Skip to content

Commit

Permalink
[wip] Add bootstrap-shim and package it on nightly
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jyn514 committed Feb 2, 2023
1 parent 9307bb2 commit bc84983
Show file tree
Hide file tree
Showing 14 changed files with 627 additions and 340 deletions.
5 changes: 5 additions & 0 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ name = "bootstrap"
path = "bin/main.rs"
test = false

[[bin]]
name = "bootstrap-shim"
path = "bin/bootstrap-shim.rs"
test = false

[[bin]]
name = "rustc"
path = "bin/rustc.rs"
Expand Down
29 changes: 29 additions & 0 deletions src/bootstrap/bin/bootstrap-shim.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::{env, process::Command};

use bootstrap::{t, MinimalConfig};

#[path = "../../../src/tools/x/src/main.rs"]
mod run_python;

fn main() {
let args = env::args().skip(1).collect::<Vec<_>>();
let mut opts = getopts::Options::new();
opts.optopt("", "config", "TOML configuration file for build", "FILE");
let matches = t!(opts.parse(args));

// If there are no untracked changes to bootstrap, download it from CI.
// Otherwise, build it from source. Use python to build to avoid duplicating the code between python and rust.
let config = MinimalConfig::parse(t!(matches.opt_get("config")));
let bootstrap_bin = if let Some(commit) = last_modified_bootstrap_commit(&config) {
config.download_bootstrap(&commit)
} else {
return run_python::main();
};

let args: Vec<_> = std::env::args().skip(1).collect();
Command::new(bootstrap_bin).args(args).status().expect("failed to spawn bootstrap binairy");
}

fn last_modified_bootstrap_commit(config: &MinimalConfig) -> Option<String> {
config.last_modified_commit(&["src/bootstrap"], "download-bootstrap", true)
}
4 changes: 3 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,8 @@ impl<'a> Builder<'a> {
check::Rls,
check::RustAnalyzer,
check::Rustfmt,
check::Bootstrap
check::Bootstrap,
check::BootstrapShim,
),
Kind::Test => describe!(
crate::toolstate::ToolStateCheck,
Expand Down Expand Up @@ -761,6 +762,7 @@ impl<'a> Builder<'a> {
dist::LlvmTools,
dist::RustDev,
dist::Bootstrap,
dist::BootstrapShim,
dist::Extended,
// It seems that PlainSourceTarball somehow changes how some of the tools
// perceive their dependencies (see #93033) which would invalidate fingerprints
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree);

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

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

0 comments on commit bc84983

Please sign in to comment.