about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-04-20 14:36:55 +0200
committerGitHub <noreply@github.com>2023-04-20 14:36:55 +0200
commit56d08d1bcddcba8e3fbdbb0231b992a328ee62b3 (patch)
treefe3753d65109ef0b021cdcfcf060175f423a9d9d
parente2ad167c12b351336cca18b62a626e1fdbcb81ad (diff)
parente434b5b9ece208a42bdc960f053fd5f39a67054f (diff)
downloadrust-56d08d1bcddcba8e3fbdbb0231b992a328ee62b3.tar.gz
rust-56d08d1bcddcba8e3fbdbb0231b992a328ee62b3.zip
Rollup merge of #110584 - ferrocene:comptest-sysroot-arg, r=oli-obk
Allow overwriting the sysroot compile flag in compile tests

This was added in https://github.com/rust-lang/rust/pull/110478/files#diff-03a0567fa80ca04ed5a55f9ac5c711b4f84659be2d0ac4a984196d581c04f76b, unconditionally passing the `sysroot` flag to the compile test invocations. In our ferrocene fork we have a few tests that test the `sysroot` flag specifically which fail due to the flag being passed multiple times now.

We believe upstreaming this small change could be beneficial should the rust-lang/rust also want to test certain sysroot setups in the future.
-rw-r--r--src/tools/compiletest/src/runtest.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 1a4e9b58383..0c17ae79808 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1900,8 +1900,11 @@ impl<'test> TestCx<'test> {
         // Use a single thread for efficiency and a deterministic error message order
         rustc.arg("-Zthreads=1");
 
-        // In stage 0, make sure we use `stage0-sysroot` instead of the bootstrap sysroot.
-        rustc.arg("--sysroot").arg(&self.config.sysroot_base);
+        // Optionally prevent default --sysroot if specified in test compile-flags.
+        if !self.props.compile_flags.iter().any(|flag| flag.starts_with("--sysroot")) {
+            // In stage 0, make sure we use `stage0-sysroot` instead of the bootstrap sysroot.
+            rustc.arg("--sysroot").arg(&self.config.sysroot_base);
+        }
 
         // Optionally prevent default --target if specified in test compile-flags.
         let custom_target = self.props.compile_flags.iter().any(|x| x.starts_with("--target"));