Skip to content

Commit

Permalink
Support build for aarch64-pc-windows-msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwsmith committed May 17, 2024
1 parent 4d5e125 commit 14194fc
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 37 additions & 11 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++");
Expand All @@ -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);
Expand Down

0 comments on commit 14194fc

Please sign in to comment.