rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.57k stars 12.62k forks source link

Environment variable `RUSTFLAGS` not set inside `build.rs` script since Rust 1.55.0 #91132

Closed Tirka closed 2 years ago

Tirka commented 2 years ago

Install Rust Stable 1.54 and 1.55

rustup install 1.54.0
rustup install 1.55.0

Clone Minimal Reproducible Example

git clone https://github.com/Tirka/rustflags-buildrs.git
cd ./rustflags-buildrs

Build with Cargo and Rust Stable 1.54.0

RUSTFLAGS="-C target-cpu=skylake" FOO="bar" cargo +1.54.0 build -vv

Output:

[rustflags-buildrs 0.1.0] RUSTFLAGS=Some("-C target-cpu=skylake")
[rustflags-buildrs 0.1.0] FOO=Some("bar")

Cargo clean

cargo clean

Build with Cargo and Rust Stable 1.55.0

RUSTFLAGS="-C target-cpu=skylake" FOO="bar" cargo +1.55.0 build -vv

Output:

[rustflags-buildrs 0.1.0] RUSTFLAGS=None
[rustflags-buildrs 0.1.0] FOO=Some("bar")

It looks like RUSTFLAGS environment variable is not available within build.rs script since 1.55.0 and I can't find any info related to this new behavior in the changelog.

jyn514 commented 2 years ago

@ehuss could you transfer this to rust-lang/cargo?

Tirka commented 2 years ago

@ehuss could you transfer this to rust-lang/cargo?

Sure

Tirka commented 2 years ago

Transferred to https://github.com/rust-lang/cargo/issues/10111