Skip to content

Commit

Permalink
Only pass --[no-]gc-sections if linker is GNU ld.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
luqmana committed May 13, 2021
1 parent 6d395a1 commit 3fe1d7f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Expand Up @@ -469,17 +469,15 @@ 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");
}
}

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");
}
}
Expand Down

0 comments on commit 3fe1d7f

Please sign in to comment.