Skip to content

Host tuple available without build.rs #664

@kornelski

Description

@kornelski

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

rust-lang/rust#146296

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

rust-lang/rust#146295

https://docs.rs/current_platform/0.2.0/current_platform/ / https://crates.io/crates/current_platform

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions