about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-10 11:00:28 +0000
committerbors <bors@rust-lang.org>2024-10-10 11:00:28 +0000
commit4cc494bbfe9911d24f3ee521f98d5c6bb7e3ffe8 (patch)
treee19d6f2a7cab3a46426146fa6e8edf8c43730f9b /compiler/rustc_codegen_ssa
parentde19f2b73d4fd456be06f299a5d9d8fd622ca298 (diff)
parent1c62cff89775b6ab0feb0ed6c888114a64a1798f (diff)
downloadrust-4cc494bbfe9911d24f3ee521f98d5c6bb7e3ffe8.tar.gz
rust-4cc494bbfe9911d24f3ee521f98d5c6bb7e3ffe8.zip
Auto merge of #131495 - matthiaskrgr:rollup-lwf2u4i, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #130625 (Fix a few relative paths in rustc doc)
 - #131397 (fix/update teach_note from 'escaping mutable ref/ptr' const-check)
 - #131479 (Apple: Avoid redundant `-Wl,-dylib` flag when linking)
 - #131480 (Fix hardcoded strip path when cross-compiling from Linux to Darwin)
 - #131482 (structurally resolve adts and tuples expectations too)
 - #131484 (Add myself back to review rotation)
 - #131491 (impossible obligations fast path)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs4
-rw-r--r--compiler/rustc_codegen_ssa/src/back/linker.rs8
2 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index e7b1c63a822..34dc599e4fd 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -1087,7 +1087,9 @@ fn link_natively(
     let strip = sess.opts.cg.strip;
 
     if sess.target.is_like_osx {
-        let stripcmd = "/usr/bin/strip";
+        // Use system `strip` when running on host macOS.
+        // <https://github.com/rust-lang/rust/pull/130781>
+        let stripcmd = if cfg!(target_os = "macos") { "/usr/bin/strip" } else { "strip" };
         match (strip, crate_type) {
             (Strip::Debuginfo, _) => {
                 strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
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