Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow replacement of functions with hardware-specific alternatives #451

Closed
jonathanpallant opened this issue Jan 28, 2022 · 1 comment
Closed

Comments

@jonathanpallant
Copy link

The Raspberry Pi Silicon RP2040 is a dual-Cortex-M0+ based microcontroller, but it also has a Hardware Divide peripheral.

It it possible to mark __udivmodsi4 (and/or similar) as weak symbols so we can replace them in a library crate? Or is there some other supported way to drop-in a faster platform-specific divide algorithm?

Ref: rp-rs/rp-hal#278

@Amanieu
Copy link
Member

Amanieu commented Jan 31, 2022

I'm hesitant to involve weak symbols since they have some over on targets that use dynamic linking: defining a symbol as weak forces all calls to it to be indirect via the PLT since a strong definition could be present in a shared library that is loaded at runtime.

Instead we should prefer the current system of relying on the linker as described by rp-rs/rp-hal#278 (comment). Rustc guarantees that the compiler_builtins crate is always linked last so its symbols will only be used if no other definition is available in the libraries listed in the linker args.

There are currently a few issues with this due to the fact that compiler-builtins isn't putting each intrinsic in its own object file (#412), but this is something that should be fixed within compiler-builtins.

@Amanieu Amanieu closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants