Skip to content

Add new --test-codegen-backend bootstrap option #145256

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Aug 11, 2025

This new bootstrap command line flag allows to do:

./x.py test tests/ui/intrinsics/panic-uninitialized-zeroed.rs --stage 1 -j8 --test-codegen-backend gcc

This is the last step before running it into the CI.

Supersedes #144687.

r? @Kobzol

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 11, 2025

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

{
let sysroot = sysroot.join("lib");
let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8");
cargo.env("LD_LIBRARY_PATH", sysroot_str);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly I still need to change this env variable to be able to build the compiler with the GCC backend. However, no need anymore for the tests. \o/

@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Member

Kobzol commented Aug 11, 2025

Why isn't it enough to set rust.codegen-backends = ["gcc"] and then run x test? It should build stage 1 rustc configured to use the GCC backend by default, so when it is used in tests, it should compile everything using the GCC codegen backend.

@GuillaumeGomez
Copy link
Member Author

Because as a first step we want to keep rustc built with LLVM and run tests with the GCC backend to limit the potential impact.

@GuillaumeGomez GuillaumeGomez force-pushed the bootstrap-test-codegen-backend branch from 65df661 to 09c014a Compare August 11, 2025 16:28
@Kobzol
Copy link
Member

Kobzol commented Aug 11, 2025

If stage 1 tests are enough for you, then using the default codegen backend would be enough for that. We would build rustc using LLVM, then build libstd using GCC, and then run tests using GCC. Or do you think we require stage 2 at this moment?

@GuillaumeGomez
Copy link
Member Author

I have two use cases for this:

  1. It's super easy to test another codegen backend without having to edit a config file without (potentially) having to recompile.
  2. I'd like to be able to "cross test" rustc built with one backend and using another one to ensure no weird corner cases come up.

@GuillaumeGomez
Copy link
Member Author

Forgot but we're supposed to have a command-line argument as described here.

@Kobzol
Copy link
Member

Kobzol commented Aug 11, 2025

I have two use cases for this:

  1. It's super easy to test another codegen backend without having to edit a config file without (potentially) having to recompile.
  2. I'd like to be able to "cross test" rustc built with one backend and using another one to ensure no weird corner cases come up.

You can do e.g. x test --set 'rust.codegen-backends=["gcc"]' to run tests with the GCC backend without modifying the config file.

I'm fine with having a flag, but I don't think that what the PR currently does is what you want 🤔It only tells compiletest that you're using a rustc that builds stuff using the GCC backend, but you don't make sure that is indeed what happens. In other words, the flag as currently implemented is a no-op, and the actual functionality that gets you GCC used during tests is setting "gcc" as the first member of "rust.codegen-backends". That's why I was confused about what the flag should do and how does it differ from setting the "gcc" field 😅

I would suggest either:

  • Not add a flag for now and just set "gcc" as the first member of rust.codegen-backends. This allows you to use a LLVM-compiled rustc and GCC-compiled stdlib to run (stage 1) tests using the GCC backend.
  • Add a flag that will instruct compiletest to append something like -Zcodegen-backend=gcc to the compile flags of every executed test. This allows you to use a LLVM-compiled rustc + LLVM-compiled stdlib and run (even stage 2) tests using the GCC backkend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants