Mechanism for automatically passing flags used by rustc · Issue #1254 · rust-lang/cc-rs (original) (raw)

When cc-rs is running in a build script, it currently does not check which flags were passed to rustc.

There are some flags which in order to be fully effective need to be passed to both rustc and cc, a good example being AArch64 branch protection - if the Rust code is built with BTI but the C component is not, that will disable BTI for the whole binary.

Would some mechanism for checking which flags were passed to rustc and determining their corresponding cc flags be desirable to have? This could either be in the form of adding them in automatically, a separate function such as inherit_rustc_flags() or even just a warning to the user that some flags that should match don't match.

I'm thinking about implementing something along the lines of what I described above, but I wanted to ask for some thoughts from people who work on this crate. Is this desirable in the first place? If so, roughly what direction should I go in with this?