about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2023-04-20 09:47:16 +0200
committerLukas Wirth <lukastw97@gmail.com>2023-04-20 10:07:28 +0200
commite434b5b9ece208a42bdc960f053fd5f39a67054f (patch)
treeac42bb631a9746a6d9c561e61fd0c3fd4e8d405f
parent7fde08365c4c3cfc9a9f8a6a02693b789adbe6da (diff)
downloadrust-e434b5b9ece208a42bdc960f053fd5f39a67054f.tar.gz
rust-e434b5b9ece208a42bdc960f053fd5f39a67054f.zip
Allow overwriting the sysroot compile flag in compile tests
-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"));