-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc doesn't propagate custom link sections #31758
Comments
Do you have a small reproduction that we can test against? It'd help to know how you're linking a library into a second one as that may have something going awry there as well. |
Pushed a small reproduction to https://github.com/rasendubi/rust_link_section. Steps to reproduce:
I also discovered the issue shows only with LTO enabled. Seems that it collects the section because nobody refers to it. Can I instruct the compiler to keep the section? |
Ah it looks like this was caused by #30830 where we fixed LTO to internalize static symbols that weren't needed as part of the ABI. If you mark the symbol as We don't really exhaustively define how we retain symbols, however, especially for LTO, so this is indeed a little bit of a gray area as to what the "correct" behavior here is. cc @arcnmx |
- data-layout is no longer needed in target file. (Changed in previous commit.) See rust-lang/rust#31367 - Symbols with custom section should be marked as no_mangle; otherwise, LTO will collect them. See rust-lang/rust#31758
Thanks! Adding I'm closing the issue now. Feel free to re-open if you expect any further activity. |
As much as I would've liked |
I have a library that outputs a custom link section (
.isr_vector
). That works fine, but when I link that library into the second one, there is no.isr_vector
section in the result static library.That worked before, so I bisected the issue down to a nightly build. The first bad nightly is 2016-02-12 (
rustc 1.8.0-nightly (4b2c7030f 2016-02-12)
). The last good one is 2016-02-11 (rustc 1.8.0-nightly (3f4227af1 2016-02-10)
).The full source is here: https://github.com/rasendubi/bkernel/tree/f788e32a2e0493420236cc2642cfaa9c4824203a. The link section is defined in https://github.com/rasendubi/bkernel/blob/f788e32a2e0493420236cc2642cfaa9c4824203a/stm32f4/isr_vector.rs.
The text was updated successfully, but these errors were encountered: