Skip to content

x test --stage 2 std uses the wrong stage when download-rustc is enabled #108768

Closed
@jyn514

Description

@jyn514

cc #81930

I tried this code:

./configure --set rust.download-rustc
x test --stage 2 library/core

I expected to see this happen: Bootstrap uses the stage 2 compiler to run the tests.

Instead, this happened: Bootstrap uses the stage 1 compiler:

Testing {core} stage1 (aarch64-unknown-linux-gnu -> aarch64-unknown-linux-gnu)
   Compiling core v0.0.0 (/home/gh-jyn514/rust/library/core)
error[E0773]: attempted to define built-in macro more than once
    --> /home/gh-jyn514/rust/library/core/src/macros/mod.rs:1310:5
     |
1310 |     macro_rules! cfg {
     |     ^^^^^^^^^^^^^^^^
     |
note: previously defined here
    --> /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/ci-rustc-sysroot/lib/rustlib/src/rust/library/core/src/macros/mod.rs:13
10:5
     |
1310 |     macro_rules! cfg {
     |     ^^^^^^^^^^^^^^^^

error[E0152]: duplicate lang item in crate `core` (which `corebenches` depends on): `sized`.
  |
  = note: the lang item is first defined in crate `core` (which `std` depends on)
  = note: first definition in `core` loaded from /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/ci-rustc-sysroot/lib/rustlib/a
arch64-unknown-linux-gnu/lib/libcore-d20cd64dc93f727e.rlib
  = note: second definition in `core` loaded from /home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/stage1-std/aarch64-unknown-li
nux-gnu/release/deps/libcore-8c941efb0bc89716.rlib

I think the right fix is to unconditionally use the stage 2 compiler in compiler_for when config.download_rustc is set:

let compiler = builder.compiler_for(builder.top_stage, host, host);

rust/src/bootstrap/lib.rs

Lines 1206 to 1210 in a5d2731

fn force_use_stage1(&self, compiler: Compiler, target: TargetSelection) -> bool {
!self.config.full_bootstrap
&& compiler.stage >= 2
&& (self.hosts.iter().any(|h| *h == target) || target == self.build)
}

Meta

HEAD is 35636f9

Metadata

Metadata

Assignees

Labels

A-download-rustcArea: The `rust.download-rustc` build option.C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions