Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a608f0

Browse filesBrowse files
Rollup merge of #136472 - jieyouxu:pass-stage, r=Mark-Simulacrum
[`compiletest`-related cleanups 2/7] Feed stage number to compiletest directly Reference for overall changes: #136437 Part **2** of **7** of the *`compiletest`-related cleanups* PR series. ### Summary - Pass stage number via new `--stage` compiletest flag directly from bootstrap, instead of deriving that info in compiletest by doing gymnastics on `--stage-id`. - Just a cleanup, should have no functional changes. r? bootstrap
2 parents 6ef2cd8 + 8a0dc27 commit 2a608f0
Copy full SHA for 2a608f0

File tree

Expand file treeCollapse file tree

6 files changed

+41
-38
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+41
-38
lines changed

‎src/bootstrap/src/core/build_steps/test.rs

Copy file name to clipboardExpand all lines: src/bootstrap/src/core/build_steps/test.rs
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,16 +1648,17 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
16481648
// bootstrap compiler.
16491649
// NOTE: Only stage 1 is special cased because we need the rustc_private artifacts to match the
16501650
// running compiler in stage 2 when plugins run.
1651-
let stage_id = if suite == "ui-fulldeps" && compiler.stage == 1 {
1652-
// At stage 0 (stage - 1) we are using the beta compiler. Using `self.target` can lead finding
1653-
// an incorrect compiler path on cross-targets, as the stage 0 beta compiler is always equal
1654-
// to `build.build` in the configuration.
1651+
let (stage, stage_id) = if suite == "ui-fulldeps" && compiler.stage == 1 {
1652+
// At stage 0 (stage - 1) we are using the beta compiler. Using `self.target` can lead
1653+
// finding an incorrect compiler path on cross-targets, as the stage 0 beta compiler is
1654+
// always equal to `build.build` in the configuration.
16551655
let build = builder.build.build;
1656-
16571656
compiler = builder.compiler(compiler.stage - 1, build);
1658-
format!("stage{}-{}", compiler.stage + 1, build)
1657+
let test_stage = compiler.stage + 1;
1658+
(test_stage, format!("stage{}-{}", test_stage, build))
16591659
} else {
1660-
format!("stage{}-{}", compiler.stage, target)
1660+
let stage = compiler.stage;
1661+
(stage, format!("stage{}-{}", stage, target))
16611662
};
16621663

16631664
if suite.ends_with("fulldeps") {
@@ -1699,6 +1700,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
16991700
// compiletest currently has... a lot of arguments, so let's just pass all
17001701
// of them!
17011702

1703+
cmd.arg("--stage").arg(stage.to_string());
1704+
cmd.arg("--stage-id").arg(stage_id);
1705+
17021706
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
17031707
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(compiler, target));
17041708
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
@@ -1767,8 +1771,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17671771
} else {
17681772
builder.sysroot(compiler).to_path_buf()
17691773
};
1774+
17701775
cmd.arg("--sysroot-base").arg(sysroot);
1771-
cmd.arg("--stage-id").arg(stage_id);
1776+
17721777
cmd.arg("--suite").arg(suite);
17731778
cmd.arg("--mode").arg(mode);
17741779
cmd.arg("--target").arg(target.rustc_target_arg());

‎src/tools/compiletest/src/common.rs

Copy file name to clipboardExpand all lines: src/tools/compiletest/src/common.rs
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ pub struct Config {
224224
/// The directory containing the compiler sysroot
225225
pub sysroot_base: PathBuf,
226226

227-
/// The name of the stage being built (stage1, etc)
227+
/// The number of the stage under test.
228+
pub stage: u32,
229+
/// The id of the stage under test (stage1-xxx, etc).
228230
pub stage_id: String,
229231

230232
/// The test mode, e.g. ui or debuginfo.

‎src/tools/compiletest/src/header/cfg.rs

Copy file name to clipboardExpand all lines: src/tools/compiletest/src/header/cfg.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn parse_cfg_name_directive<'a>(
192192
message: "on big-endian targets",
193193
}
194194
condition! {
195-
name: config.stage_id.split('-').next().unwrap(),
195+
name: format!("stage{}", config.stage).as_str(),
196196
allowed_names: &["stage0", "stage1", "stage2"],
197197
message: "when the bootstrapping stage is {name}",
198198
}

‎src/tools/compiletest/src/header/tests.rs

