Skip to content

configure: Use CARGO_CFG_*_{F16,F128} rather than invoking rustc #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Aug 5, 2025

Currently we run rustc from the RUSTC environment variable to figure out whether or not to enable f16 and f128, based on the target_has_reliable_{f16,f128} config. However, this does not know about the codegen backend used, and the backend isn't trivial to check in a build script (usually the backend gets set via RUSTFLAGS).

It turns out we don't actually need to run rustc here: Cargo unconditionally emits all config from the relevant compiler as CARGO_CFG_* variables, regardless of whether or not they are known options. Switch to checking these to set config rather than invoking rustc.

As an added advantage, we don't need any special handling for target.json files.

Fixes: ed17b95 ("Use the compiler to determine whether or not to enable f16 and f128")

Currently we run the `rustc` from the `RUSTC` environment variable to
figure out whether or not to enable `f16` and `f128`, based on the
`target_has_reliable_{f16,f128}` config. However, this does not know
about the codegen backend used, and the backend isn't trivial to check
in a build script (usually it gets set via `RUSTFLAGS`).

It turns out we don't actually need to run `rustc` here: Cargo
unconditionally emits all config from the relevant compiler as
`CARGO_CFG_*` variables, regardless of whether or not they are known
options. Switch to checking these for setting config rather than
invoking `rustc`.

As an added advantage, this will work with target.json files without any
special handling.

Fixes: ed17b95 ("Use the compiler to determine whether or not to enable `f16` and `f128`")
@tgross35 tgross35 merged commit 87a66ec into rust-lang:master Aug 5, 2025
38 checks passed
@tgross35 tgross35 deleted the cargo-rustc-fix branch August 5, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant