From 21fe2b5b1a60840d73f3ded07f38a7dbbaa50a09 Mon Sep 17 00:00:00 2001 From: Yuyi Wang Date: Sat, 1 Oct 2022 13:53:54 +0800 Subject: [PATCH 1/5] Make wasmtime build for windows-aarch64 --- crates/jit/src/unwind.rs | 3 +++ crates/jit/src/unwind/winx64.rs | 2 +- crates/runtime/src/traphandlers/windows.rs | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/jit/src/unwind.rs b/crates/jit/src/unwind.rs index eedb52e14331..3de3074201ba 100644 --- a/crates/jit/src/unwind.rs +++ b/crates/jit/src/unwind.rs @@ -5,6 +5,9 @@ cfg_if::cfg_if! { } else if #[cfg(all(windows, target_arch = "x86"))] { mod winx32; pub use self::winx32::*; + } else if #[cfg(all(windows, target_arch = "aarch64"))] { + mod winx64; + pub use self::winx64::*; } else if #[cfg(unix)] { mod systemv; pub use self::systemv::*; diff --git a/crates/jit/src/unwind/winx64.rs b/crates/jit/src/unwind/winx64.rs index 9ddbcfca9a73..23ccbe285c39 100644 --- a/crates/jit/src/unwind/winx64.rs +++ b/crates/jit/src/unwind/winx64.rs @@ -21,7 +21,7 @@ impl UnwindRegistration { if RtlAddFunctionTable( unwind_info as *mut _, (unwind_len / unit_len) as u32, - base_address as u64, + base_address as _, ) == 0 { bail!("failed to register function table"); diff --git a/crates/runtime/src/traphandlers/windows.rs b/crates/runtime/src/traphandlers/windows.rs index 8931503fec81..c76c1b0c068f 100644 --- a/crates/runtime/src/traphandlers/windows.rs +++ b/crates/runtime/src/traphandlers/windows.rs @@ -58,6 +58,9 @@ unsafe extern "system" fn exception_handler(exception_info: *mut EXCEPTION_POINT } else if #[cfg(target_arch = "x86")] { let ip = (*(*exception_info).ContextRecord).Eip as *const u8; let fp = (*(*exception_info).ContextRecord).Ebp as usize; + } else if #[cfg(target_arch = "aarch64")] { + let ip = (*(*exception_info).ContextRecord).Pc as *const u8; + let fp = (*(*exception_info).ContextRecord).Anonymous.Anonymous.Fp as usize; } else { compile_error!("unsupported platform"); } From 1d12f248810897ba79b915fabde2baf58f3d8723 Mon Sep 17 00:00:00 2001 From: Yuyi Wang Date: Sat, 1 Oct 2022 13:57:06 +0800 Subject: [PATCH 2/5] Add check for win arm64 build. --- .github/workflows/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f4fab40829a..92125a9d33c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -183,6 +183,19 @@ jobs: - run: cargo check --target wasm32-unknown-emscripten -p wasi-common - run: cargo check --target armv7-unknown-linux-gnueabihf -p wasi-common + # Check whether `wasmtime` cross-compiles to aarch64-pc-windows-msvc + checks: + name: Check Windows ARM64 + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - uses: ./.github/actions/install-rust + + # Check some feature combinations of the `wasmtime` crate + - run: cargo check -p wasmtime --target aarch64-pc-windows-msvc + fuzz_targets: name: Fuzz Targets runs-on: ubuntu-latest From e05245540bae375918cc3868335dc7fca3cb8aac Mon Sep 17 00:00:00 2001 From: Yuyi Wang Date: Sat, 1 Oct 2022 14:01:34 +0800 Subject: [PATCH 3/5] Fix checks for winarm64 key in workflows. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92125a9d33c0..3509d092321a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -184,7 +184,7 @@ jobs: - run: cargo check --target armv7-unknown-linux-gnueabihf -p wasi-common # Check whether `wasmtime` cross-compiles to aarch64-pc-windows-msvc - checks: + checks_winarm64: name: Check Windows ARM64 runs-on: windows-latest steps: From c3706421d5dd8232de8bb1a8855086f5677552d7 Mon Sep 17 00:00:00 2001 From: Yuyi Wang Date: Sat, 1 Oct 2022 14:05:19 +0800 Subject: [PATCH 4/5] Add target in windows arm64 build. --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3509d092321a..7ba038bce94d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -192,8 +192,7 @@ jobs: with: submodules: true - uses: ./.github/actions/install-rust - - # Check some feature combinations of the `wasmtime` crate + - run: rustup target add aarch64-pc-windows-msvc - run: cargo check -p wasmtime --target aarch64-pc-windows-msvc fuzz_targets: From 9af384b91f946a2f37e1224bf64f768657eccfef Mon Sep 17 00:00:00 2001 From: Yuyi Wang Date: Sat, 1 Oct 2022 21:51:21 +0800 Subject: [PATCH 5/5] Add tracking issue for Windows ARM64 trap handling --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ba038bce94d..a3c05f999043 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -184,6 +184,8 @@ jobs: - run: cargo check --target armv7-unknown-linux-gnueabihf -p wasi-common # Check whether `wasmtime` cross-compiles to aarch64-pc-windows-msvc + # We don't build nor test it because it lacks trap handling. + # Tracking issue: https://github.com/bytecodealliance/wasmtime/issues/4992 checks_winarm64: name: Check Windows ARM64 runs-on: windows-latest