Skip to content

Commit ea88adc

Browse files
authored
Rollup merge of rust-lang#63637 - alexcrichton:remove-libtest-step, r=Mark-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.
2 parents 5ae0710 + 72470e3 commit ea88adc

File tree

18 files changed

+159
-496
lines changed

18 files changed

+159
-496
lines changed

Diff for: Cargo.lock

+29-4
Original file line numberDiff line numberDiff line change
@@ -1138,10 +1138,12 @@ dependencies = [
11381138

11391139
[[package]]
11401140
name = "getopts"
1141-
version = "0.2.19"
1141+
version = "0.2.21"
11421142
source = "registry+https://github.com/rust-lang/crates.io-index"
1143-
checksum = "72327b15c228bfe31f1390f93dd5e9279587f0463836393c9df719ce62a3e450"
1143+
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
11441144
dependencies = [
1145+
"rustc-std-workspace-core",
1146+
"rustc-std-workspace-std",
11451147
"unicode-width",
11461148
]
11471149

@@ -2364,6 +2366,9 @@ dependencies = [
23642366
[[package]]
23652367
name = "proc_macro"
23662368
version = "0.0.0"
2369+
dependencies = [
2370+
"std",
2371+
]
23672372

23682373
[[package]]
23692374
name = "profiler_builtins"
@@ -3052,6 +3057,13 @@ dependencies = [
30523057
"core",
30533058
]
30543059

3060+
[[package]]
3061+
name = "rustc-std-workspace-std"
3062+
version = "1.0.0"
3063+
dependencies = [
3064+
"std",
3065+
]
3066+
30553067
[[package]]
30563068
name = "rustc-workspace-hack"
30573069
version = "1.0.0"
@@ -4039,6 +4051,10 @@ dependencies = [
40394051
[[package]]
40404052
name = "term"
40414053
version = "0.0.0"
4054+
dependencies = [
4055+
"core",
4056+
"std",
4057+
]
40424058

40434059
[[package]]
40444060
name = "term"
@@ -4085,8 +4101,12 @@ dependencies = [
40854101
name = "test"
40864102
version = "0.0.0"
40874103
dependencies = [
4104+
"core",
40884105
"getopts",
4106+
"libc",
4107+
"panic_unwind",
40894108
"proc_macro",
4109+
"std",
40904110
"term 0.0.0",
40914111
]
40924112

@@ -4463,9 +4483,14 @@ checksum = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"
44634483

44644484
[[package]]
44654485
name = "unicode-width"
4466-
version = "0.1.5"
4486+
version = "0.1.6"
44674487
source = "registry+https://github.com/rust-lang/crates.io-index"
4468-
checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
4488+
checksum = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20"
4489+
dependencies = [
4490+
"compiler_builtins",
4491+
"rustc-std-workspace-core",
4492+
"rustc-std-workspace-std",
4493+
]
44694494

44704495
[[package]]
44714496
name = "unicode-xid"

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
6868
# here
6969
rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
7070
rustc-std-workspace-alloc = { path = 'src/tools/rustc-std-workspace-alloc' }
71+
rustc-std-workspace-std = { path = 'src/tools/rustc-std-workspace-std' }
7172

7273
[patch."https://github.com/rust-lang/rust-clippy"]
7374
clippy_lints = { path = "src/tools/clippy/clippy_lints" }

Diff for: src/bootstrap/builder.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ impl<'a> Builder<'a> {
337337
match kind {
338338
Kind::Build => describe!(
339339
compile::Std,
340-
compile::Test,
341340
compile::Rustc,
342341
compile::CodegenBackend,
343342
compile::StartupObjects,
@@ -363,7 +362,6 @@ impl<'a> Builder<'a> {
363362
),
364363
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
365364
check::Std,
366-
check::Test,
367365
check::Rustc,
368366
check::CodegenBackend,
369367
check::Rustdoc
@@ -425,8 +423,6 @@ impl<'a> Builder<'a> {
425423
doc::TheBook,
426424
doc::Standalone,
427425
doc::Std,
428-
doc::Test,
429-
doc::WhitelistedRustc,
430426
doc::Rustc,
431427
doc::Rustdoc,
432428
doc::ErrorIndex,
@@ -795,7 +791,7 @@ impl<'a> Builder<'a> {
795791
}
796792

797793
match mode {
798-
Mode::Std | Mode::Test | Mode::ToolBootstrap | Mode::ToolStd | Mode::ToolTest=> {},
794+
Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {},
799795
Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {
800796
// Build proc macros both for the host and the target
801797
if target != compiler.host && cmd != "check" {
@@ -846,7 +842,6 @@ impl<'a> Builder<'a> {
846842
// things still build right, please do!
847843
match mode {
848844
Mode::Std => metadata.push_str("std"),
849-
Mode::Test => metadata.push_str("test"),
850845
_ => {},
851846
}
852847
cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata);
@@ -943,9 +938,9 @@ impl<'a> Builder<'a> {
943938

944939
let debuginfo_level = match mode {
945940
Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc,
946-
Mode::Std | Mode::Test => self.config.rust_debuginfo_level_std,
941+
Mode::Std => self.config.rust_debuginfo_level_std,
947942
Mode::ToolBootstrap | Mode::ToolStd |
948-
Mode::ToolTest | Mode::ToolRustc => self.config.rust_debuginfo_level_tools,
943+
Mode::ToolRustc => self.config.rust_debuginfo_level_tools,
949944
};
950945
cargo.env("RUSTC_DEBUGINFO_LEVEL", debuginfo_level.to_string());
951946

@@ -1145,7 +1140,6 @@ impl<'a> Builder<'a> {
11451140

11461141
match (mode, self.config.rust_codegen_units_std, self.config.rust_codegen_units) {
11471142
(Mode::Std, Some(n), _) |
1148-
(Mode::Test, Some(n), _) |
11491143
(_, _, Some(n)) => {
11501144
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
11511145
}

Diff for: src/bootstrap/builder/tests.rs

+64-89
Original file line numberDiff line numberDiff line change
@@ -365,27 +365,6 @@ fn dist_with_same_targets_and_hosts() {
365365
},
366366
]
367367
);
368-
assert_eq!(
369-
first(builder.cache.all::<compile::Test>()),
370-
&[
371-
compile::Test {
372-
compiler: Compiler { host: a, stage: 0 },
373-
target: a,
374-
},
375-
compile::Test {
376-
compiler: Compiler { host: a, stage: 1 },
377-
target: a,
378-
},
379-
compile::Test {
380-
compiler: Compiler { host: a, stage: 2 },
381-
target: a,
382-
},
383-
compile::Test {
384-
compiler: Compiler { host: a, stage: 1 },
385-
target: b,
386-
},
387-
]
388-
);
389368
assert_eq!(
390369
first(builder.cache.all::<compile::Assemble>()),
391370
&[
@@ -415,7 +394,47 @@ fn build_default() {
415394
let b = INTERNER.intern_str("B");
416395
let c = INTERNER.intern_str("C");
417396

418-
assert!(!builder.cache.all::<compile::Std>().is_empty());
397+
assert_eq!(
398+
first(builder.cache.all::<compile::Std>()),
399+
&[
400+
compile::Std {
401+
compiler: Compiler { host: a, stage: 0 },
402+
target: a,
403+
},
404+
compile::Std {
405+
compiler: Compiler { host: a, stage: 1 },
406+
target: a,
407+
},
408+
compile::Std {
409+
compiler: Compiler { host: a, stage: 2 },
410+
target: a,
411+
},
412+
compile::Std {
413+
compiler: Compiler { host: b, stage: 2 },
414+
target: a,
415+
},
416+
compile::Std {
417+
compiler: Compiler { host: a, stage: 1 },
418+
target: b,
419+
},
420+
compile::Std {
421+
compiler: Compiler { host: a, stage: 2 },
422+
target: b,
423+
},
424+
compile::Std {
425+
compiler: Compiler { host: b, stage: 2 },
426+
target: b,
427+
},
428+
compile::Std {
429+
compiler: Compiler { host: a, stage: 2 },
430+
target: c,
431+
},
432+
compile::Std {
433+
compiler: Compiler { host: b, stage: 2 },
434+
target: c,
435+
},
436+
]
437+
);
419438
assert!(!builder.cache.all::<compile::Assemble>().is_empty());
420439
assert_eq!(
421440
first(builder.cache.all::<compile::Rustc>()),
@@ -450,63 +469,61 @@ fn build_default() {
450469
},
451470
]
452471
);
472+
}
473+
474+
#[test]
475+
fn build_with_target_flag() {
476+
let mut config = configure(&["B"], &["C"]);
477+
config.skip_only_host_steps = true;
478+
let build = Build::new(config);
479+
let mut builder = Builder::new(&build);
480+
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
481+
482+
let a = INTERNER.intern_str("A");
483+
let b = INTERNER.intern_str("B");
484+
let c = INTERNER.intern_str("C");
453485

454486
assert_eq!(
455-
first(builder.cache.all::<compile::Test>()),
487+
first(builder.cache.all::<compile::Std>()),
456488
&[
457-
compile::Test {
489+
compile::Std {
458490
compiler: Compiler { host: a, stage: 0 },
459491
target: a,
460492
},
461-
compile::Test {
493+
compile::Std {
462494
compiler: Compiler { host: a, stage: 1 },
463495
target: a,
464496
},
465-
compile::Test {
497+
compile::Std {
466498
compiler: Compiler { host: a, stage: 2 },
467499
target: a,
468500
},
469-
compile::Test {
501+
compile::Std {
470502
compiler: Compiler { host: b, stage: 2 },
471503
target: a,
472504
},
473-
compile::Test {
505+
compile::Std {
474506
compiler: Compiler { host: a, stage: 1 },
475507
target: b,
476508
},
477-
compile::Test {
509+
compile::Std {
478510
compiler: Compiler { host: a, stage: 2 },
479511
target: b,
480512
},
481-
compile::Test {
513+
compile::Std {
482514
compiler: Compiler { host: b, stage: 2 },
483515
target: b,
484516
},
485-
compile::Test {
517+
compile::Std {
486518
compiler: Compiler { host: a, stage: 2 },
487519
target: c,
488520
},
489-
compile::Test {
521+
compile::Std {
490522
compiler: Compiler { host: b, stage: 2 },
491523
target: c,
492524
},
493525
]
494526
);
495-
}
496-
497-
#[test]
498-
fn build_with_target_flag() {
499-
let mut config = configure(&["B"], &["C"]);
500-
config.skip_only_host_steps = true;
501-
let build = Build::new(config);
502-
let mut builder = Builder::new(&build);
503-
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
504-
505-
let a = INTERNER.intern_str("A");
506-
let b = INTERNER.intern_str("B");
507-
let c = INTERNER.intern_str("C");
508-
509-
assert!(!builder.cache.all::<compile::Std>().is_empty());
510527
assert_eq!(
511528
first(builder.cache.all::<compile::Assemble>()),
512529
&[
@@ -541,48 +558,6 @@ fn build_with_target_flag() {
541558
},
542559
]
543560
);
544-
545-
assert_eq!(
546-
first(builder.cache.all::<compile::Test>()),
547-
&[
548-
compile::Test {
549-
compiler: Compiler { host: a, stage: 0 },
550-
target: a,
551-
},
552-
compile::Test {
553-
compiler: Compiler { host: a, stage: 1 },
554-
target: a,
555-
},
556-
compile::Test {
557-
compiler: Compiler { host: a, stage: 2 },
558-
target: a,
559-
},
560-
compile::Test {
561-
compiler: Compiler { host: b, stage: 2 },
562-
target: a,
563-
},
564-
compile::Test {
565-
compiler: Compiler { host: a, stage: 1 },
566-
target: b,
567-
},
568-
compile::Test {
569-
compiler: Compiler { host: a, stage: 2 },
570-
target: b,
571-
},
572-
compile::Test {
573-
compiler: Compiler { host: b, stage: 2 },
574-
target: b,
575-
},
576-
compile::Test {
577-
compiler: Compiler { host: a, stage: 2 },
578-
target: c,
579-
},
580-
compile::Test {
581-
compiler: Compiler { host: b, stage: 2 },
582-
target: c,
583-
},
584-
]
585-
);
586561
}
587562

588563
#[test]

0 commit comments

Comments
 (0)