CARGO_CFG_TARGET_FEATURE
does not include default value of crt-static
#14778
Labels
A-build-scripts
Area: build.rs scripts
C-bug
Category: bug
S-needs-design
Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Problem
The value of
target_feature = "crt-static"
can be controlled inrustc
with-Ctarget-feature=+crt-static
or-Ctarget-feature=-crt-static
. Some targets have this enabled by default, but that doesn't seem to be propagated toCARGO_CFG_TARGET_FEATURE
.Steps
Create a build script with the following contents:
Since running
rustc --target=aarch64-unknown-linux-musl --print=cfg
outputstarget_feature="crt-static"
, one would expect it to also be output withcargo check --target=aarch64-unknown-linux-musl
of the above program, but it does not, settingRUSTFLAGS="-Ctarget-features=+crt-static"
is required.Possible Solution(s)
Maybe this method in
rustc
needs to be tweaked?Or maybe Cargo needs to avoid passing
--crate-type proc-macro
torustc
when determining target info? (somewhere around here)Notes
This is somewhat affecting
cc
, as it is not guaranteed to pass the correct value for the ``/-static
flag to compilers (though it shouldn't matter much since `cc` doesn't link anyhow).Version
cargo 1.84.0-nightly (cf53cc5 2024-10-18)
release: 1.84.0-nightly
commit-hash: cf53cc5
commit-date: 2024-10-18
host: aarch64-apple-darwin
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.7.1 (sys:0.4.74+curl-8.9.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Mac OS 14.7.0 [64-bit]
The text was updated successfully, but these errors were encountered: