Skip to content

Remove #[no_mangle] from CORE_PERIPHERALS to enable zero-cost peripherals #242

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

Closed
jonas-schievink opened this issue Jul 12, 2020 · 0 comments · Fixed by #243
Closed

Remove #[no_mangle] from CORE_PERIPHERALS to enable zero-cost peripherals #242

jonas-schievink opened this issue Jul 12, 2020 · 0 comments · Fixed by #243

Comments

@jonas-schievink
Copy link
Contributor

The #[no_mangle] on the CORE_PERIPHERALS currently prevents LLVM from optimizing it out when only stored to:

#[no_mangle]
static mut CORE_PERIPHERALS: bool = false;

This means that even if an app only uses Peripherals::steal(), it still has to pay 1 Byte of RAM for the global. Since 1 is greater than 0, this can be improved.

#[no_mangle] is used to prevent multiple cortex-m versions to be linked together, so this behavior must be retained somehow. While we already use links in Cargo.toml for this, this only works with newer versions (that are currently not even released), so another (zero-sized) global should be introduced to take over CORE_PERIPHERALS' job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant