Skip to content

compiletest: add implied needs-target-std for codegen mode tests unless annotated with #![no_std]/#![no_core]#151294

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
jieyouxu:infer-needs-target-std
Jan 26, 2026
Merged

compiletest: add implied needs-target-std for codegen mode tests unless annotated with #![no_std]/#![no_core]#151294
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
jieyouxu:infer-needs-target-std

Conversation

@jieyouxu
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu commented Jan 18, 2026

A codegen mode test (such as codegen-llvm test suite) will now by default have an implied //@ needs-target-std directive, unless the test explicitly has an #![no_std]/#![no_core] attribute which disables this behavior.

  • When a test has both #![no_std]/#![no_core] and //@ needs-target-std, the explicit //@ needs-target-std directive will cause the test to be ignored for targets that do not support std still.

This is to make it easier to test out-of-tree targets / custom targets (and targets not tested in r-l/r CI) without requiring target maintainers to do a bunch of manual //@ needs-target-std busywork.

Context: #t-compiler/help > `compiletest` cannot find `core` library for target != host

Implementation remarks

This is an alternative version of #150672, with some differences:

  • This PR applies this implied-needs-target-std behavior to all codegen test mode tests.
  • This PR does the synthetic directive injection in the same place as implied-codegen-run directives. Both are of course hacks, but at least they're together next to each other.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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