Skip to content

Commit 7f17efc

Browse files
committed
try more for musl builds
1 parent c6c6d45 commit 7f17efc

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

boring-sys/build/main.rs

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,26 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
213213
return boringssl_cmake;
214214
}
215215

216+
let target_is_musl = config.target.contains("unknown-linux-musl");
217+
let using_zig = config
218+
.env
219+
.cc
220+
.as_deref()
221+
.and_then(|s| s.to_str())
222+
.map(|s| s.contains("zig") || s.ends_with("zigcc") || s.ends_with("zigcxx"))
223+
.unwrap_or_default();
224+
216225
if should_use_cmake_cross_compilation(config) {
217-
boringssl_cmake
218-
.define("CMAKE_CROSSCOMPILING", "true")
219-
.define("CMAKE_C_COMPILER_TARGET", &config.target)
220-
.define("CMAKE_CXX_COMPILER_TARGET", &config.target)
221-
.define("CMAKE_ASM_COMPILER_TARGET", &config.target);
226+
boringssl_cmake.define("CMAKE_CROSSCOMPILING", "true");
227+
228+
// Do NOT set CMAKE_*_COMPILER_TARGET when using Zig.
229+
// CMake turns these into `--target=<rust-triple>` which Zig cannot parse.
230+
if !using_zig {
231+
boringssl_cmake
232+
.define("CMAKE_C_COMPILER_TARGET", &config.target)
233+
.define("CMAKE_CXX_COMPILER_TARGET", &config.target)
234+
.define("CMAKE_ASM_COMPILER_TARGET", &config.target);
235+
}
222236
}
223237

224238
if let Some(cc) = &config.env.cc {
@@ -343,22 +357,26 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
343357
);
344358
}
345359
"aarch64" => {
346-
boringssl_cmake.define(
347-
"CMAKE_TOOLCHAIN_FILE",
348-
config
349-
.manifest_dir
350-
.join("cmake/aarch64-linux.cmake")
351-
.as_os_str(),
352-
);
360+
if !(target_is_musl && using_zig) {
361+
boringssl_cmake.define(
362+
"CMAKE_TOOLCHAIN_FILE",
363+
config
364+
.manifest_dir
365+
.join("cmake/aarch64-linux.cmake")
366+
.as_os_str(),
367+
);
368+
}
353369
}
354370
"arm" => {
355-
boringssl_cmake.define(
356-
"CMAKE_TOOLCHAIN_FILE",
357-
config
358-
.manifest_dir
359-
.join("cmake/armv7-linux.cmake")
360-
.as_os_str(),
361-
);
371+
if !(target_is_musl && using_zig) {
372+
boringssl_cmake.define(
373+
"CMAKE_TOOLCHAIN_FILE",
374+
config
375+
.manifest_dir
376+
.join("cmake/armv7-linux.cmake")
377+
.as_os_str(),
378+
);
379+
}
362380
}
363381
_ => {
364382
println!(

0 commit comments

Comments
 (0)