-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
unused _defmt
symbols are kept by the linker
#588
Comments
Behavior is the same using GNU LD so probably not a LLD bug. |
it seems that so ... maybe we can drop the |
Any recent changes here? I found this issue after noticing that a big chunk of formatting code was linked into my WIP USB-HS DFU bootloader for an stm32f7. I'd already removed ~3K of formatting code by persistently using defmt::panic! and defmt::unwrap!, plus not depending on crates that do any raw panics. "cargo bloat" shows 1.7K in "<&T as core::fmt::Display>::fmt", which is only called by the core::panic! implementation, which is only invoked by __defmt_default_panic, which is only linked in because of this issue. (I provide my own #[defmt::panic_handler] diverging fn that just does a udf.) I see that the linker script now does a "PROVIDE(_defmt_panic = __defmt_default_panic)", and I see that the implementation of #[defmt::panic_handler] names the function _defmt_panic, so it looks like the situation is a little different. Is there a good way to get the linker to drop the __defmt_default_panic now? |
I haven't checked yet if feature flags are available to build.rs files, but if they are, would you be open to a PR adding a feature flag (on by default) that if missing would disable this PROVIDE from the linker script? For binary crates that don't set a defmt::panic_handler, disabling the feature would break linking, but if the binary crate does provide such a function, they can disable the feature with no issues. And just removing the PROVIDE line definitely saves that full 1.7K from my binary, plus a little for smaller functions only called by it. |
related to #586
Steps to reproduce
Start from app-template, configure it to use the
main
branch ofdefmt
then modifyhello
to look like thisThis is going to become more relevant after #519 lands because even if you fully disable logs (
DEFMT_LOG=off
) the symbols are kept and they take up valuable Flash space.The text was updated successfully, but these errors were encountered: