use --print=all-target-specs-json for stage1+
This commit is contained in:
parent
0e6d2053b4
commit
c075691b82
1 changed files with 33 additions and 20 deletions
|
@ -9,9 +9,9 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use crate::util::{add_dylib_path, PathBufExt};
|
use crate::util::{add_dylib_path, PathBufExt};
|
||||||
use lazycell::LazyCell;
|
use lazycell::LazyCell;
|
||||||
use std::collections::HashSet;
|
|
||||||
use test::{ColorConfig, OutputFormat};
|
|
||||||
use serde::de::{Deserialize, Deserializer, Error as _};
|
use serde::de::{Deserialize, Deserializer, Error as _};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use test::{ColorConfig, OutputFormat};
|
||||||
|
|
||||||
macro_rules! string_enum {
|
macro_rules! string_enum {
|
||||||
($(#[$meta:meta])* $vis:vis enum $name:ident { $($variant:ident => $repr:expr,)* }) => {
|
($(#[$meta:meta])* $vis:vis enum $name:ident { $($variant:ident => $repr:expr,)* }) => {
|
||||||
|
@ -410,8 +410,17 @@ pub struct TargetCfgs {
|
||||||
|
|
||||||
impl TargetCfgs {
|
impl TargetCfgs {
|
||||||
fn new(config: &Config) -> TargetCfgs {
|
fn new(config: &Config) -> TargetCfgs {
|
||||||
// Gather list of all targets
|
let targets: HashMap<String, TargetCfg> = if config.stage_id.starts_with("stage0-") {
|
||||||
let targets = rustc_output(config, &["--print=target-list"]);
|
// #[cfg(bootstrap)]
|
||||||
|
// Needed only for one cycle, remove during the bootstrap bump.
|
||||||
|
Self::collect_all_slow(config)
|
||||||
|
} else {
|
||||||
|
serde_json::from_str(&rustc_output(
|
||||||
|
config,
|
||||||
|
&["--print=all-target-specs-json", "-Zunstable-options"],
|
||||||
|
))
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let mut current = None;
|
let mut current = None;
|
||||||
let mut all_targets = HashSet::new();
|
let mut all_targets = HashSet::new();
|
||||||
|
@ -422,9 +431,7 @@ impl TargetCfgs {
|
||||||
let mut all_families = HashSet::new();
|
let mut all_families = HashSet::new();
|
||||||
let mut all_pointer_widths = HashSet::new();
|
let mut all_pointer_widths = HashSet::new();
|
||||||
|
|
||||||
for target in targets.trim().lines() {
|
for (target, cfg) in targets.into_iter() {
|
||||||
let cfg = TargetCfg::new(config, target);
|
|
||||||
|
|
||||||
all_archs.insert(cfg.arch.clone());
|
all_archs.insert(cfg.arch.clone());
|
||||||
all_oses.insert(cfg.os.clone());
|
all_oses.insert(cfg.os.clone());
|
||||||
all_envs.insert(cfg.env.clone());
|
all_envs.insert(cfg.env.clone());
|
||||||
|
@ -451,6 +458,25 @@ impl TargetCfgs {
|
||||||
all_pointer_widths,
|
all_pointer_widths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #[cfg(bootstrap)]
|
||||||
|
// Needed only for one cycle, remove during the bootstrap bump.
|
||||||
|
fn collect_all_slow(config: &Config) -> HashMap<String, TargetCfg> {
|
||||||
|
let mut result = HashMap::new();
|
||||||
|
for target in rustc_output(config, &["--print=target-list"]).trim().lines() {
|
||||||
|
let json = rustc_output(
|
||||||
|
config,
|
||||||
|
&["--print=target-spec-json", "-Zunstable-options", "--target", target],
|
||||||
|
);
|
||||||
|
match serde_json::from_str(&json) {
|
||||||
|
Ok(res) => {
|
||||||
|
result.insert(target.into(), res);
|
||||||
|
}
|
||||||
|
Err(err) => panic!("failed to parse target spec for {target}: {err}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, serde::Deserialize)]
|
#[derive(Clone, Debug, serde::Deserialize)]
|
||||||
|
@ -481,19 +507,6 @@ pub enum Endian {
|
||||||
Big,
|
Big,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TargetCfg {
|
|
||||||
fn new(config: &Config, target: &str) -> TargetCfg {
|
|
||||||
let json = rustc_output(
|
|
||||||
config,
|
|
||||||
&["--print=target-spec-json", "-Zunstable-options", "--target", target],
|
|
||||||
);
|
|
||||||
match serde_json::from_str(&json) {
|
|
||||||
Ok(res) => res,
|
|
||||||
Err(err) => panic!("failed to parse target spec for {target}: {err}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rustc_output(config: &Config, args: &[&str]) -> String {
|
fn rustc_output(config: &Config, args: &[&str]) -> String {
|
||||||
let mut command = Command::new(&config.rustc_path);
|
let mut command = Command::new(&config.rustc_path);
|
||||||
add_dylib_path(&mut command, iter::once(&config.compile_lib_path));
|
add_dylib_path(&mut command, iter::once(&config.compile_lib_path));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue