Skip to content

Commit

Permalink
Auto merge of rust-lang#63637 - alexcrichton:remove-libtest-step, r=M…
Browse files Browse the repository at this point in the history
…ark-Simulacrum

bootstrap: Merge the libtest build step with libstd

Since its inception rustbuild has always worked in three stages: one for
libstd, one for libtest, and one for rustc. These three stages were
architected around crates.io dependencies, where rustc wants to depend
on crates.io crates but said crates don't explicitly depend on libstd,
requiring a sysroot assembly step in the middle. This same logic was
applied for libtest where libtest wants to depend on crates.io crates
(`getopts`) but `getopts` didn't say that it depended on std, so it
needed `std` built ahead of time.

Lots of time has passed since the inception of rustbuild, however,
and we've since gotten to the point where even `std` itself is depending
on crates.io crates (albeit with some wonky configuration). This
commit applies the same logic to the two dependencies that the `test`
crate pulls in from crates.io, `getopts` and `unicode-width`. Over the
many years since rustbuild's inception `unicode-width` was the only
dependency picked up by the `test` crate, so the extra configuration
necessary to get crates building in this crate graph is unlikely to be
too much of a burden on developers.

After this patch it means that there are now only two build phasese of
rustbuild, one for libstd and one for rustc. The libtest/libproc_macro
build phase is all lumped into one now with `std`.

This was originally motivated by rust-lang/cargo#7216 where Cargo was
having to deal with synthesizing dependency edges but this commit makes
them explicit in this repository.
  • Loading branch information
bors committed Aug 24, 2019
2 parents c2f3174 + b47c969 commit 4784645
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 497 deletions.
34 changes: 30 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1139,10 +1139,12 @@ dependencies = [

[[package]]
name = "getopts"
version = "0.2.19"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72327b15c228bfe31f1390f93dd5e9279587f0463836393c9df719ce62a3e450"
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"rustc-std-workspace-core",
"rustc-std-workspace-std",
"unicode-width",
]

