Skip to content

Commit bc84983

Browse files
committed
[wip] Add bootstrap-shim and package it on nightly
- Pass `dist bootstrap-shim` explicitly in CI This makes it possible to run `dist bootstrap` without also building bootstrap-shim, and more importantly works around a bug where currently two steps aren't allowed to have the same path. - Add `check::BootstrapShim` - [wip] start unifying parsing for Config and MinimalConfig
1 parent 9307bb2 commit bc84983

File tree

14 files changed

+627
-340
lines changed

14 files changed

+627
-340
lines changed

src/bootstrap/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ name = "bootstrap"
1414
path = "bin/main.rs"
1515
test = false
1616

17+
[[bin]]
18+
name = "bootstrap-shim"
19+
path = "bin/bootstrap-shim.rs"
20+
test = false
21+
1722
[[bin]]
1823
name = "rustc"
1924
path = "bin/rustc.rs"

src/bootstrap/bin/bootstrap-shim.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use std::{env, process::Command};
2+
3+
use bootstrap::{t, MinimalConfig};
4+
5+
#[path = "../../../src/tools/x/src/main.rs"]
6+
mod run_python;
7+
8+
fn main() {
9+
let args = env::args().skip(1).collect::<Vec<_>>();
10+
let mut opts = getopts::Options::new();
11+
opts.optopt("", "config", "TOML configuration file for build", "FILE");
12+
let matches = t!(opts.parse(args));
13+
14+
// If there are no untracked changes to bootstrap, download it from CI.
15+
// Otherwise, build it from source. Use python to build to avoid duplicating the code between python and rust.
16+
let config = MinimalConfig::parse(t!(matches.opt_get("config")));
17+
let bootstrap_bin = if let Some(commit) = last_modified_bootstrap_commit(&config) {
18+
config.download_bootstrap(&commit)
19+
} else {
20+
return run_python::main();
21+
};
22+
23+
let args: Vec<_> = std::env::args().skip(1).collect();
24+
Command::new(bootstrap_bin).args(args).status().expect("failed to spawn bootstrap binairy");
25+
}
26+
27+
fn last_modified_bootstrap_commit(config: &MinimalConfig) -> Option<String> {
28+
config.last_modified_commit(&["src/bootstrap"], "download-bootstrap", true)
29+
}

src/bootstrap/builder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,8 @@ impl<'a> Builder<'a> {
656656
check::Rls,
657657
check::RustAnalyzer,
658658
check::Rustfmt,
659-
check::Bootstrap
659+
check::Bootstrap,
660+
check::BootstrapShim,
660661
),
661662
Kind::Test => describe!(
662663
crate::toolstate::ToolStateCheck,
@@ -761,6 +762,7 @@ impl<'a> Builder<'a> {
761762
dist::LlvmTools,
762763
dist::RustDev,
763764
dist::Bootstrap,
765+
dist::BootstrapShim,
764766
dist::Extended,
765767
// It seems that PlainSourceTarball somehow changes how some of the tools
766768
// perceive their dependencies (see #93033) which would invalidate fingerprints

src/bootstrap/check.rs

+2
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,9 @@ tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
473473
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
474474
tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree);
475475

476+
// FIXME: currently these are marked as ToolRustc, but they should be ToolBootstrap instead to avoid having to build the compiler first
476477
tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false);
478+
tool_check_step!(BootstrapShim, "src/bootstrap/bin/bootstrap-shim", SourceType::InTree, false);
477479

478480
/// Cargo's output path for the standard library in a given stage, compiled
479481
/// by a particular compiler for the specified target.

0 commit comments

Comments
 (0)