Open
Description
Problem
When setting flags with the profile-rustflags
unstable feature (tracking issue #10271), the data is not propagated to the build script environment variables CARGO_CFG_TARGET_FEATURE
and CARGO_ENCODED_RUSTFLAGS
.
Steps
- Create a new binary
- Create a
build.rs
:
fn main() {
println!("cargo:warning=Feats: {:?} Flags: {:?}", std::env::var("CARGO_CFG_TARGET_FEATURE"), std::env::var("CARGO_ENCODED_RUSTFLAGS"));
}
- Set up
Cargo.toml
:
cargo-features = [ "profile-rustflags" ]
[package]
name = "profile_flags_script"
version = "0.1.0"
edition = "2021"
[profile.dev]
rustflags = [ "-C", "target-feature=+crt-static" ]
- Call
cargo run
- observe thatcrt-static
is not reported by the build script. - Create
.cargo/Config.toml
:
[build]
rustflags = [ "-C", "target-feature=+crt-static" ]
- Call
cargo clean
andcargo run
- observe that the build script now sees thecrt-static
flag, as it should.
Possible Solution(s)
No response
Notes
This issue seems very similar to #6858.
Version
cargo 1.70.0-nightly (145219a9f 2023-03-27)
release: 1.70.0-nightly
commit-hash: 145219a9f089f8b57c09f40525374fbade1e34ae
commit-date: 2023-03-27
host: x86_64-pc-windows-msvc
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:Schannel)
os: Windows 10.0.19045 (Windows 10 Home) [64-bit]