Feature gate: #![feature(env_host_tuple)]
This adds the current host tuple (AKA target triple) to std::env.
The goal is to remove the need for using build scripts to save Cargo's TARGET env var (example). Tools invoking cargo often need to know the platform's default target in order to add a matching --target <tuple> arg.
It uses the term "tuple" instead of "triple", because the "host tuple" terminology has been decided in: #125579 (comment)
It uses the term "host", because:
- after
std has been built, its compilation target becomes the host for programs using it.
- during cross-compilation, Cargo's
build.rs scripts will get the same tuple in the HOST env var, but a different TARGET.
- the term "target" is overloaded in Rust/Cargo.
Public API
std::env::consts::HOST_TUPLE: &str
Steps / History
Unresolved Questions
@rustbot label -S-tracking-unimplemented
Feature gate:
#![feature(env_host_tuple)]This adds the current host tuple (AKA target triple) to
std::env.The goal is to remove the need for using build scripts to save Cargo's
TARGETenv var (example). Tools invokingcargooften need to know the platform's default target in order to add a matching--target <tuple>arg.It uses the term "tuple" instead of "triple", because the "host tuple" terminology has been decided in: #125579 (comment)
It uses the term "host", because:
stdhas been built, its compilation target becomes the host for programs using it.build.rsscripts will get the same tuple in theHOSTenv var, but a differentTARGET.Public API
Steps / History
Unresolved Questions
@rustbot label -S-tracking-unimplemented
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