Skip to content

Commit de96f3d

Browse files
committed
Auto merge of rust-lang#110478 - jyn514:stage1-fulldeps, r=albertlarsan68
Support `x test --stage 1 ui-fulldeps` `@Nilstrieb` had an excellent idea the other day: the same way that rustdoc is able to load `rustc_driver` from the sysroot, ui-fulldeps tests should also be able to load it from the sysroot. That allows us to run fulldeps tests with stage1, without having to fully rebuild the compiler twice. It does unfortunately have the downside that we're building the tests with the *bootstrap* compiler, not the in-tree sources, but since most of the fulldeps tests are for the *API* of the compiler, that seems ok. I think it's possible to extend this to `run-make-fulldeps`, but I've run out of energy for tonight. - Move `plugin` tests into a subdirectory. Plugins are loaded at runtime with `dlopen` and so require the ABI of the running compile to match the ABI of the compiler linked with `rustc_driver`. As a result they can't be supported in stage 1 and have to use `// ignore-stage1`. - Remove `ignore-stage1` from most non-plugin tests - Ignore diagnostic tests in stage 1. Even though this requires a stage 2 build to load rustc_driver, it's primarily testing the error message that the *running* compiler emits when the diagnostic struct is malformed. - Pass `-Zforce-unstable-if-unmarked` in stage1, not just stage2. That allows running `hash-stable-is-unstable` in stage1, since it now suggests adding `rustc_private` to enable loading the crates. - Add libLLVM.so to the stage0 target sysroot, to allow fulldeps tests that act as custom drivers to load it at runtime. - Pass `--sysroot stage0-sysroot` in compiletest so that we use the correct version of std. - Move a few lint tests from ui-fulldeps to ui These had an `aux-build:lint-group-plugin-test.rs` that they never actually loaded with `feature(plugin)` nor tested. I removed the unused aux-build and they pass fine with stage 1. Fixes rust-lang#75905.
2 parents 5fe3528 + d6af602 commit de96f3d

File tree

72 files changed

+236
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+236
-204
lines changed

src/bootstrap/bin/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn main() {
150150
// allow the `rustc_private` feature to link to other unstable crates
151151
// also in the sysroot. We also do this for host crates, since those
152152
// may be proc macros, in which case we might ship them.
153-
if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() && (stage != "0" || target.is_some()) {
153+
if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
154154
cmd.arg("-Z").arg("force-unstable-if-unmarked");
155155
}
156156

src/bootstrap/builder.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,24 @@ impl<'a> Builder<'a> {
10081008
// Avoid deleting the rustlib/ directory we just copied
10091009
// (in `impl Step for Sysroot`).
10101010
if !builder.download_rustc() {
1011+
builder.verbose(&format!(
1012+
"Removing sysroot {} to avoid caching bugs",
1013+
sysroot.display()
1014+
));
10111015
let _ = fs::remove_dir_all(&sysroot);
10121016
t!(fs::create_dir_all(&sysroot));
10131017
}
1018+
1019+
if self.compiler.stage == 0 {
1020+
// The stage 0 compiler for the build triple is always pre-built.
1021+
// Ensure that `libLLVM.so` ends up in the target libdir, so that ui-fulldeps tests can use it when run.
1022+
dist::maybe_install_llvm_target(
1023+
builder,
1024+
self.compiler.host,
1025+
&builder.sysroot(self.compiler),
1026+
);
1027+
}
1028+
10141029
INTERNER.intern_path(sysroot)
10151030
}
10161031
}

src/bootstrap/compile.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,7 @@ impl Step for Sysroot {
12601260
};
12611261
let sysroot = sysroot_dir(compiler.stage);
12621262

1263+
builder.verbose(&format!("Removing sysroot {} to avoid caching bugs", sysroot.display()));
12631264
let _ = fs::remove_dir_all(&sysroot);
12641265
t!(fs::create_dir_all(&sysroot));
12651266

src/bootstrap/test.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
14481448
crate::detail_exit(1);
14491449
}
14501450

1451-
let compiler = self.compiler;
1451+
let mut compiler = self.compiler;
14521452
let target = self.target;
14531453
let mode = self.mode;
14541454
let suite = self.suite;
@@ -1461,15 +1461,28 @@ note: if you're sure you want to do this, please open an issue as to why. In the
14611461
return;
14621462
}
14631463

1464-
if suite == "debuginfo" {
1465-
builder
1466-
.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
1467-
}
1464+
// Support stage 1 ui-fulldeps. This is somewhat complicated: ui-fulldeps tests for the most
1465+
// part test the *API* of the compiler, not how it compiles a given file. As a result, we
1466+
// can run them against the stage 1 sources as long as we build them with the stage 0
1467+
// bootstrap compiler.
1468+
// NOTE: Only stage 1 is special cased because we need the rustc_private artifacts to match the
1469+
// running compiler in stage 2 when plugins run.
1470+
let stage_id = if suite == "ui-fulldeps" && compiler.stage == 1 {
1471+
compiler = builder.compiler(compiler.stage - 1, target);
1472+
format!("stage{}-{}", compiler.stage + 1, target)
1473+
} else {
1474+
format!("stage{}-{}", compiler.stage, target)
1475+
};
14681476

14691477
if suite.ends_with("fulldeps") {
14701478
builder.ensure(compile::Rustc::new(compiler, target));
14711479
}
14721480

