Skip to content

Commit c805c62

Browse files
committed
fix compiletest detection of needs-rust-lld tests
for both windows and unixes
1 parent 5f25154 commit c805c62

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/tools/compiletest/src/header.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -897,15 +897,27 @@ pub fn make_test_description<R: Read>(
897897
let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target);
898898
let has_memtag = util::MEMTAG_SUPPORTED_TARGETS.contains(&&*config.target);
899899
let has_shadow_call_stack = util::SHADOWCALLSTACK_SUPPORTED_TARGETS.contains(&&*config.target);
900-
// for `-Z gcc-ld=lld`
900+
901+
// For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), we need to find
902+
// whether `rust-lld` is present in the compiler under test.
903+
//
904+
// The --compile-lib-path is the path to host shared libraries, but depends on the OS. For
905+
// example:
906+
// - on linux, it can be <sysroot>/lib
907+
// - on windows, it can be <sysroot>/bin
908+
//
909+
// However, `rust-lld` is only located under the lib path, so we look for it there.
901910
let has_rust_lld = config
902911
.compile_lib_path
912+
.parent()
913+
.expect("couldn't traverse to the parent of the specified --compile-lib-path")
914+
.join("lib")
903915
.join("rustlib")
904916
.join(&config.target)
905917
.join("bin")
906-
.join("gcc-ld")
907-
.join(if config.host.contains("windows") { "ld.exe" } else { "ld" })
918+
.join(if config.host.contains("windows") { "rust-lld.exe" } else { "rust-lld" })
908919
.exists();
920+
909921
iter_header(path, src, &mut |revision, ln| {
910922
if revision.is_some() && revision != cfg {
911923
return;

0 commit comments

Comments
 (0)