Skip to content

Commit ea813a0

Browse files
jyn514onur-ozkan
authored andcommitted
[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 3ea9ad5 commit ea813a0

File tree

16 files changed

+675
-366
lines changed

16 files changed

+675
-366
lines changed

src/bootstrap/Cargo.lock

+16
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dependencies = [
4949
"cmake",
5050
"fd-lock",
5151
"filetime",
52+
"getopts",
5253
"hex",
5354
"ignore",
5455
"is-terminal",
@@ -317,6 +318,15 @@ dependencies = [
317318
"version_check",
318319
]
319320

321+
[[package]]
322+
name = "getopts"
323+
version = "0.2.21"
324+
source = "registry+https://github.com/rust-lang/crates.io-index"
325+
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
326+
dependencies = [
327+
"unicode-width",
328+
]
329+
320330
[[package]]
321331
name = "globset"
322332
version = "0.4.8"
@@ -778,6 +788,12 @@ version = "1.0.0"
778788
source = "registry+https://github.com/rust-lang/crates.io-index"
779789
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
780790

791+
[[package]]
792+
name = "unicode-width"
793+
version = "0.1.10"
794+
source = "registry+https://github.com/rust-lang/crates.io-index"
795+
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
796+
781797
[[package]]
782798
name = "version_check"
783799
version = "0.9.4"

src/bootstrap/Cargo.toml

+6
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"
@@ -35,6 +40,7 @@ build_helper = { path = "../tools/build_helper" }
3540
cmake = "0.1.38"
3641
filetime = "0.2"
3742
cc = "1.0.69"
43+
getopts = "0.2"
3844
libc = "0.2"
3945
hex = "0.4"
4046
object = { version = "0.29.0", default-features = false, features = ["archive", "coff", "read_core", "unaligned"] }

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
@@ -703,7 +703,8 @@ impl<'a> Builder<'a> {
703703
check::Rls,
704704
check::RustAnalyzer,
705705
check::Rustfmt,
706-
check::Bootstrap
706+
check::Bootstrap,
707+
check::BootstrapShim,
707708
),
708709
Kind::Test => describe!(
709710
crate::toolstate::ToolStateCheck,
@@ -808,6 +809,7 @@ impl<'a> Builder<'a> {
808809
dist::LlvmTools,
809810
dist::RustDev,
810811
dist::Bootstrap,
812+
dist::BootstrapShim,
811813
dist::Extended,
812814
// It seems that PlainSourceTarball somehow changes how some of the tools
813815
// perceive their dependencies (see #93033) which would invalidate fingerprints

src/bootstrap/check.rs

+2
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
448448
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
449449
tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree);
450450

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

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

0 commit comments

Comments
 (0)