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

using ~/.cargo/config.toml to enable cranelift results in a confusing error when bootstrapping rustc #135300

Closed
lolbinarycat opened this issue Jan 9, 2025 · 1 comment
Labels
C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@lolbinarycat
Copy link
Contributor

the offending config:

# .cargo/config.toml
unstable.codegen-backend = true
# commenting out the following line will allow rustc to bootstrap successfully
profile.dev.codegen-backend = "cranelift"

the errror:

error: failed to find a `codegen-backends` folder in the sysroot candidates:
       * /home/binarycat/src/rs/rust/build/x86_64-unknown-linux-gnu/stage0
       * /home/binarycat/src/rs/rust/build/x86_64-unknown-linux-gnu/stage0

reproduction steps:

  1. enable download-rustc
  2. remove all of build/
  3. ./x doc library/core (probably any build command works)

there's a lot of workarounds for this, but i was only able to diagnose it on a hunch, so at the very least the error message should be more clear.

@lolbinarycat lolbinarycat added C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 9, 2025
@onur-ozkan onur-ozkan added the D-confusing Diagnostics: Confusing error or lint that should be reworked. label Jan 10, 2025
@onur-ozkan
Copy link
Member

reproduction steps:

enable download-rustc
remove all of build/
./x doc library/core (probably any build command works)

x check without 1 and 2 should be enough for reproduction.

The failure happens during bootstrap compilation itself, which is the first thing we compile on bootstrapping. In order to give a friendly message, what we have to do is:

  1. Parse .cargo/config.toml in the bootstrap python script (which will be migrated to rust eventually)
  2. Check whether sysroot contains the related artifacts for the backend used in .cargo/config.toml
  3. Give a nice error message.

I strongly believe this is too much to give a error message just for a slightly better error message than the current one (I even think the current one is quite clear already).

Even with a nice error message, there is no way to use different backends in .cargo/config.toml if you are using the default stage0 compiler. So, the path for setting different codegen on cargo is requires custom configurations and custom compiler toolchain. If we want to switch codegen backend, that should be done in the bootstrap way rather than doing it with cargo directly.

I am going to close the issue as this isn't something we can consider doing it.

@onur-ozkan onur-ozkan closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

2 participants