Merge pull request #78 from signalapp/aarch64-cross-compilation
Add minimal cross-compilation support for Windows and AArch64 Linux
This commit is contained in:
commit
3059ba6e10
|
|
@ -141,11 +141,13 @@ const BORING_SSL_PATH: &str = "deps/boringssl";
|
||||||
fn get_boringssl_cmake_config() -> cmake::Config {
|
fn get_boringssl_cmake_config() -> cmake::Config {
|
||||||
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||||
let os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
let os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||||
|
let host = std::env::var("HOST").unwrap();
|
||||||
|
let target = std::env::var("TARGET").unwrap();
|
||||||
let pwd = std::env::current_dir().unwrap();
|
let pwd = std::env::current_dir().unwrap();
|
||||||
|
|
||||||
let mut boringssl_cmake = cmake::Config::new(BORING_SSL_PATH);
|
let mut boringssl_cmake = cmake::Config::new(BORING_SSL_PATH);
|
||||||
|
if host != target {
|
||||||
// Add platform-specific parameters.
|
// Add platform-specific parameters for cross-compilation.
|
||||||
match os.as_ref() {
|
match os.as_ref() {
|
||||||
"android" => {
|
"android" => {
|
||||||
// We need ANDROID_NDK_HOME to be set properly.
|
// We need ANDROID_NDK_HOME to be set properly.
|
||||||
|
|
@ -165,8 +167,6 @@ fn get_boringssl_cmake_config() -> cmake::Config {
|
||||||
// 21 is the minimum level tested. You can give higher value.
|
// 21 is the minimum level tested. You can give higher value.
|
||||||
boringssl_cmake.define("ANDROID_NATIVE_API_LEVEL", "21");
|
boringssl_cmake.define("ANDROID_NATIVE_API_LEVEL", "21");
|
||||||
boringssl_cmake.define("ANDROID_STL", "c++_shared");
|
boringssl_cmake.define("ANDROID_STL", "c++_shared");
|
||||||
|
|
||||||
boringssl_cmake
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"ios" => {
|
"ios" => {
|
||||||
|
|
@ -186,16 +186,20 @@ fn get_boringssl_cmake_config() -> cmake::Config {
|
||||||
};
|
};
|
||||||
|
|
||||||
let cflag = format!("{} {}", bitcode_cflag, target_cflag);
|
let cflag = format!("{} {}", bitcode_cflag, target_cflag);
|
||||||
|
|
||||||
boringssl_cmake.define("CMAKE_ASM_FLAGS", &cflag);
|
boringssl_cmake.define("CMAKE_ASM_FLAGS", &cflag);
|
||||||
boringssl_cmake.cflag(&cflag);
|
boringssl_cmake.cflag(&cflag);
|
||||||
|
|
||||||
boringssl_cmake
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
"windows" => {
|
||||||
// Configure BoringSSL for building on 32-bit non-windows platforms.
|
if host.contains("windows") {
|
||||||
if arch == "x86" && os != "windows" {
|
// BoringSSL's CMakeLists.txt isn't set up for cross-compiling using Visual Studio.
|
||||||
|
// Disable assembly support so that it at least builds.
|
||||||
|
boringssl_cmake.define("OPENSSL_NO_ASM", "YES");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"linux" => match arch.as_str() {
|
||||||
|
"x86" => {
|
||||||
boringssl_cmake.define(
|
boringssl_cmake.define(
|
||||||
"CMAKE_TOOLCHAIN_FILE",
|
"CMAKE_TOOLCHAIN_FILE",
|
||||||
pwd.join(BORING_SSL_PATH)
|
pwd.join(BORING_SSL_PATH)
|
||||||
|
|
@ -203,10 +207,25 @@ fn get_boringssl_cmake_config() -> cmake::Config {
|
||||||
.as_os_str(),
|
.as_os_str(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
"aarch64" => {
|
||||||
|
boringssl_cmake.define(
|
||||||
|
"CMAKE_TOOLCHAIN_FILE",
|
||||||
|
pwd.join("cmake/aarch64-linux.cmake").as_os_str(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
eprintln!(
|
||||||
|
"warning: no toolchain file configured by boring-sys for {}",
|
||||||
|
target
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boringssl_cmake
|
boringssl_cmake
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verify that the toolchains match https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp3678.pdf
|
/// Verify that the toolchains match https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp3678.pdf
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||||
|
# Rely on environment variables to set the compiler and include paths.
|
||||||
Loading…
Reference in New Issue