Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jyn514 opened this issue Mar 5, 2023 · 2 comments · Fixed by #108866
Closed

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

jyn514 opened this issue Mar 5, 2023 · 2 comments · Fixed by #108866
Assignees
Labels
A-download-rustc Area: The `rust.download-rustc` build option. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented Mar 5, 2023

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

@jyn514 jyn514 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Mar 5, 2023
@jyn514
Copy link
Member Author

jyn514 commented Mar 5, 2023

This also affects the compiler unit tests:

   Doc-tests coverage_test_macros
/home/gh-jyn514/rust/build/aarch64-unknown-linux-gnu/ci-rustc-sysroot/bin/rustdoc: error while loading shared libraries: libtest-0f3918aac36b946e.so: cannot open shared object file: No such file or directory

@Kohei316
Copy link
Contributor

Kohei316 commented Mar 5, 2023

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 7, 2023
Force to use the stage 2 compiler  when config.download_rustc is set

Fixes rust-lang#108768
@jyn514 jyn514 added the A-download-rustc Area: The `rust.download-rustc` build option. label Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-download-rustc Area: The `rust.download-rustc` build option. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants