Skip to content

Commit 5290c6c

Browse files
Allow overriding build triple via flag.
We first check the configuration, then passed parameters (--build), then fall back to the auto-detection that bootstrap.py does. Fixes #39673.
1 parent 84d9a6e commit 5290c6c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/bootstrap/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ impl Config {
290290
config.docs = true;
291291
config.rust_rpath = true;
292292
config.rust_codegen_units = 1;
293-
config.build = flags.build;
294293
config.channel = "dev".to_string();
295294
config.codegen_tests = true;
296295
config.rust_dist_src = true;
@@ -319,6 +318,11 @@ impl Config {
319318

320319
let build = toml.build.clone().unwrap_or(Build::default());
321320
set(&mut config.build, build.build.clone().map(|x| INTERNER.intern_string(x)));
321+
set(&mut config.build, flags.build);
322+
if config.build.is_empty() {
323+
// set by bootstrap.py
324+
config.build = INTERNER.intern_str(&env::var("BUILD").unwrap());
325+
}
322326
config.hosts.push(config.build.clone());
323327
for host in build.host.iter() {
324328
let host = INTERNER.intern_str(host);

src/bootstrap/flags.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct Flags {
3333
pub on_fail: Option<String>,
3434
pub stage: Option<u32>,
3535
pub keep_stage: Option<u32>,
36-
pub build: Interned<String>,
36+
pub build: Option<Interned<String>>,
3737

3838
pub host: Vec<Interned<String>>,
3939
pub target: Vec<Interned<String>>,
@@ -327,9 +327,7 @@ Arguments:
327327
stage: stage,
328328
on_fail: matches.opt_str("on-fail"),
329329
keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()),
330-
build: INTERNER.intern_string(matches.opt_str("build").unwrap_or_else(|| {
331-
env::var("BUILD").unwrap()
332-
})),
330+
build: matches.opt_str("build").map(|s| INTERNER.intern_string(s)),
333331
host: split(matches.opt_strs("host"))
334332
.into_iter().map(|x| INTERNER.intern_string(x)).collect::<Vec<_>>(),
335333
target: split(matches.opt_strs("target"))

0 commit comments

Comments
 (0)