]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/builder.rs
Make rust.use-lld config option work with non MSVC targets
[rust.git] / src / bootstrap / builder.rs
index 144e146685fb20658d051a1a92a9da41a4e5644a..e13a5f2465336fbea5d44ab4c4bd3a87e13556d0 100644 (file)
@@ -1037,7 +1037,7 @@ pub fn cargo(
             }
         }
 
-        // FIXME: Don't use LLD if we're compiling libtest, since it fails to link it.
+        // FIXME: Don't use LLD with MSVC if we're compiling libtest, since it fails to link it.
         // See https://github.com/rust-lang/rust/issues/68647.
         let can_use_lld = mode != Mode::Std;
 
@@ -1049,6 +1049,11 @@ pub fn cargo(
             let target = crate::envify(&target.triple);
             cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker);
         }
+
+        if self.config.use_lld && !target.contains("msvc") {
+            rustflags.arg("-Clink-args=-fuse-ld=lld");
+        }
+
         if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc {
             cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler));
         }