-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Proposal
Problem statement
Programs can't get the host tuple/target triple they've been built for without running build.rs
std::env::consts
has some information about the host, but not enough reconstruct the full tuple.
Motivating examples or use cases
Tools that work with rustc, Cargo or rustdoc usually need to support --target
and emulate default behavior of building for the host if --target
is not specified.
However, the actual value of the host tuple is not easy to get. The workaround for this is to save TARGET
from build.rs
, but build scripts are relatively heavy, and Cargo would like to minimize need for them: rust-lang/cargo#14948
Solution sketch
Alternatives
There are cfg!(target_*)
macros that makes fragments of the tuple available already, but their values are not easily available. Maybe if cfg
's could be readable as values, and target
cfg existed, then some cfg_value!(target)
.
Links and related work
https://docs.rs/current_platform/0.2.0/current_platform/ / https://crates.io/crates/current_platform