about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLuqman Aden <me@luqman.ca>2021-05-13 16:55:33 -0700
committerLuqman Aden <me@luqman.ca>2021-05-13 16:55:33 -0700
commit3fe1d7f78913231cdb7a8748149f7b2e67b814bd (patch)
tree545da4c61ad88d51f286347d538bbc6dd3a3f759
parent6d395a1c2946c79966490f5b1e6e619d3a713e6b (diff)
downloadrust-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.rs6
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");
         }
     }