Skip to content

Revisit the rust_test_helpers setup #140680

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
jieyouxu opened this issue May 5, 2025 · 0 comments
Open

Revisit the rust_test_helpers setup #140680

jieyouxu opened this issue May 5, 2025 · 0 comments
Labels
A-test-infra Area: test infrastructure (may span bootstrap/compiletest/more) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jieyouxu
Copy link
Member

jieyouxu commented May 5, 2025

ui, incremental test suites all have implicit access to a C helper static library built for the host/target platforms, called rust_test_helpers.

EDIT: two copies, one for host, one for target, see

// Provide `rust_test_helpers` for both host and target.
if suite == "ui" || suite == "incremental" {
builder.ensure(TestHelpers { target: compiler.host });
builder.ensure(TestHelpers { target });
hostflags
.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
}
.

https://github.com/rust-lang/rust/blob/master/tests/auxiliary/rust_test_helpers.c

https://github.com/search?q=repo%3Arust-lang%2Frust%20rust_test_helpers&type=code

This is kinda strange for a few reasons:

  • All tests/{ui,incremental} tests implicitly have the built C static lib in the linker search paths, even if the test doesn't need it
  • A test might not need rust_test_helpers, but during bootstrap, it will be unconditionally built for the target anyway (requires a working target C compiler toolchain).
  • You can't specify or override what C compiler flags rust_test_helpers is built with. Notably, this includes optimization levels or debuginfo levels, or sanitizers or whatever. Every tests/{ui,incremental} gets access to the same prebuilt copy.

I'm not looking to change this any time soon, since it needs some surveying on what use cases tests using rust_test_helpers are exercising to come up with more robust alternative designs.

@jieyouxu jieyouxu added A-test-infra Area: test infrastructure (may span bootstrap/compiletest/more) C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 5, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 5, 2025
@jieyouxu jieyouxu added A-testsuite Area: The testsuite used to check the correctness of rustc and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-test-infra Area: test infrastructure (may span bootstrap/compiletest/more) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants