Skip to content

Commit 0cc120b

Browse files
committed
For compiletests, use the linker if present.
When running x.py test tests/ui with a custom linker script, we found that 204 tests actually invoke the default linker (/usr/bin/ld) instead of the linker script. Depending on the system linker, this will cause those tests to fail. Many of the failing tests (196) use "// aux-build:..." directives. One such example is tests/ui/annotate-snippet/multispan.rs. In cases where there were failures, we ran with -v and confirmed that we saw "linker: Some(<path deleted>)" when the compiletest configuration was dumped. Nevertheless, the rustc command lines for the failing tests did not contain -Clinker=XXX, resulting in errors like the following: = note: /usr/bin/ld: /path/to/libunwind.a(UnwindLevel1-gcc-ext.o): unrecognized relocation (0x2a) in section `.text._Unwind_GetDataRelBase' /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status
1 parent e216300 commit 0cc120b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,10 @@ impl<'test> TestCx<'test> {
18971897
// Use a single thread for efficiency and a deterministic error message order
18981898
rustc.arg("-Zthreads=1");
18991899

1900+
if let Some(ref linker) = self.config.linker {
1901+
rustc.arg(format!("-Clinker={}", linker));
1902+
}
1903+
19001904
// Optionally prevent default --target if specified in test compile-flags.
19011905
let custom_target = self.props.compile_flags.iter().any(|x| x.starts_with("--target"));
19021906

0 commit comments

Comments
 (0)