Skip to content

Commit 87514bf

Browse files
authored
Rollup merge of #142297 - jieyouxu:needs-target-std, r=Kobzol
Implement `//@ needs-target-std` compiletest directive Closes rust-lang/rust#141863. Needed to unblock rust-lang/rust#139244 and rust-lang/rust#141856. ### Summary This PR implements a `//@ needs-target-std` compiletest directive that gates test execution based on whether the target supports std or not. For some cases, this should be preferred over e.g. some combination of `//@ ignore-none`, `//@ ignore-nvptx` and more[^none-limit]. ### Implementation limitation Unfortunately, since there is currently [no reliable way to determine from metadata whether a given target supports std or not](rust-lang/rust#142296), we have to resort to a hack. Bootstrap currently determines whether or not a target supports std by a naive target tuple substring comparison: a target supports std if its target tuple does *not* contain one of `["-none", "nvptx", "switch"]` substrings. This PR simply pulls that hack out into `build_helpers` to avoid reimplementing the same hack in compiletest, and uses that logic to inform `//@ needs-target-std`. ### Auxiliary changes This PR additionally changes a few run-make tests to use `//@ needs-target-std` over an inconsistent combination of target-based `ignore`s. This should help with rust-lang/rust#139244. --- r? bootstrap [^none-limit]: Notably, `target_os = "none"` is **not** a sufficient condition for "target does not support std"
2 parents b6cfb66 + b8b2ca4 commit 87514bf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/tests/directives.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ settings:
202202
`//@ needs-crate-type: cdylib, proc-macro` will cause the test to be ignored
203203
on `wasm32-unknown-unknown` target because the target does not support the
204204
`proc-macro` crate type.
205+
- `needs-target-std` — ignores if target platform does not have std support.
205206

206207
The following directives will check LLVM support:
207208

0 commit comments

Comments
 (0)