Closed Tirka closed 2 years ago
Thanks for the report, and sorry about the problem you've run into. This was changed in #9601, and I asked for clarification over there. But I'm also wondering, is it feasible for you to use CARGO_ENCODED_RUSTFLAGS
? I'm not sure if your project has strict requirements for supporting older versions of cargo.
Unfortunately, this change of the Cargo behavior affects 3rd party crates, which rely on RUSTFLAGS
in their build.rs.
(e.g., https://github.com/darrenldl/reed-solomon-erasure/blob/5fe2d8a7786ac7891cca6c1e20371a0be0c9ce82/build.rs#L164)
So, this is not a bug? Is this behavior expected?
Following up from https://github.com/rust-lang/cargo/pull/9601#issuecomment-976888868 I'll echo what jonhoo said and otherwise add that other methods of configuring flags, e.g. build.rustflags
and such, were never reflected with RUSTFLAGS
and are now all reflected via the replacement. While this was a breaking change I figured it was ok since it was only "half" working before when the outer cargo invocation already happened to set the environment variable and it would be best for a guaranteed source of information instead of one that only may happen to be set.
We added it to the Changelog, both in the release where the change happened and in the release where you noticed it. Sorry for not documenting this change when it happened. https://github.com/rust-lang/cargo/pull/10141
Problem
Environment variable RUSTFLAGS not set inside build.rs script since Rust 1.55.0
Steps
Install Rust Stable 1.54 and 1.55
Clone Minimal Reproducible Example
Build with Cargo and Rust Stable 1.54.0
Output:
Cargo clean
Build with Cargo and Rust Stable 1.55.0
Output:
It looks like
RUSTFLAGS
environment variable is not available withinbuild.rs
script since1.55.0
and I can't find any info related to this new behavior in the changelog.Possible Solution(s)
No response
Notes
No response
Version
No response