1481+
if suite == "debuginfo" {
1482+
builder
1483+
.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
1484+
}
1485+
14731486
builder.ensure(compile::Std::new(compiler, target));
14741487
// ensure that `libproc_macro` is available on the host.
14751488
builder.ensure(compile::Std::new(compiler, compiler.host));
@@ -1528,7 +1541,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15281541
cmd.arg("--src-base").arg(builder.src.join("tests").join(suite));
15291542
cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
15301543
cmd.arg("--sysroot-base").arg(builder.sysroot(compiler));
1531-
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
1544+
cmd.arg("--stage-id").arg(stage_id);
15321545
cmd.arg("--suite").arg(suite);
15331546
cmd.arg("--mode").arg(mode);
15341547
cmd.arg("--target").arg(target.rustc_target_arg());

src/tools/compiletest/src/common.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ pub struct TargetCfgs {
422422

423423
impl TargetCfgs {
424424
fn new(config: &Config) -> TargetCfgs {
425-
let targets: HashMap<String, TargetCfg> = if config.stage_id.starts_with("stage0-") {
425+
let targets: HashMap<String, TargetCfg> = if config.stage_id.starts_with("stage0-")
426+
|| (config.suite == "ui-fulldeps" && config.stage_id.starts_with("stage1-"))
427+
{
426428
// #[cfg(bootstrap)]
427429
// Needed only for one cycle, remove during the bootstrap bump.
428430
Self::collect_all_slow(config)

src/tools/compiletest/src/runtest.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,9 @@ impl<'test> TestCx<'test> {
19001900
// Use a single thread for efficiency and a deterministic error message order
19011901
rustc.arg("-Zthreads=1");
19021902

1903+
// In stage 0, make sure we use `stage0-sysroot` instead of the bootstrap sysroot.
1904+
rustc.arg("--sysroot").arg(&self.config.sysroot_base);
1905+
19031906
// Optionally prevent default --target if specified in test compile-flags.
19041907
let custom_target = self.props.compile_flags.iter().any(|x| x.starts_with("--target"));
19051908

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
99

1010
// FIXME: The following limits should be reduced eventually.
1111
const ENTRY_LIMIT: usize = 885;
12-
const ROOT_ENTRY_LIMIT: usize = 891;
12+
const ROOT_ENTRY_LIMIT: usize = 894;
1313
const ISSUES_ENTRY_LIMIT: usize = 1977;
1414

1515
fn check_entries(tests_path: &Path, bad: &mut bool) {

tests/ui-fulldeps/compiler-calls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Test that the Callbacks interface to the compiler works.
33

44
// ignore-cross-compile
5-
// ignore-stage1
65
// ignore-remote
76

87
#![feature(rustc_private)]

tests/ui-fulldeps/hash-stable-is-unstable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-stage1
21
// compile-flags: -Zdeduplicate-diagnostics=yes
32
extern crate rustc_data_structures;
43
//~^ use of unstable library feature 'rustc_private'

tests/ui-fulldeps/hash-stable-is-unstable.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
2-
--> $DIR/hash-stable-is-unstable.rs:3:1
2+
--> $DIR/hash-stable-is-unstable.rs:2:1
33
|
44
LL | extern crate rustc_data_structures;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | extern crate rustc_data_structures;
88
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
99

1010
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
11-
--> $DIR/hash-stable-is-unstable.rs:5:1
11+
--> $DIR/hash-stable-is-unstable.rs:4:1
1212
|
1313
LL | extern crate rustc_macros;
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -17,7 +17,7 @@ LL | extern crate rustc_macros;
1717
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
1818

1919
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
20-
--> $DIR/hash-stable-is-unstable.rs:7:1
20+
--> $DIR/hash-stable-is-unstable.rs:6:1
2121
|
2222
LL | extern crate rustc_query_system;
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -26,7 +26,7 @@ LL | extern crate rustc_query_system;
2626
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
2727

2828
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
29-
--> $DIR/hash-stable-is-unstable.rs:10:5
29+
--> $DIR/hash-stable-is-unstable.rs:9:5
3030
|
3131
LL | use rustc_macros::HashStable;
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -35,7 +35,7 @@ LL | use rustc_macros::HashStable;
3535
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
3636

3737
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
38-
--> $DIR/hash-stable-is-unstable.rs:13:10
38+
--> $DIR/hash-stable-is-unstable.rs:12:10
3939
|
4040
LL | #[derive(HashStable)]
4141
| ^^^^^^^^^^

tests/ui-fulldeps/pathless-extern-unstable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-stage1
21
// edition:2018
32
// compile-flags:--extern rustc_middle
43

tests/ui-fulldeps/pathless-extern-unstable.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
2-
--> $DIR/pathless-extern-unstable.rs:7:9
2+
--> $DIR/pathless-extern-unstable.rs:6:9
33
|
44
LL | pub use rustc_middle;
55
| ^^^^^^^^^^^^
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/ui-fulldeps/macro-crate-rlib.rs tests/ui-fulldeps/plugin/macro-crate-rlib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// aux-build:rlib-crate-test.rs
2+
// ignore-stage1
23
// ignore-cross-compile gives a different error message
34

45
#![feature(plugin)]

tests/ui-fulldeps/macro-crate-rlib.stderr tests/ui-fulldeps/plugin/macro-crate-rlib.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0457]: plugin `rlib_crate_test` only found in rlib format, but must be available in dylib format
2-
--> $DIR/macro-crate-rlib.rs:5:11
2+
--> $DIR/macro-crate-rlib.rs:6:11
33
|
44
LL | #![plugin(rlib_crate_test)]
55
| ^^^^^^^^^^^^^^^
File renamed without changes.

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
77
// changing the output of this test. Since Diagnostic is strictly internal to the compiler
88
// the test is just ignored on stable and beta:
9+
// ignore-stage1
910
// ignore-beta
1011
// ignore-stable
1112

0 commit comments

Comments
 (0)