rust-lang / rust-lang/rust

There isn't a reliable way to determine if a given target tuple supports std or not

Open
#142,296 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-targets C-enhancement T-bootstrap T-compiler T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Related to #141863. I'd like to implement a reliable //@ needs-target-std compiletest directive, but after some experimentation I found out that we don't really have a reliable way to determine if a given target tuple supports std.

Bootstrap, for this reason, has to resort to the hack for determining target std support that is

https://github.com/rust-lang/rust/blob/100199c9aa50b0c47b37c9c86335d68b2a77b535/src/bootstrap/src/core/config/toml/target.rs#L87-L89

Noratrieb suggested a proper long-term solution (on community discord)

the std build script should probably read it from the metadata field [..]
and then the metadata is actually reliable

which seems way more principled to me.

rustc similarly does not have any way to convey this information. For instance, the closest thing is the target spec metadata.std field, but not all built-in target specs actually populate this field[^intent]. Built-in target specs currently without std support field (2025-06-10)[^illustrative]:

aarch64-unknown-redox
aarch64-unknown-teeos
aarch64-unknown-uefi
aarch64-uwp-windows-msvc
arm64ec-pc-windows-msvc
armv6k-nintendo-3ds
armv7-wrs-vxworks-eabihf
avr-none
i586-unknown-redox
i686-unknown-uefi
i686-uwp-windows-gnu
i686-uwp-windows-msvc
mips-mti-none-elf
mipsel-mti-none-elf
powerpc-wrs-vxworks-spe
powerpc64-ibm-aix
riscv32im-risc0-zkvm-elf
riscv32imac-unknown-xous-elf
thumbv7a-pc-windows-msvc
wasm32-wali-linux-musl
wasm64-unknown-unknown
x86_64-unknown-l4re-uclibc
x86_64-unknown-uefi
xtensa-esp32-espidf
xtensa-esp32s2-espidf
xtensa-esp32s3-espidf

[^intent]: Putting aside that metadata is really only intended for doc generation purposes and is by no means guaranteed to be reliable
[^illustrative]: Just for expository purposes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the target-support hack in src/bootstrap/src/core/config/toml/target.rs and the existing compiletest needs-target-std proposal. Investigate how the std build script could expose reliable target metadata and how rustc or compiletest would consume it. Done means the directive can reliably determine std support for the listed target tuples.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.