Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support build for aarch64-pc-windows-msvc #406

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(not(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
Loading