Skip to content

Commit 51a6d44

Browse files
committed
boring-sys: Don't use CMake cross-compilation for macOS->iOS
(or macOS->macOS)
1 parent 9cf03ae commit 51a6d44

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

boring-sys/build/main.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ use crate::config::Config;
1111

1212
mod config;
1313

14+
fn should_use_cmake_cross_compilation(config: &Config) -> bool {
15+
if config.host == config.target {
16+
return false;
17+
}
18+
match config.target_os.as_str() {
19+
"macos" | "ios" => {
20+
// Cross-compiling for Apple platforms on macOS is supported using the normal Xcode
21+
// tools, along with the settings from `cmake_params_apple`.
22+
!config.host.ends_with("-darwin")
23+
}
24+
_ => true,
25+
}
26+
}
27+
1428
// Android NDK >= 19.
1529
const CMAKE_PARAMS_ANDROID_NDK: &[(&str, &[(&str, &str)])] = &[
1630
("aarch64", &[("ANDROID_ABI", "arm64-v8a")]),
@@ -193,11 +207,13 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
193207
return boringssl_cmake;
194208
}
195209

196-
boringssl_cmake
197-
.define("CMAKE_CROSSCOMPILING", "true")
198-
.define("CMAKE_C_COMPILER_TARGET", &config.target)
199-
.define("CMAKE_CXX_COMPILER_TARGET", &config.target)
200-
.define("CMAKE_ASM_COMPILER_TARGET", &config.target);
210+
if should_use_cmake_cross_compilation(config) {
211+
boringssl_cmake
212+
.define("CMAKE_CROSSCOMPILING", "true")
213+
.define("CMAKE_C_COMPILER_TARGET", &config.target)
214+
.define("CMAKE_CXX_COMPILER_TARGET", &config.target)
215+
.define("CMAKE_ASM_COMPILER_TARGET", &config.target);
216+
}
201217

202218
if let Some(sysroot) = &config.env.sysroot {
203219
boringssl_cmake.define("CMAKE_SYSROOT", sysroot);

0 commit comments

Comments
 (0)