diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-10 12:49:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-10 12:49:19 +0200 |
| commit | 173c50fb0e0ee3eb767b2687a6439a75a58f8978 (patch) | |
| tree | 84f20380d4a08f104c79cbab405207e1752699c1 | |
| parent | a2c43eb80698dc551bf9f4c0041b2cde751a7a5d (diff) | |
| parent | d6aaf7b036868c29e74ec380493f81ecbd1a4503 (diff) | |
| download | rust-173c50fb0e0ee3eb767b2687a6439a75a58f8978.tar.gz rust-173c50fb0e0ee3eb767b2687a6439a75a58f8978.zip | |
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 https://github.com/rust-lang/rust/commit/e338a4154b134fc1d4628496d4ccf85b7af7c443, 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
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 3f3d305da01..c4bb82d0dd7 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -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 |
