Skip to content

Commit 750aa85

Browse files
committed
rustbuild: Quickly dist cross-host compilers
This commit optimizes the compile time for creating tarballs of cross-host compilers and as a proof of concept adds two to the standard Travis matrix. Much of this commit is further refactoring and refining of the `step.rs` definitions along with the interpretation of `--target` and `--host` flags. This has gotten confusing enough that I've also added a small test suite to `src/bootstrap/step.rs` to ensure what we're doing works and doesn't regress. After this commit when you execute: ./x.py dist --host $MY_HOST --target $MY_HOST the build system will compile two compilers. The first is for the build platform and the second is for the host platform. This second compiler is then packaged up and placed into `build/dist` and is ready to go. With a fully cached LLVM and docker image I was able to create a cross-host compiler in around 20 minutes locally. Eventually we plan to add a whole litany of cross-host entries to the Travis matrix, but for now we're just adding a few before we eat up all the extra capacity. cc #38531
1 parent 254876e commit 750aa85

File tree

9 files changed

+493
-38
lines changed

9 files changed

+493
-38
lines changed

src/bootstrap/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ version = "0.0.0"
66
[lib]
77
name = "bootstrap"
88
path = "lib.rs"
9+
doctest = false
910

1011
[[bin]]
1112
name = "bootstrap"
1213
path = "bin/main.rs"
14+
test = false
1315

1416
[[bin]]
1517
name = "rustc"
1618
path = "bin/rustc.rs"
19+
test = false
1720

1821
[[bin]]
1922
name = "rustdoc"
2023
path = "bin/rustdoc.rs"
24+
test = false
2125

2226
[dependencies]
2327
build_helper = { path = "../build_helper" }

src/bootstrap/check.rs

+11
Original file line numberDiff line numberDiff line change
@@ -563,3 +563,14 @@ pub fn distcheck(build: &Build) {
563563
.arg("check")
564564
.current_dir(&dir));
565565
}
566+
567+
/// Test the build system itself
568+
pub fn bootstrap(build: &Build) {
569+
let mut cmd = Command::new(&build.cargo);
570+
cmd.arg("test")
571+
.current_dir(build.src.join("src/bootstrap"))
572+
.env("CARGO_TARGET_DIR", build.out.join("bootstrap"))
573+
.env("RUSTC", &build.rustc);
574+
cmd.arg("--").args(&build.flags.cmd.test_args());
575+
build.run(&mut cmd);
576+
}

src/bootstrap/dist.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,9 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
346346
}
347347

348348
/// Creates the `rust-src` installer component and the plain source tarball
349-
pub fn rust_src(build: &Build, host: &str) {
349+
pub fn rust_src(build: &Build) {
350350
println!("Dist src");
351351

352-
if host != build.config.build {
353-
println!("\tskipping, not a build host");
354-
return
355-
}
356-
357352
let plain_name = format!("rustc-{}-src", package_vers(build));
358353
let name = format!("rust-src-{}", package_vers(build));
359354
let image = tmpdir(build).join(format!("{}-image", name));

src/bootstrap/doc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ pub fn rustbook(build: &Build, target: &str, name: &str) {
5757
/// `STAMP` alongw ith providing the various header/footer HTML we've cutomized.
5858
///
5959
/// In the end, this is just a glorified wrapper around rustdoc!
60-
pub fn standalone(build: &Build, stage: u32, target: &str) {
61-
println!("Documenting stage{} standalone ({})", stage, target);
60+
pub fn standalone(build: &Build, target: &str) {
61+
println!("Documenting standalone ({})", target);
6262
let out = build.doc_out(target);
6363
t!(fs::create_dir_all(&out));
6464

65-
let compiler = Compiler::new(stage, &build.config.build);
65+
let compiler = Compiler::new(0, &build.config.build);
6666

6767
let favicon = build.src.join("src/doc/favicon.inc");
6868
let footer = build.src.join("src/doc/footer.inc");

0 commit comments

Comments
 (0)