about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-20 07:10:18 +0000
committerbors <bors@rust-lang.org>2022-09-20 07:10:18 +0000
commit8fd6d03e22fba2930ad377b87299de6a37076074 (patch)
treec5fa9caa1ae1f3572549c588e78ba3fc400d90c5 /compiler/rustc_codegen_ssa
parentacb8934fd57b3c2740c4abac0a5728c2c9b1423b (diff)
parenta38a082afb5522a0943e60b556588eb78a4dda80 (diff)
Auto merge of #101806 - BelovDV:issue-fix-fn-find_library, r=petrochenkov
fix verbatim with upstream dependencies

https://github.com/rust-lang/rust/issues/99425#issuecomment-1207224161

r? `@petrochenkov`
Diffstat (limited to 'compiler/rustc_codegen_ssa')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/linker.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs
index e505543b27c..e0bd7a33f73 100644
--- a/compiler/rustc_codegen_ssa/src/back/linker.rs
+++ b/compiler/rustc_codegen_ssa/src/back/linker.rs
@@ -439,7 +439,10 @@ impl<'a> Linker for GccLinker<'a> {
             }
         }
         self.hint_dynamic();
-        self.cmd.arg(format!("-l{}{}", if verbatim { ":" } else { "" }, lib));
+        self.cmd.arg(format!(
+            "-l{}{lib}",
+            if verbatim && self.sess.target.linker_is_gnu { ":" } else { "" },
+        ));
         if !as_needed {
             if self.sess.target.is_like_osx {
                 // See above FIXME comment
@@ -450,7 +453,10 @@ impl<'a> Linker for GccLinker<'a> {
     }
     fn link_staticlib(&mut self, lib: &str, verbatim: bool) {
         self.hint_static();
-        self.cmd.arg(format!("-l{}{}", if verbatim { ":" } else { "" }, lib));
+        self.cmd.arg(format!(
+            "-l{}{lib}",
+            if verbatim && self.sess.target.linker_is_gnu { ":" } else { "" },
+        ));
     }
     fn link_rlib(&mut self, lib: &Path) {
         self.hint_static();
@@ -504,10 +510,10 @@ impl<'a> Linker for GccLinker<'a> {
         self.hint_static();
         let target = &self.sess.target;
         if !target.is_like_osx {
-            self.linker_arg("--whole-archive").cmd.arg(format!(
-                "-l{}{}",
-                if verbatim { ":" } else { "" },
-                lib
+            self.linker_arg("--whole-archive");
+            self.cmd.arg(format!(
+                "-l{}{lib}",
+                if verbatim && self.sess.target.linker_is_gnu { ":" } else { "" },
             ));
             self.linker_arg("--no-whole-archive");
         } else {