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.77k stars 427 forks source link

Don't use the value of SDKROOT if it doesn't match the target. #1047

Closed jfgoog closed 2 months ago

jfgoog commented 2 months ago

The SDKROOT environment variable can be problematic on Mac. In cases where you are compiling for multiple targets, SDKROOT cannot be right for all of them. Furthermore, the system Python interpreter sets SDKROOT to the MacOSX SDK if not already set.

So, if you are using a Python script to run a build, and you need to build for multiple targets, the logic in the cc crate doesn't work. This is precisely what is happening with rustc itself, and so we can't upgrade the version of the cc crate used by the bootstrap code.

(Unsetting SDKROOT doesn't work either because the custom clang build that rustc uses for CI depends on it being set)

jfgoog commented 2 months ago

For more information, see https://github.com/rust-lang/rust/pull/122504 and https://github.com/rust-lang/rust/issues/124565