rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.8k stars 434 forks source link

Deployment target incorrect in rust-std assets on apple platforms #1171

Open Reflejo opened 1 month ago

Reflejo commented 1 month ago

After this PR, the rust-std assets built in CI (nightly/beta/stable/etc) have an incorrect deployment target on darwin. rust-std was relying on. rusts' default targets when IPHONEOS_DEPLOYMENT_TARGET was not set and the CI job does not include that env var.

Meaning that when rust-std is built with the c feature (it is for all assets), the rust-std rlib takes the maximum minos which thanks to libcompile-rt is now the host sdk-version.

Related issue https://github.com/rust-lang/compiler-builtins/issues/650#issuecomment-2267277172

I proposed two solutions in the previous issue, let me know if you think of a third.

cc @BlackHoleFox

BlackHoleFox commented 1 month ago

From your options I think its better if Rust's CI sets the environment variable to control it. imo compiler-builtins should use the same variables as std, or maybe it would be enough if Rust's CI set IPHONEOS_DEPLOYMENT_TARGET next to the macOS one (seems like a bug that its not there as well).

I do sympathize and apologize for the upstream bug :( I don't think this is for cc to fix, see below for a longer explanation why. I'll ping @NobodyXu in case though.

Long-winded tangent time, though: We have significantly struggled to find the "right default" for everyone now that Rust's deployment target can be different then 7.0 from years ago. We nuked the rustc querying from cc because it broke too many people's build setups where they were relying on the XCode-ish behavior of your current SDK, when they actually should have been setting the variable (like Apple intends, but Rust projects historically haven't cared about this for above reasons). A perfect world would let us restore the rustc querying default (so Rust projects stick with Rust's defaults, instead of Apple's) and tell everyone to set their deployment targets like every XCode and SwiftPM project have you do. Alas though!