Skip to content

Commit d799f2d

Browse files
authored
Rollup merge of #69381 - QuiltOS:no-std-from-config, r=Mark-Simulacrum
Allow getting `no_std` from the config file Currently, it is only set correctly in the sanity checking implicit default fallback code. Having a config file at all will for force `no_std = false`.
2 parents e028f26 + 4f15867 commit d799f2d

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/bootstrap/config.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ pub struct Target {
177177
pub no_std: bool,
178178
}
179179

180+
impl Target {
181+
pub fn from_triple(triple: &str) -> Self {
182+
let mut target: Self = Default::default();
183+
if triple.contains("-none-") || triple.contains("nvptx") {
184+
target.no_std = true;
185+
}
186+
target
187+
}
188+
}
180189
/// Structure of the `config.toml` file that configuration is read from.
181190
///
182191
/// This structure uses `Decodable` to automatically decode a TOML configuration
@@ -353,6 +362,7 @@ struct TomlTarget {
353362
musl_root: Option<String>,
354363
wasi_root: Option<String>,
355364
qemu_rootfs: Option<String>,
365+
no_std: Option<bool>,
356366
}
357367

358368
impl Config {
@@ -595,7 +605,7 @@ impl Config {
595605

596606
if let Some(ref t) = toml.target {
597607
for (triple, cfg) in t {
598-
let mut target = Target::default();
608+
let mut target = Target::from_triple(triple);
599609

600610
if let Some(ref s) = cfg.llvm_config {
601611
target.llvm_config = Some(config.src.join(s));
@@ -606,6 +616,9 @@ impl Config {
606616
if let Some(ref s) = cfg.android_ndk {
607617
target.ndk = Some(config.src.join(s));
608618
}
619+
if let Some(s) = cfg.no_std {
620+
target.no_std = s;
621+
}
609622
target.cc = cfg.cc.clone().map(PathBuf::from);
610623
target.cxx = cfg.cxx.clone().map(PathBuf::from);
611624
target.ar = cfg.ar.clone().map(PathBuf::from);

src/bootstrap/sanity.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::process::Command;
1717

1818
use build_helper::{output, t};
1919

20+
use crate::config::Target;
2021
use crate::Build;
2122

2223
struct Finder {
@@ -192,13 +193,9 @@ pub fn check(build: &mut Build) {
192193
panic!("the iOS target is only supported on macOS");
193194
}
194195

195-
if target.contains("-none-") || target.contains("nvptx") {
196-
if build.no_std(*target).is_none() {
197-
let target = build.config.target_config.entry(target.clone()).or_default();
198-
199-
target.no_std = true;
200-
}
196+
build.config.target_config.entry(target.clone()).or_insert(Target::from_triple(target));
201197

198+
if target.contains("-none-") || target.contains("nvptx") {
202199
if build.no_std(*target) == Some(false) {
203200
panic!("All the *-none-* and nvptx* targets are no-std targets")
204201
}

0 commit comments

Comments
 (0)