Skip to content

Commit 75ada3a

Browse files
committed
Auto merge of rust-lang#102438 - andrewpollack:add-target-rustc-flags, r=Mark-Simulacrum
Adding target_rustcflags to `compiletest` TargetCfg creation Adjustment to rust-lang#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`
2 parents 24ac6a2 + 2f172b4 commit 75ada3a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/tools/compiletest/src/common.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ impl Config {
385385
}
386386

387387
fn target_cfg(&self) -> &TargetCfg {
388-
self.target_cfg.borrow_with(|| TargetCfg::new(&self.rustc_path, &self.target))
388+
self.target_cfg
389+
.borrow_with(|| TargetCfg::new(&self.rustc_path, &self.target, &self.target_rustcflags))
389390
}
390391

391392
pub fn matches_arch(&self, arch: &str) -> bool {
@@ -456,11 +457,12 @@ pub enum Endian {
456457
}
457458

458459
impl TargetCfg {
459-
fn new(rustc_path: &Path, target: &str) -> TargetCfg {
460+
fn new(rustc_path: &Path, target: &str, target_rustcflags: &Option<String>) -> TargetCfg {
460461
let output = match Command::new(rustc_path)
461462
.arg("--print=cfg")
462463
.arg("--target")
463464
.arg(target)
465+
.args(target_rustcflags.into_iter().map(|s| s.split_whitespace()).flatten())
464466
.output()
465467
{
466468
Ok(output) => output,

0 commit comments

Comments
 (0)