diff options
| author | Luqman Aden <me@luqman.ca> | 2021-05-13 16:55:33 -0700 |
|---|---|---|
| committer | Luqman Aden <me@luqman.ca> | 2021-05-13 16:55:33 -0700 |
| commit | 3fe1d7f78913231cdb7a8748149f7b2e67b814bd (patch) | |
| tree | 545da4c61ad88d51f286347d538bbc6dd3a3f759 | |
| parent | 6d395a1c2946c79966490f5b1e6e619d3a713e6b (diff) | |
| download | rust-3fe1d7f78913231cdb7a8748149f7b2e67b814bd.tar.gz rust-3fe1d7f78913231cdb7a8748149f7b2e67b814bd.zip | |
Only pass --[no-]gc-sections if linker is GNU ld.
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.
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 93059b2323d..74629fcd118 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -469,7 +469,7 @@ impl<'a> Linker for GccLinker<'a> { // eliminate the metadata. If we're building an executable, however, // --gc-sections drops the size of hello world from 1.8MB to 597K, a 67% // reduction. - } else if !keep_metadata { + } else if self.sess.target.linker_is_gnu && !keep_metadata { self.linker_arg("--gc-sections"); } } @@ -477,9 +477,7 @@ impl<'a> Linker for GccLinker<'a> { fn no_gc_sections(&mut self) { if self.sess.target.is_like_osx { self.linker_arg("-no_dead_strip"); - } else if self.sess.target.is_like_solaris { - self.linker_arg("-zrecord"); - } else { + } else if self.sess.target.linker_is_gnu { self.linker_arg("--no-gc-sections"); } } |
