cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

`CARGO_ENCODED_RUSTFLAGS` doesn't include flags for builtin Cargo options

Open madsmtm opened this issue 2 months ago • 1 comments

In particular, it doesn't include LTO flags when using Cargo's [profile.*] lto = "..." option.

This prevents us from correctly passing -flto=..., which affects Rust's bootstrap, and which I hit recently in https://github.com/rust-lang/rust/pull/148925.

I'm unsure if this is something that Cargo is aware of, though see e.g. https://github.com/rust-lang/cargo/issues/12437 for a similar issue. CC @weihanglo, how do you think Cargo would best expose to build scripts like cc-rs that it's doing LTO?

madsmtm avatar Nov 15 '25 20:11 madsmtm

It is more similar to these:

Unfortunately CARGO_ENCODED_RUSTFLAGS doesn't not expose flags controlled by Cargo. It represents extra flags that user passes directly.

Feel free to create a Cargo issue and we can discuss there!

weihanglo avatar Nov 17 '25 21:11 weihanglo