Skip to content

Commit

Permalink
Rollup merge of #131479 - madsmtm:avoid-redundant-dylib, r=jieyouxu
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matthiaskrgr authored Oct 10, 2024
2 parents a2c43eb + d6aaf7b commit 173c50f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,14 @@ impl<'a> GccLinker<'a> {
fn build_dylib(&mut self, crate_type: CrateType, out_filename: &Path) {
// On mac we need to tell the linker to let this library be rpathed
if self.sess.target.is_like_osx {
if !self.is_ld {
if self.is_cc() {
// `-dynamiclib` makes `cc` pass `-dylib` to the linker.
self.cc_arg("-dynamiclib");
} else {
self.link_arg("-dylib");
// Clang also sets `-dynamic`, but that's implied by `-dylib`, so unnecessary.
}

self.link_arg("-dylib");

// Note that the `osx_rpath_install_name` option here is a hack
// purely to support bootstrap right now, we should get a more
// principled solution at some point to force the compiler to pass
Expand Down

0 comments on commit 173c50f

Please sign in to comment.