Skip to content

Commit 173c50f

Browse files
authored
Rollup merge of #131479 - madsmtm:avoid-redundant-dylib, r=jieyouxu
Apple: Avoid redundant `-Wl,-dylib` flag when linking Seems to have been introduced all the way back in e338a41, but should be redundant, `-dynamiclib` should already make `cc` set `-dylib` when linking. Spotted this while trying to get `-Clinker-flavor=gcc` and `-Clinker-flavor=ld` closer together, not that important to fix. `@rustbot` label O-apple
2 parents a2c43eb + d6aaf7b commit 173c50f

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)