Expand Down Expand Up @@ -2375,6 +2377,9 @@ dependencies = [
[[package]]
name = "proc_macro"
version = "0.0.0"
dependencies = [
"std",
]

[[package]]
name = "profiler_builtins"
Expand Down Expand Up @@ -3063,6 +3068,13 @@ dependencies = [
"core",
]

[[package]]
name = "rustc-std-workspace-std"
version = "1.0.0"
dependencies = [
"std",
]

[[package]]
name = "rustc-workspace-hack"
version = "1.0.0"
Expand Down Expand Up @@ -4068,6 +4080,10 @@ dependencies = [
[[package]]
name = "term"
version = "0.0.0"
dependencies = [
"core",
"std",
]

[[package]]
name = "term"
Expand Down Expand Up @@ -4114,8 +4130,13 @@ dependencies = [
name = "test"
version = "0.0.0"
dependencies = [
"core",
"getopts",
"libc",
"panic_abort",
"panic_unwind",
"proc_macro",
"std",
"term 0.0.0",
]

Expand Down Expand Up @@ -4483,9 +4504,14 @@ checksum = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"

[[package]]
name = "unicode-width"
version = "0.1.5"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
checksum = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
"rustc-std-workspace-std",
]

[[package]]
name = "unicode-xid"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
# here
rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'src/tools/rustc-std-workspace-alloc' }
rustc-std-workspace-std = { path = 'src/tools/rustc-std-workspace-std' }

[patch."https://github.com/rust-lang/rust-clippy"]
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
12 changes: 3 additions & 9 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ impl<'a> Builder<'a> {
match kind {
Kind::Build => describe!(
compile::Std,
compile::Test,
compile::Rustc,
compile::CodegenBackend,
compile::StartupObjects,
Expand All @@ -363,7 +362,6 @@ impl<'a> Builder<'a> {
),
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
check::Std,
check::Test,
check::Rustc,
check::CodegenBackend,
check::Rustdoc
Expand Down Expand Up @@ -425,8 +423,6 @@ impl<'a> Builder<'a> {
doc::TheBook,
doc::Standalone,
doc::Std,
doc::Test,
doc::WhitelistedRustc,
doc::Rustc,
doc::Rustdoc,
doc::ErrorIndex,
Expand Down Expand Up @@ -801,7 +797,7 @@ impl<'a> Builder<'a> {
}

match mode {
Mode::Std | Mode::Test | Mode::ToolBootstrap | Mode::ToolStd | Mode::ToolTest=> {},
Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {},
Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {
// Build proc macros both for the host and the target
if target != compiler.host && cmd != "check" {
Expand Down Expand Up @@ -852,7 +848,6 @@ impl<'a> Builder<'a> {
// things still build right, please do!
match mode {
Mode::Std => metadata.push_str("std"),
Mode::Test => metadata.push_str("test"),
_ => {},
}
cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata);
Expand Down Expand Up @@ -948,9 +943,9 @@ impl<'a> Builder<'a> {

let debuginfo_level = match mode {
Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc,
Mode::Std | Mode::Test => self.config.rust_debuginfo_level_std,
Mode::Std => self.config.rust_debuginfo_level_std,
Mode::ToolBootstrap | Mode::ToolStd |
Mode::ToolTest | Mode::ToolRustc => self.config.rust_debuginfo_level_tools,
Mode::ToolRustc => self.config.rust_debuginfo_level_tools,
};
cargo.env("RUSTC_DEBUGINFO_LEVEL", debuginfo_level.to_string());

Expand Down Expand Up @@ -1150,7 +1145,6 @@ impl<'a> Builder<'a> {

match (mode, self.config.rust_codegen_units_std, self.config.rust_codegen_units) {
(Mode::Std, Some(n), _) |
(Mode::Test, Some(n), _) |
(_, _, Some(n)) => {
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
}
Expand Down
153 changes: 64 additions & 89 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,27 +365,6 @@ fn dist_with_same_targets_and_hosts() {
},
]
);
assert_eq!(
first(builder.cache.all::<compile::Test>()),
&[
compile::Test {
compiler: Compiler { host: a, stage: 0 },
target: a,
},
compile::Test {
compiler: Compiler { host: a, stage: 1 },
target: a,
},
compile::Test {
compiler: Compiler { host: a, stage: 2 },
target: a,
},
compile::Test {
compiler: Compiler { host: a, stage: 1 },
target: b,
},
]
);
assert_eq!(
first(builder.cache.all::<compile::Assemble>()),
&[
Expand Down Expand Up @@ -415,7 +394,47 @@ fn build_default() {
let b = INTERNER.intern_str("B");
let c = INTERNER.intern_str("C");

assert!(!builder.cache.all::<compile::Std>().is_empty());
assert_eq!(
first(builder.cache.all::<compile::Std>()),
&[
compile::Std {
compiler: Compiler { host: a, stage: 0 },
target: a,
},
compile::Std {
compiler: Compiler { host: a, stage: 1 },
target: a,
},
compile::Std {
compiler: Compiler { host: a, stage: 2 },
target: a,
},
compile::Std {
compiler: Compiler { host: b, stage: 2 },
target: a,
},
compile::Std {
compiler: Compiler { host: a, stage: 1 },
target: b,
},
compile::Std {
compiler: Compiler { host: a, stage: 2 },
target: b,
},
compile::Std {
compiler: Compiler { host: b, stage: 2 },
target: b,
},
compile::Std {
compiler: Compiler { host: a, stage: 2 },
target: c,
},
compile::Std {
compiler: Compiler { host: b, stage: 2 },
target: c,
},
]
);
assert!(!builder.cache.all::<compile::Assemble>().is_empty());
assert_eq!(
first(builder.cache.all::<compile::Rustc>()),
Expand Down Expand Up @@ -450,63 +469,61 @@ fn build_default() {
},
]
);
}

#[test]
fn build_with_target_flag() {
let mut config = configure(&["B"], &["C"]);
config.skip_only_host_steps = true;
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);

let a = INTERNER.intern_str("A");
let b = INTERNER.intern_str("B");
let c = INTERNER.intern_str("C");

assert_eq!(
first(builder.cache.all::<compile::Test>()),
first(builder.cache.all::<compile::Std>()),
&[
compile::Test {
compile::Std {
compiler: Compiler { host: a, stage: 0 },
target: a,
},
compile::Test {
compile::Std {
compiler: Compiler { host: a, stage: 1 },
target: a,
},
compile::Test {
compile::Std {
compiler: Compiler { host: a, stage: 2 },
target: a,
},
compile::Test {
compile::Std {
compiler: Compiler { host: b, stage: 2 },
target: a,
},
compile::Test {
compile::Std {
compiler: Compiler { host: a, stage: 1 },
target: b,
},
compile::Test {
compile::Std {
compiler: Compiler { host: a, stage: 2 },
target: b,
},
compile::Test {
compile::Std {
compiler: Compiler { host: b, stage: 2 },
target: b,
},
compile::Test {
compile::Std {
compiler: Compiler { host: a, stage: 2 },
target: c,
},
compile::Test {
compile::Std {
compiler: Compiler { host: b, stage: 2 },
target: c,
},
]
);
}

#[test]
fn build_with_target_flag() {
let mut config = configure(&["B"], &["C"]);
config.skip_only_host_steps = true;
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);

let a = INTERNER.intern_str("A");
let b = INTERNER.intern_str("B");
let c = INTERNER.intern_str("C");

assert!(!builder.cache.all::<compile::Std>().is_empty());
assert_eq!(
first(builder.cache.all::<compile::Assemble>()),
&[
Expand Down Expand Up @@ -541,48 +558,6 @@ fn build_with_target_flag() {
},
]
);

assert_eq!(
first(builder.cache.all::<compile::Test>()),
&[
compile::Test {
compiler: Compiler { host: a, stage: 0 },
target: a,
},
compile::Test {
compiler: Compiler { host: a, stage: 1 },
target: a,
},
compile::Test {
compiler: Compiler { host: a, stage: 2 },
target: a,
},
compile::Test {
compiler: Compiler { host: b, stage: 2 },
target: a,
},
compile::Test {
compiler: Compiler { host: a, stage: 1 },
target: b,
},
compile::Test {
compiler: Compiler { host: a, stage: 2 },
target: b,
},
compile::Test {
compiler: Compiler { host: b, stage: 2 },
target: b,
},
compile::Test {
compiler: Compiler { host: a, stage: 2 },
target: c,
},
compile::Test {
compiler: Compiler { host: b, stage: 2 },
target: c,
},
]
);
}

#[test]
Expand Down
Loading

0 comments on commit 4784645

Please sign in to comment.