Skip to content

Commit d6aaf7b

Browse files
committed
Avoid redundant -Wl,-dylib flag when linking
1 parent fc0f045 commit d6aaf7b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,14 @@ impl<'a> GccLinker<'a> {
404404
fn build_dylib(&mut self, crate_type: CrateType, out_filename: &Path) {
405405
// On mac we need to tell the linker to let this library be rpathed
406406
if self.sess.target.is_like_osx {
407-
if !self.is_ld {
407+
if self.is_cc() {
408+
// `-dynamiclib` makes `cc` pass `-dylib` to the linker.
408409
self.cc_arg("-dynamiclib");
410+
} else {
411+
self.link_arg("-dylib");
412+
// Clang also sets `-dynamic`, but that's implied by `-dylib`, so unnecessary.
409413
}
410414

411-
self.link_arg("-dylib");
412-
413415
// Note that the `osx_rpath_install_name` option here is a hack
414416
// purely to support bootstrap right now, we should get a more
415417
// principled solution at some point to force the compiler to pass

0 commit comments

Comments
 (0)