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, 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 ignores. 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"
This PR modifies src/bootstrap/src/core/config.
If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.
The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.
cc @BoxyUwU, @jieyouxu, @kobzol
Since you're already looking at it, r? Kobzol
Maybe you could do the usual try build with "annoying CI jobs that cross-compile". Feel free to r=me with or without doing that.
We have some metadata for that inn the Target json input/output.
https://github.com/rust-lang/rust/blob/100199c9aa50b0c47b37c9c86335d68b2a77b535/compiler/rustc_target/src/json.rs#L101
We have some metadata for that inn the Target json input/output.
https://github.com/rust-lang/rust/blob/100199c9aa50b0c47b37c9c86335d68b2a77b535/compiler/rustc_target/src/json.rs#L101
Please see https://github.com/rust-lang/rust/issues/142296, I've looked at that avenue already. TL;DR not all built-in target specs have this metadata std field
rustcsimilarly does not have any way to convey this information. For instance, the closest thing is the target specmetadata.stdfield, but not all built-in target specs actually populate this field[^intent]. Built-in target specs currently without std support field
(Which additionally, the metadata field is only intended for doc generation purposes, and I don't think we can rely on that as-is even if all target specs do have this metadata available.)
@bors2 try jobs=test-various,armhf-gnu
:hourglass: Trying commit c558db34dc4ad66236d09ba7a2101a4c6b8cacd5 with merge 5a1574d9d1d5c87041fdcc35c5794fbf60746c7c…
To cancel the try build, run the command @bors2 try cancel.
@rustbot author
:sunny: Try build successful (CI)
Build commit: 5a1574d9d1d5c87041fdcc35c5794fbf60746c7c (5a1574d9d1d5c87041fdcc35c5794fbf60746c7c)
@bors r=Kobzol rollup
:pushpin: Commit c558db34dc4ad66236d09ba7a2101a4c6b8cacd5 has been approved by Kobzol
It is now in the queue for this repository.