about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-05 17:54:32 +0000
committerbors <bors@rust-lang.org>2022-10-05 17:54:32 +0000
commit75ada3a1534fbc4801c73fafecd0f7455f1e3419 (patch)
tree7f7a592c84e1b5921f458dff3e229087c036394b /src/tools/compiletest
parent24ac6a26bcf5be1ac841e7fe969bd992b3461f9d (diff)
parent2f172b4f0b024990a0fd3df2fedd0fe18b48a303 (diff)
downloadrust-75ada3a1534fbc4801c73fafecd0f7455f1e3419.tar.gz
rust-75ada3a1534fbc4801c73fafecd0f7455f1e3419.zip
Auto merge of #102438 - andrewpollack:add-target-rustc-flags, r=Mark-Simulacrum
Adding target_rustcflags to `compiletest` TargetCfg creation

Adjustment to https://github.com/rust-lang/rust/pull/102134, ensures config returned by `rustc --target foo --print cfg` accurately reflects rustflags passed via `target_rustcflags`.

Fixes breaking change of not correctly handling `x.py test ... --test-args "--target-rustcflags -Cpanic=abort --target-rustcflags -Zpanic_abort_tests"`

cc `@djkoloski`
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/common.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index 4994fb9bbf9..b9ac6c9f364 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -385,7 +385,8 @@ impl Config {
     }
 
     fn target_cfg(&self) -> &TargetCfg {
-        self.target_cfg.borrow_with(|| TargetCfg::new(&self.rustc_path, &self.target))
+        self.target_cfg
+            .borrow_with(|| TargetCfg::new(&self.rustc_path, &self.target, &self.target_rustcflags))
     }
 
     pub fn matches_arch(&self, arch: &str) -> bool {
@@ -456,11 +457,12 @@ pub enum Endian {
 }
 
 impl TargetCfg {
-    fn new(rustc_path: &Path, target: &str) -> TargetCfg {
+    fn new(rustc_path: &Path, target: &str, target_rustcflags: &Option<String>) -> TargetCfg {
         let output = match Command::new(rustc_path)
             .arg("--print=cfg")
             .arg("--target")
             .arg(target)
+            .args(target_rustcflags.into_iter().map(|s| s.split_whitespace()).flatten())
             .output()
         {
             Ok(output) => output,