Uh oh!
There was an error while loading. Please reload this page.
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.
rust-highfive
commented
May 14, 2021
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
luqmana
commented
May 14, 2021
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
May 15, 2021
@bors r+ |
bors
commented
May 15, 2021
📌 Commit 3fe1d7f has been approved by |
bors
commented
May 16, 2021
⌛ 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.
luqmana
commented
May 16, 2021
Test failed because the mingw targets do use |
petrochenkov
commented
May 16, 2021
@luqmana If it supports |
luqmana
commented
May 16, 2021
Hmm, then should the docs be updated since they say
The man pages for |
petrochenkov
commented
May 17, 2021
Here's what my investigation showed:
I'm ok with setting |
luqmana
commented
May 17, 2021
@petrochenkov Thanks for digging into that! Updated the PR to handle those now |
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
May 18, 2021
r=me with #85274 (comment) addressed. |
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
May 18, 2021
Thanks! |
bors
commented
May 18, 2021
📌 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 Fixesrust-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_solarisbranch fromgc_sectionsin #84468 made sense as-z ignore/recordare more analogous to the--[no-]-as-neededflags, it inadvertently caused solaris linkers to be passed the--gc-sectionsflag. So let's just change it to be more explicit about when we pass those flags.