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

Bootstrap sometimes fails to build miri because of "nightly" feature confusion #118129

Closed
RalfJung opened this issue Nov 21, 2023 · 10 comments · Fixed by #134526
Closed

Bootstrap sometimes fails to build miri because of "nightly" feature confusion #118129

RalfJung opened this issue Nov 21, 2023 · 10 comments · Fixed by #134526
Labels
A-miri Area: The miri tool C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@RalfJung
Copy link
Member

Step to reproduce:

rm build/host/stage0* -rf
./x.py check library/std compiler/rustc src/tools/miri

Now Miri fails to build with >1800 errors. The first ones are:

error[E0464]: multiple candidates for `rmeta` dependency `rustc_ast` found
  --> src/tools/miri/src/lib.rs:53:1
   |
53 | extern crate rustc_ast;
   | ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: candidate #1: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_ast-11854d11a3563889.rmeta
   = note: candidate #2: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_ast-feb80e66ce1c74d4.rmeta

error[E0464]: multiple candidates for `rmeta` dependency `rustc_const_eval` found
  --> src/tools/miri/src/lib.rs:54:1
   |
54 | extern crate rustc_const_eval;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: candidate #1: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_const_eval-078a7b0d61866866.rmeta
   = note: candidate #2: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_const_eval-2fa8de12acbc8979.rmeta

error[E0464]: multiple candidates for `rmeta` dependency `rustc_data_structures` found
  --> src/tools/miri/src/lib.rs:55:1
   |
55 | extern crate rustc_data_structures;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: candidate #1: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_data_structures-93605ddb6ab78ed8.rmeta
   = note: candidate #2: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_data_structures-e65a21da042ec502.rmeta

error[E0464]: multiple candidates for `rmeta` dependency `rustc_errors` found
  --> src/tools/miri/src/lib.rs:56:1
   |
56 | extern crate rustc_errors;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: candidate #1: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_errors-792f00940afc5752.rmeta
   = note: candidate #2: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_errors-ddd5d12697277ea9.rmeta

error[E0464]: multiple candidates for `rmeta` dependency `rustc_hir` found
  --> src/tools/miri/src/lib.rs:57:1
   |
57 | extern crate rustc_hir;
   | ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: candidate #1: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_hir-37bcaf20f0254cb3.rmeta
   = note: candidate #2: /home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_hir-6f8ad5718a5b342e.rmeta

However, if I now run ./x.py check miri, everything is fine. rm build/host/stage0* -rf && ./x.py check miri is also fine. Something about explicitly giving the three paths to build is throwing bootstrap off. And even more strangely, the same sequence of commands worked fine before #116828.

Cc @rust-lang/bootstrap

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 21, 2023
@fmease fmease added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. A-miri Area: The miri tool and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 2, 2023
@onur-ozkan
Copy link
Member

onur-ozkan commented Dec 3, 2023

compiler/rustc_index_macros should be compiled with its default feature nightly. However, in rustc_index, this feature disabled by default. When compiling these specific paths (library/std compiler/rustc src/tools/miri), rustc_index_macros is not built with its default feature.

A quick workaround for your case would be adding compiler/rustc_index_macros path in x check (like x check library/std compiler/rustc compiler/rustc_index_macros src/tools/miri).

@RalfJung
Copy link
Member Author

RalfJung commented Apr 4, 2024

FWIW I cannot reproduce the problem any more. Has this been fixed?

@RalfJung
Copy link
Member Author

RalfJung commented Apr 4, 2024

Actually never mind the issue still exists

@RalfJung
Copy link
Member Author

RalfJung commented Dec 15, 2024

@onur-ozkan

However, in rustc_index, this feature disabled by default.

I don't understand this explanation. Looking at the Cargo.toml, we have

rustc_index_macros = { path = "../rustc_index_macros", default-features = false }

and

[features]
# tidy-alphabetical-start
default = ["nightly"]
nightly = [
    "dep:rustc_serialize",
    "dep:rustc_macros",
    "rustc_index_macros/nightly",
]
rustc_randomized_layouts = []
# tidy-alphabetical-end

So by default, we do enable rustc_index_macros/nightly.

Why does adding compiler/rustc_index_macros even make any difference here? I can't find any code in bootstrap that would special-case this crate. This is all quite strange to me.

@RalfJung
Copy link
Member Author

RalfJung commented Dec 15, 2024

Cc @compiler-errors

The work-around for this works, but it makes the x invocation in RA so long that RA no longer shows progress during the build in vscode. So it'd be nice to get this fixed properly; something about this entire "nightly" feature setup is just not working correctly currently.

@RalfJung RalfJung changed the title Bootstrap sometimes fails to build miri Bootstrap sometimes fails to build miri because of "nightly" feature confusion Dec 15, 2024
@compiler-errors
Copy link
Member

what am i being ccd for

@RalfJung
Copy link
Member Author

RalfJung commented Dec 15, 2024

@compiler-errors you wrote some of the commits adding this "nightly" feature everywhere (e.g. 4506681). Somehow that is causing issues with building Miri: some rustc crates end up being built twice with different feature sets, and then the extern crate in Miri doesn't know which crate to load. I don't understand how this nightly feature is being enabled/disabled where, so I figured maybe you can help.

@RalfJung
Copy link
Member Author

I think I found another work-around: ./x check library compiler miri also works. It's just compiler/rustc that causes problems. I have no idea why...

@compiler-errors
Copy link
Member

not totally sure, but sounds like a bootstrap issue 🤔

@onur-ozkan
Copy link
Member

It's more of a cargo thing (I am not sure if this is an expected behaviour or not). When default-features = false is set, cargo can't propagate "nightly" feature which is a default feature for compiler/rustc_index_macros/Cargo.toml but disabled with default-features = false in compiler/rustc_index/Cargo.toml.

See #134526 for the fix.

cc @rust-lang/cargo

jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 20, 2024
…ieyouxu

update `rustc_index_macros` feature handling

It seems that cargo can't [conditionally propagate features](https://github.com/rust-lang/rust/blob/214587c89d527dd0ccbe1f2150c737d3bdee67b0/compiler/rustc_index/Cargo.toml#L20) if they were enabled by default on the target crate, but disabled with `default-features = false` in the current/parent crate.

Fixes rust-lang#118129
DianQK added a commit to DianQK/rust that referenced this issue Dec 21, 2024
…ieyouxu

update `rustc_index_macros` feature handling

It seems that cargo can't [conditionally propagate features](https://github.com/rust-lang/rust/blob/214587c89d527dd0ccbe1f2150c737d3bdee67b0/compiler/rustc_index/Cargo.toml#L20) if they were enabled by default on the target crate, but disabled with `default-features = false` in the current/parent crate.

Fixes rust-lang#118129
@bors bors closed this as completed in e461a3f Dec 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 22, 2024
Rollup merge of rust-lang#134526 - onur-ozkan:nightly-feat-rustc, r=jieyouxu

update `rustc_index_macros` feature handling

It seems that cargo can't [conditionally propagate features](https://github.com/rust-lang/rust/blob/214587c89d527dd0ccbe1f2150c737d3bdee67b0/compiler/rustc_index/Cargo.toml#L20) if they were enabled by default on the target crate, but disabled with `default-features = false` in the current/parent crate.

Fixes rust-lang#118129
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-miri Area: The miri tool C-bug Category: This is a bug. 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.

5 participants