Skip to content

Commit 3fe1d7f

Browse files
committed
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.
1 parent 6d395a1 commit 3fe1d7f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -469,17 +469,15 @@ impl<'a> Linker for GccLinker<'a> {
469469
// eliminate the metadata. If we're building an executable, however,
470470
// --gc-sections drops the size of hello world from 1.8MB to 597K, a 67%
471471
// reduction.
472-
} else if !keep_metadata {
472+
} else if self.sess.target.linker_is_gnu && !keep_metadata {
473473
self.linker_arg("--gc-sections");
474474
}
475475
}
476476

477477
fn no_gc_sections(&mut self) {
478478
if self.sess.target.is_like_osx {
479479
self.linker_arg("-no_dead_strip");
480-
} else if self.sess.target.is_like_solaris {
481-
self.linker_arg("-zrecord");
482-
} else {
480+
} else if self.sess.target.linker_is_gnu {
483481
self.linker_arg("--no-gc-sections");
484482
}
485483
}

0 commit comments

Comments
 (0)