Skip to content

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

Open
@jieyouxu

Description

@jieyouxu

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

if triple.contains("-none") || triple.contains("nvptx") || triple.contains("switch") {
target.no_std = true;
}

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 field1. Built-in target specs currently without std support field (2025-06-10)2:

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

Footnotes

  1. Putting aside that metadata is really only intended for doc generation purposes and is by no means guaranteed to be reliable

  2. Just for expository purposes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-targetsArea: Concerning the implications of different compiler targetsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions