Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading target specs in compiletest not working with custom targets #113200

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ pub struct TargetCfgs {

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

// Handle custom target specs, which are not included in `--print=all-target-specs-json`.
if config.target.ends_with(".json") {
targets.insert(
config.target.clone(),
serde_json::from_str(&rustc_output(
config,
&["--print=target-spec-json", "-Zunstable-options", "--target", &config.target],
))
.unwrap(),
);
}

for (target, cfg) in targets.iter() {
all_archs.insert(cfg.arch.clone());
all_oses.insert(cfg.os.clone());
Expand Down