From 14194fc59716cd4cd5ce9b5d9eb92ba89690db94 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Tue, 23 Apr 2024 17:04:00 -0400 Subject: [PATCH] Support build for aarch64-pc-windows-msvc --- .github/workflows/cross.yml | 18 +++++++++++ aws-lc-sys/builder/cmake_builder.rs | 48 ++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 80481e23afc..edf806fcab2 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -123,3 +123,21 @@ jobs: run: cargo test -p aws-lc-rs --target x86_64-pc-windows-gnu --features bindgen - name: Release test on `x86_64-pc-windows-gnu` run: cargo test -p aws-lc-rs --release --target x86_64-pc-windows-gnu --features bindgen + + aws-lc-rs-windows-arm64: + if: github.repository_owner == 'aws' + name: aarch64-pc-windows-msvc + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: Install ninja-build tool + uses: seanmiddleditch/gha-setup-ninja@v4 + - uses: dtolnay/rust-toolchain@master + id: toolchain + with: + toolchain: stable + target: aarch64-pc-windows-msvc + - name: Build for `aarch64-pc-windows-msvc` + run: cargo build -p aws-lc-rs --target aarch64-pc-windows-msvc --features bindgen \ No newline at end of file diff --git a/aws-lc-sys/builder/cmake_builder.rs b/aws-lc-sys/builder/cmake_builder.rs index 4b3e4739a35..764efa68fce 100644 --- a/aws-lc-sys/builder/cmake_builder.rs +++ b/aws-lc-sys/builder/cmake_builder.rs @@ -17,6 +17,10 @@ pub(crate) struct CmakeBuilder { output_lib_type: OutputLibType, } +fn test_clang_cl_command() -> bool { + execute_command("clang-cl".as_ref(), &["--version".as_ref()]).status +} + fn test_ninja_command() -> bool { execute_command("ninja".as_ref(), &["--version".as_ref()]).status || execute_command("ninja-build".as_ref(), &["--version".as_ref()]).status @@ -139,6 +143,20 @@ impl CmakeBuilder { cmake_cfg.generator("Ninja"); } + if target_os() == "windows" && target_arch() == "aarch64" && target_env() == "msvc" { + cmake_cfg.generator("Ninja"); + cmake_cfg.define("CMAKE_C_COMPILER", "clang-cl"); + cmake_cfg.define("CMAKE_CXX_COMPILER", "clang-cl"); + cmake_cfg.define("CMAKE_ASM_COMPILER", "clang-cl"); + #[cfg(target_arch != "aarch64")] + { + // Only needed when cross-compiling + cmake_cfg.define("CMAKE_C_COMPILER_TARGET", "arm64-pc-windows-msvc"); + cmake_cfg.define("CMAKE_CXX_COMPILER_TARGET", "arm64-pc-windows-msvc"); + cmake_cfg.define("CMAKE_ASM_COMPILER_TARGET", "arm64-pc-windows-msvc"); + } + } + if cfg!(feature = "asan") { env::set_var("CC", "clang"); env::set_var("CXX", "clang++"); @@ -161,17 +179,25 @@ impl crate::Builder for CmakeBuilder { fn check_dependencies(&self) -> Result<(), String> { let mut missing_dependency = false; - if target_os() == "windows" - && target_arch() == "x86_64" - && !test_nasm_command() - && !is_no_asm() - { - eprintln!( - "Consider setting `AWS_LC_SYS_NO_ASM` in the environment for development builds.\ - See User Guide about the limitations: https://aws.github.io/aws-lc-rs/index.html" - ); - eprintln!("Missing dependency: nasm"); - missing_dependency = true; + if target_os() == "windows" { + if target_arch() == "x86_64" && !test_nasm_command() && !is_no_asm() { + eprintln!( + "Consider setting `AWS_LC_SYS_NO_ASM` in the environment for development builds.\ + See User Guide about the limitations: https://aws.github.io/aws-lc-rs/index.html" + ); + eprintln!("Missing dependency: nasm"); + missing_dependency = true; + } + if target_arch() == "aarch64" && target_env() == "msvc" { + if !test_ninja_command() { + eprintln!("Missing dependency: ninja"); + missing_dependency = true; + } + if !test_clang_cl_command() { + eprintln!("Missing dependency: clang-cl"); + missing_dependency = true; + } + } } if let Some(cmake_cmd) = find_cmake_command() { env::set_var("CMAKE", cmake_cmd);