-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Force rlibs to be linked in whole for cdylib and bin #93791
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Would it make sense to only do this when |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Wow! It's great that #50007 is finally seeing a fix, after all this time! Just to make sure, we still need #93718 in addition to this, right?
@nico-abram I could be wrong, but think it might be a little more complex than this, to handle the case where a |
From the test, it seems that the current behaviour is deliberately introduced in cc719d2 by @alexcrichton. |
I was planning to make an exactly opposite change in #85144, but it requires stabilizing the |
On a closer look, this PR doesn't touch native libs, only rlibs, so the linking modifiers that I've mentioned are somewhat orthogonal to this (but we can support similar linking modifiers for rlibs too). However, including all symbols is still a huge overkill for fixing #50007 and #47384, those issues need to be addressed in some more selective way. |
What's your suggested alternative? In #85144 you said (for dylib) we are using symbol export list for this, but this is not sufficient: the exported symbol list is passed to LD using version script, but this wouldn't affect the symbol resolution. E.g. |
In my mental model, the artifact of each crate, being a compilation unit on its own, should be closer to a .o file than .a file. So I also think link rlibs as a whole should be the expected behaviour. |
Somehow mark only the |
Let's do a perf run to see how "overkill" is this change. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit e760877 with merge f80eb827f9222fa2d5893442f376349408e73200... |
☀️ Try build successful - checks-actions |
Queued f80eb827f9222fa2d5893442f376349408e73200 with parent e7aca89, future comparison URL. |
Finished benchmarking commit (f80eb827f9222fa2d5893442f376349408e73200): comparison url. Summary: This benchmark run shows 45 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never |
ping from triage: FYI: when a PR is ready for review, post a message containing |
Currently there is a disagreement about whether this should be done or not. |
Closing in favor of #95604. |
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? `@petrochenkov` cc `@carbotaniuman`
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? ``@petrochenkov`` cc ``@carbotaniuman``
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? ```@petrochenkov``` cc ```@carbotaniuman```
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? `@petrochenkov` cc `@carbotaniuman`
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? `@petrochenkov` cc `@carbotaniuman`
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix rust-lang#50007 and rust-lang#47384 This is the synthetic object file approach that I described in rust-lang#95363 (comment), allowing all exported and used symbols to be linked while still allowing them to be GCed. Related rust-lang#93791, rust-lang#95363 r? `@petrochenkov` cc `@carbotaniuman`
Fix #50007 and #47384
These issues are caused by the fact that linker will perform archive member selection. By default, an object file in an archive won't be selected unless it is needed to satisfy an undefined reference. This step precedes any linker script and section GC. To address this issue, we can just the whole rlibs to be linked (this is
--whole-archive
for ELF targets).