-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Only pass --[no-]gc-sections if linker is GNU ld. #85274
Conversation
LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the case of at least the solaris ld in illumos, that flag is unrecognized and will cause the linking step to fail.
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ |
📌 Commit 3fe1d7f has been approved by |
⌛ Testing commit 3fe1d7f with merge 5d28235010a9b782714887f7a7e91bf7dd8da0b4... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
… also indicate linker_is_gnu.
Test failed because the mingw targets do use |
@luqmana If it supports |
Hmm, then should the docs be updated since they say
The man pages for |
Here's what my investigation showed:
I'm ok with setting |
@petrochenkov Thanks for digging into that! Updated the PR to handle those now |
r=me with #85274 (comment) addressed. |
Thanks! |
📌 Commit ac5fd90 has been approved by |
…r=petrochenkov Only pass --[no-]gc-sections if linker is GNU ld. Fixes a regression from rust-lang#84468 where linking now fails with solaris linkers. LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the case of at least the solaris ld in illumos, that flag is unrecognized and will cause the linking step to fail. Even though removing the `is_like_solaris` branch from `gc_sections` in rust-lang#84468 made sense as `-z ignore/record` are more analogous to the `--[no-]-as-needed` flags, it inadvertently caused solaris linkers to be passed the `--gc-sections` flag. So let's just change it to be more explicit about when we pass those flags.
Rollup of 8 pull requests Successful merges: - rust-lang#83366 (Stabilize extended_key_value_attributes) - rust-lang#83767 (Fix v0 symbol mangling bug) - rust-lang#84883 (compiletest: "fix" FileCheck with --allow-unused-prefixes) - rust-lang#85274 (Only pass --[no-]gc-sections if linker is GNU ld.) - rust-lang#85297 (bootstrap: build cargo only if requested in tools) - rust-lang#85396 (rustdoc: restore header sizes) - rust-lang#85425 (Fix must_use on `Option::is_none`) - rust-lang#85438 (Fix escape handling) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Rust used to pass `--gc-section` automatically. In rust-lang/rust#85274, this behavior was changed to only pass that flag for targets that use a GNU linker. So we have to add it manually, otherwise the bootloader grows too large to be loaded by our assembly stage.
Swap TargetOptions::linker_is_gnu default from false to true and update targets as appropriate. rust-lang#85274 gated the `--gc-sections` flag on targets that specified `linker_is_gnu` to stop us from passing it to incompatible linkers. But that had the unintended effect of the flag no longer being passed on targets for which it is valid and hence caused a regression in binary size. Given that most `ld`-style linkers are GNU compatible, this change flips our default for `linker_is_gnu` from false to true. That also means updating the targets that relied on the previous default: * Apple * Illumos * L4Re (not sure about this one) * MSVC * NvtPtx * Solaris Fixes rust-lang#85519
Fixes a regression from #84468 where linking now fails with solaris linkers. LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the case of at least the solaris ld in illumos, that flag is unrecognized and will cause the linking step to fail.
Even though removing the
is_like_solaris
branch fromgc_sections
in #84468 made sense as-z ignore/record
are more analogous to the--[no-]-as-needed
flags, it inadvertently caused solaris linkers to be passed the--gc-sections
flag. So let's just change it to be more explicit about when we pass those flags.