Copy file name to clipboardExpand all lines: src/tools/compiletest/src/header/tests.rs
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct ConfigBuilder {
7272
channel: Option<String>,
7373
host: Option<String>,
7474
target: Option<String>,
75+
stage: Option<u32>,
7576
stage_id: Option<String>,
7677
llvm_version: Option<String>,
7778
git_hash: bool,
@@ -102,6 +103,11 @@ impl ConfigBuilder {
102103
self
103104
}
104105

106+
fn stage(&mut self, n: u32) -> &mut Self {
107+
self.stage = Some(n);
108+
self
109+
}
110+
105111
fn stage_id(&mut self, s: &str) -> &mut Self {
106112
self.stage_id = Some(s.to_owned());
107113
self
@@ -156,6 +162,8 @@ impl ConfigBuilder {
156162
"--cxxflags=",
157163
"--llvm-components=",
158164
"--android-cross-path=",
165+
"--stage",
166+
&self.stage.unwrap_or(2).to_string(),
159167
"--stage-id",
160168
self.stage_id.as_deref().unwrap_or("stage2-x86_64-unknown-linux-gnu"),
161169
"--channel",
@@ -388,7 +396,7 @@ fn std_debug_assertions() {
388396

389397
#[test]
390398
fn stage() {
391-
let config: Config = cfg().stage_id("stage1-x86_64-unknown-linux-gnu").build();
399+
let config: Config = cfg().stage(1).stage_id("stage1-x86_64-unknown-linux-gnu").build();
392400

393401
assert!(check_ignore(&config, "//@ ignore-stage1"));
394402
assert!(!check_ignore(&config, "//@ ignore-stage2"));

‎src/tools/compiletest/src/lib.rs

Copy file name to clipboardExpand all lines: src/tools/compiletest/src/lib.rs
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
6464
.reqopt("", "src-base", "directory to scan for test files", "PATH")
6565
.reqopt("", "build-base", "directory to deposit test outputs", "PATH")
6666
.reqopt("", "sysroot-base", "directory containing the compiler sysroot", "PATH")
67+
.reqopt("", "stage", "stage number under test", "N")
6768
.reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET")
6869
.reqopt(
6970
"",
@@ -294,6 +295,11 @@ pub fn parse_config(args: Vec<String>) -> Config {
294295
panic!("`--nocapture` is deprecated; please use `--no-capture`");
295296
}
296297

298+
let stage = match matches.opt_str("stage") {
299+
Some(stage) => stage.parse::<u32>().expect("expected `--stage` to be an unsigned integer"),
300+
None => panic!("`--stage` is required"),
301+
};
302+
297303
Config {
298304
bless: matches.opt_present("bless"),
299305
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
@@ -311,7 +317,10 @@ pub fn parse_config(args: Vec<String>) -> Config {
311317
src_base,
312318
build_base: opt_path(matches, "build-base"),
313319
sysroot_base: opt_path(matches, "sysroot-base"),
320+
321+
stage,
314322
stage_id: matches.opt_str("stage-id").unwrap(),
323+
315324
mode,
316325
suite: matches.opt_str("suite").unwrap(),
317326
debugger: matches.opt_str("debugger").map(|debugger| {
@@ -415,6 +424,7 @@ pub fn log_config(config: &Config) {
415424
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path));
416425
logv(c, format!("src_base: {:?}", config.src_base.display()));
417426
logv(c, format!("build_base: {:?}", config.build_base.display()));
427+
logv(c, format!("stage: {}", config.stage));
418428
logv(c, format!("stage_id: {}", config.stage_id));
419429
logv(c, format!("mode: {}", config.mode));
420430
logv(c, format!("run_ignored: {}", config.run_ignored));

‎src/tools/compiletest/src/runtest/run_make.rs

Copy file name to clipboardExpand all lines: src/tools/compiletest/src/runtest/run_make.rs
+5-27Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -239,30 +239,6 @@ impl TestCx<'_> {
239239
}
240240
}
241241

242-
// `self.config.stage_id` looks like `stage1-<target_triple>`, but we only want
243-
// the `stage1` part as that is what the output directories of bootstrap are prefixed with.
244-
// Note that this *assumes* build layout from bootstrap is produced as:
245-
//
246-
// ```
247-
// build/<target_triple>/ // <- this is `build_root`
248-
// ├── stage0
249-
// ├── stage0-bootstrap-tools
250-
// ├── stage0-codegen
251-
// ├── stage0-rustc
252-
// ├── stage0-std
253-
// ├── stage0-sysroot
254-
// ├── stage0-tools
255-
// ├── stage0-tools-bin
256-
// ├── stage1
257-
// ├── stage1-std
258-
// ├── stage1-tools
259-
// ├── stage1-tools-bin
260-
// └── test
261-
// ```
262-
// FIXME(jieyouxu): improve the communication between bootstrap and compiletest here so
263-
// we don't have to hack out a `stageN`.
264-
let stage = self.config.stage_id.split('-').next().unwrap();
265-
266242
// In order to link in the support library as a rlib when compiling recipes, we need three
267243
// paths:
268244
// 1. Path of the built support library rlib itself.
@@ -284,10 +260,12 @@ impl TestCx<'_> {
284260
// support lib and its deps are organized, can't we copy them to the tools-bin dir as
285261
// well?), but this seems to work for now.
286262

287-
let stage_tools_bin = build_root.join(format!("{stage}-tools-bin"));
263+
let stage_number = self.config.stage;
264+
265+
let stage_tools_bin = build_root.join(format!("stage{stage_number}-tools-bin"));
288266
let support_lib_path = stage_tools_bin.join("librun_make_support.rlib");
289267

290-
let stage_tools = build_root.join(format!("{stage}-tools"));
268+
let stage_tools = build_root.join(format!("stage{stage_number}-tools"));
291269
let support_lib_deps = stage_tools.join(&self.config.host).join("release").join("deps");
292270
let support_lib_deps_deps = stage_tools.join("release").join("deps");
293271

@@ -368,7 +346,7 @@ impl TestCx<'_> {
368346
// provided through env vars.
369347

370348
// Compute stage-specific standard library paths.
371-
let stage_std_path = build_root.join(&stage).join("lib");
349+
let stage_std_path = build_root.join(format!("stage{stage_number}")).join("lib");
372350

373351
// Compute dynamic library search paths for recipes.
374352
let recipe_dylib_search_paths = {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.