mirror of
https://github.com/Sunscreen-tech/Sunscreen.git
synced 2026-04-19 03:00:06 -04:00
Allow cross compilation on mac
This commit is contained in:
@@ -3,6 +3,28 @@ use emsdk::Config as EmConfig;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Allow x86_64 <-> aarch64 cross compilation on macOS
|
||||
/// https://stackoverflow.com/questions/69803659/what-is-the-proper-way-to-build-for-macos-x86-64-using-cmake-on-apple-m1-arm
|
||||
fn setup_macos_cross_compile(config: &mut Config) {
|
||||
let host_triple = std::env::var("HOST").unwrap();
|
||||
let target_triple = std::env::var("TARGET").unwrap();
|
||||
|
||||
let host_triple = host_triple.split("-").collect::<Vec<_>>();
|
||||
let target_triple = target_triple.split("-").collect::<Vec<_>>();
|
||||
|
||||
if host_triple[1] == "apple" && target_triple[1] == "apple" && host_triple[0] != target_triple[0] {
|
||||
config.define("SEAL_MEMSET_S_FOUND_EXITCODE", "0");
|
||||
config.define("SEAL_MEMSET_S_FOUND_EXITCODE__TRYRUN_OUTPUT", "");
|
||||
config.define("SEAL___BUILTIN_CLZLL_FOUND_EXITCODE", "0");
|
||||
config.define("SEAL___BUILTIN_CLZLL_FOUND_EXITCODE__TRYRUN_OUTPUT", "");
|
||||
config.define("SEAL__ADDCARRY_U64_FOUND_EXITCODE", "0");
|
||||
config.define("SEAL__ADDCARRY_U64_FOUND_EXITCODE__TRYRUN_OUTPUT", "");
|
||||
config.define("SEAL__SUBBORROW_U64_FOUND_EXITCODE", "0");
|
||||
config.define("SEAL__SUBBORROW_U64_FOUND_EXITCODE__TRYRUN_OUTPUT", "");
|
||||
//config.define("CMAKE_OSX_ARCHITECTURES", target_triple[0]);
|
||||
}
|
||||
}
|
||||
|
||||
fn compile_native(profile: &str, out_path: &Path) {
|
||||
let hexl = if std::env::var("CARGO_FEATURE_HEXL").is_ok() {
|
||||
"ON"
|
||||
@@ -10,8 +32,9 @@ fn compile_native(profile: &str, out_path: &Path) {
|
||||
"OFF"
|
||||
};
|
||||
|
||||
let dst = Config::new("SEAL")
|
||||
.define("CMAKE_BUILD_TYPE", profile)
|
||||
let mut builder = Config::new("SEAL");
|
||||
|
||||
builder.define("CMAKE_BUILD_TYPE", profile)
|
||||
.define("CMAKE_CXX_FLAGS_RELEASE", "-DNDEBUG -O3")
|
||||
.define("CMAKE_C_FLAGS_RELEASE", "-DNDEBUG -O3")
|
||||
.define("SEAL_USE_GAUSSIAN_NOISE", "ON")
|
||||
@@ -26,8 +49,11 @@ fn compile_native(profile: &str, out_path: &Path) {
|
||||
.define("SEAL_USE_INTRIN", "ON")
|
||||
.define("SEAL_USE_MSGSL", "OFF")
|
||||
.define("SEAL_USE_ZLIB", "ON")
|
||||
.define("SEAL_USE_ZSTD", "ON")
|
||||
.build();
|
||||
.define("SEAL_USE_ZSTD", "ON");
|
||||
|
||||
setup_macos_cross_compile(&mut builder);
|
||||
|
||||
let dst = builder.build();
|
||||
|
||||
let out_path_suffix = if std::env::var("CARGO_CFG_WINDOWS").is_ok() {
|
||||
profile
|
||||
|
||||
Reference in New Issue
Block a user