about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2022-09-06 17:19:46 +0200
committerRémy Rakic <remy.rakic+github@gmail.com>2022-09-07 14:51:54 +0200
commitc805c62562e2d19116e8a4099c498276ae08aebf (patch)
tree78bf50f25e4eb47f492255476cbb46ce8225fce3
parent5f25154813b6eeb353bd7f0f758c4475cd239ffd (diff)
downloadrust-c805c62562e2d19116e8a4099c498276ae08aebf.tar.gz
rust-c805c62562e2d19116e8a4099c498276ae08aebf.zip
fix compiletest detection of needs-rust-lld tests
for both windows and unixes
-rw-r--r--src/tools/compiletest/src/header.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 8f097f47b45..3ff1cbf20cd 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -897,15 +897,27 @@ pub fn make_test_description<R: Read>(
     let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target);
     let has_memtag = util::MEMTAG_SUPPORTED_TARGETS.contains(&&*config.target);
     let has_shadow_call_stack = util::SHADOWCALLSTACK_SUPPORTED_TARGETS.contains(&&*config.target);
-    // for `-Z gcc-ld=lld`
+
+    // For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), we need to find
+    // whether `rust-lld` is present in the compiler under test.
+    //
+    // The --compile-lib-path is the path to host shared libraries, but depends on the OS. For
+    // example:
+    // - on linux, it can be <sysroot>/lib
+    // - on windows, it can be <sysroot>/bin
+    //
+    // However, `rust-lld` is only located under the lib path, so we look for it there.
     let has_rust_lld = config
         .compile_lib_path
+        .parent()
+        .expect("couldn't traverse to the parent of the specified --compile-lib-path")
+        .join("lib")
         .join("rustlib")
         .join(&config.target)
         .join("bin")
-        .join("gcc-ld")
-        .join(if config.host.contains("windows") { "ld.exe" } else { "ld" })
+        .join(if config.host.contains("windows") { "rust-lld.exe" } else { "rust-lld" })
         .exists();
+
     iter_header(path, src, &mut |revision, ln| {
         if revision.is_some() && revision != cfg {
             return;