Skip to content

Commit 302a08c

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 8045438 commit 302a08c

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
@@ -287,7 +287,6 @@ impl Config {
287287
config.docs = true;
288288
config.rust_rpath = true;
289289
config.rust_codegen_units = 1;
290-
config.build = flags.build;
291290
config.channel = "dev".to_string();
292291
config.codegen_tests = true;
293292
config.rust_dist_src = true;
@@ -316,6 +315,11 @@ impl Config {
316315

317316
let build = toml.build.clone().unwrap_or(Build::default());
318317
set(&mut config.build, build.build.clone().map(|x| INTERNER.intern_string(x)));
318+
set(&mut config.build, flags.build);
319+
if config.build.is_empty() {
320+
// set by bootstrap.py
321+
config.build = INTERNER.intern_str(&env::var("BUILD").unwrap());
322+
}
319323
config.hosts.push(config.build.clone());
320324
for host in build.host.iter() {
321325
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)