Skip to content

Commit f4b80ca

Browse files
committed
Auto merge of rust-lang#113200 - ferrocene:pa-fix-mir-opt-bless, r=oli-obk
Fix loading target specs in compiletest not working with custom targets In rust-lang#112454 (comment) it was pointed out that the PR broke blessing mir-opt tests. Since rust-lang#112418, blessing mir-opt tests generates "synthetic targets", which are custom target specs. Those specs are not included in `--print=all-target-specs-json`, and rust-lang#112454 required that the current target was returned by that flag. This PR fixes the breakage by loading the target spec for the current target explicitly, if a custom target is detected. r? `@oli-obk`
2 parents 56d507d + 00cc815 commit f4b80ca

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/tools/compiletest/src/common.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ pub struct TargetCfgs {
439439

440440
impl TargetCfgs {
441441
fn new(config: &Config) -> TargetCfgs {
442-
let targets: HashMap<String, TargetCfg> = serde_json::from_str(&rustc_output(
442+
let mut targets: HashMap<String, TargetCfg> = serde_json::from_str(&rustc_output(
443443
config,
444444
&["--print=all-target-specs-json", "-Zunstable-options"],
445445
))
@@ -454,6 +454,18 @@ impl TargetCfgs {
454454
let mut all_families = HashSet::new();
455455
let mut all_pointer_widths = HashSet::new();
456456

457+
// Handle custom target specs, which are not included in `--print=all-target-specs-json`.
458+
if config.target.ends_with(".json") {
459+
targets.insert(
460+
config.target.clone(),
461+
serde_json::from_str(&rustc_output(
462+
config,
463+
&["--print=target-spec-json", "-Zunstable-options", "--target", &config.target],
464+
))
465+
.unwrap(),
466+
);
467+
}
468+
457469
for (target, cfg) in targets.iter() {
458470
all_archs.insert(cfg.arch.clone());
459471
all_oses.insert(cfg.os.clone());

0 commit comments

Comments
 (0)