-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
#[link_section]
does not work in libraries on release
#85045
Comments
#[link_section]
does not work in libraries on release
|
The section is obviously used, see the |
It is used at a source level, but there's nothing preventing optimizations from inlining the value of the (immutable) static into the printing routines. At which point the static can become otherwise unused. FWIW I'm not able to reproduce this, regardless:
The only recommendation I have is the same as before. Verify that it isn't the linker removing this section. Perhaps the easiest way would be to utilize a linker script with |
You are right its an optimization thing. But I still think it is an unwanted behavior. Note that I changed the example |
Since #91504 on nightly we now have |
I tried this code while compiling for release:
bin.rs
lib.rs
I expected to see this happen (compiled with debug):
asaffisher@ubuntu:/mnt/hgfs/elfredo/target/debug$ readelf -S test_echo_patch_elf | grep extend [18] .extended PROGBITS 000000000003cec8 0003cec8
Instead, this happened(compiled in release):
asaffisher@ubuntu:/mnt/hgfs/elfredo/target/release$ readelf -S test_echo_patch_elf | grep extend asaffisher@ubuntu:/mnt/hgfs/elfredo/target/release$
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: