Skip to content

Commit

Permalink
Auto merge of #102438 - andrewpollack:add-target-rustc-flags, r=Mark-…
Browse files Browse the repository at this point in the history
…Simulacrum

Adding target_rustcflags to `compiletest` TargetCfg creation

Adjustment to #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`
  • Loading branch information
bors committed Oct 5, 2022
2 parents 24ac6a2 + 2f172b4 commit 75ada3a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 75ada3a

Please sign in to comment.