Skip to content

Commit

Permalink
Fix build on 32-bit Windows; consolidate CI platform checks
Browse files Browse the repository at this point in the history
This commit fixes the build of the `wasmtime` crate and CLI on 32-bit
Windows. This required adding some extra bits for trap handling and a
stub for "unimplemented" for unwind information registration. This then
additionally refactored our CI configuration to place all of the
cross-compile checks in one matrix instead of spread out across a few
jobs.

Closes bytecodealliance#9882
  • Loading branch information
alexcrichton committed Dec 20, 2024
1 parent d621b45 commit 8372018
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 65 deletions.
113 changes: 49 additions & 64 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ jobs:
audit: ${{ steps.calculate.outputs.audit }}
preview1-adapter: ${{ steps.calculate.outputs.preview1-adapter }}
run-dwarf: ${{ steps.calculate.outputs.run-dwarf }}
platform-checks: ${{ steps.calculate.outputs.platform-checks }}
steps:
- uses: actions/checkout@v4
- id: calculate
Expand All @@ -215,6 +216,8 @@ jobs:
run_full=true
elif grep -q 'prtest:debug' commits.log; then
echo run-dwarf=true >> $GITHUB_OUTPUT
elif grep -q 'prtest:platform-checks' commits.log; then
echo platform-checks=true >> $GITHUB_OUTPUT
fi
if grep -q crates.c-api names.log; then
echo test-capi=true >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -256,6 +259,7 @@ jobs:
echo audit=true >> $GITHUB_OUTPUT
echo preview1-adapter=true >> $GITHUB_OUTPUT
echo run-dwarf=true >> $GITHUB_OUTPUT
echo platform-checks=true >> $GITHUB_OUTPUT
fi
# Build all documentation of Wasmtime, including the C API documentation,
Expand Down Expand Up @@ -452,13 +456,6 @@ jobs:
submodules: true
- uses: ./.github/actions/install-rust

- run: rustup target add x86_64-unknown-none
- run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,component-model
- run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model
- run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps
- run: cargo check --target x86_64-unknown-none -p cranelift-control --no-default-features
- run: cargo check --target x86_64-unknown-none -p pulley-interpreter --features encode,decode,disas,interp

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
if: failure()
Expand Down Expand Up @@ -512,10 +509,6 @@ jobs:
env:
CARGO_PROFILE_DEV_DEBUG_ASSERTIONS: false

# Check whether `wasmtime` cross-compiles to x86_64-unknown-freebsd
- run: rustup target add x86_64-unknown-freebsd
- run: cargo check --target x86_64-unknown-freebsd

# Re-vendor all WIT files and ensure that they're all up-to-date by ensuring
# that there's no git changes.
- name: Re-vendor WIT
Expand All @@ -531,44 +524,60 @@ jobs:
- uses: ./.github/actions/cancel-on-failure
if: failure()

checks_illumos:
name: Check illumos
runs-on: ubuntu-latest
# Various checks that Wasmtime builds for a variety of platforms. Each
# platform may not include the entire dependency tree and maybe just a few
# features here and there, see the `include` matrix for more details.
platform_checks:
needs: determine
if: needs.determine.outputs.platform-checks
name: Platform: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-unknown-freebsd
os: ubuntu-latest
test: cargo check
- target: aarch64-pc-windows-msvc
os: windows-latest
test: cargo check
- target: i686-pc-windows-msvc
os: windows-latest
test: cargo check
# This is used for general compatibility with `#![no_std]` targets and a
# variety of crates are tested here.
- target: x86_64-unknown-none
os: ubuntu-latest
test: >
cargo check -p wasmtime --no-default-features --features runtime,component-model &&
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model &&
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps &&
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps &&
cargo check -p cranelift-control --no-default-features &&
cargo check -p pulley-interpreter --features encode,decode,disas,interp
# Use `cross` for illumos to have a C compiler/linker available.
- target: x86_64-unknown-illumos
os: ubuntu-latest
cross: true
test: cross build
- target: wasm32-wasip1
os: ubuntu-latest
test: cargo build --no-default-features --features compile,cranelift,all-arch
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-rust

# Check whether `wasmtime` cross-compiles to illumos. We need to use `cross` for this (even for
# cargo check) because of non-Rust dependencies.
- run: rustup target add ${{ matrix.target }}
- name: Install cross
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --no-confirm cross
- name: Cross-compile to illumos
run:
cross build --target x86_64-unknown-illumos

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
if: failure()

# 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:
needs: determine
if: needs.determine.outputs.run-full
name: Check Windows ARM64
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add aarch64-pc-windows-msvc
- run: cargo check -p wasmtime --target aarch64-pc-windows-msvc
if: ${{ matrix.cross }}
- run: ${{ matrix.test }}
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
Expand Down Expand Up @@ -956,27 +965,6 @@ jobs:
- uses: ./.github/actions/cancel-on-failure
if: failure()


build-wasmtime-target-wasm32:
name: Build wasmtime-target-wasm32
if: needs.determine.outputs.run-full
needs: determine
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
- run: cargo build --target wasm32-wasip1 --no-default-features --features compile,cranelift,all-arch
env:
VERSION: ${{ github.sha }}

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
if: failure()


bench:
needs: determine
if: needs.determine.outputs.run-full
Expand Down Expand Up @@ -1174,16 +1162,13 @@ jobs:
- no_std_checks
- clippy
- monolith_checks
- checks_illumos
- checks_winarm64
- bench
- meta_deterministic_check
- verify-publish
- determine
- miri
- build-preview1-component-adapter
- build-preview1-component-adapter-provider
- build-wasmtime-target-wasm32
- test-min-platform-example
- check_js
if: always()
Expand Down
10 changes: 9 additions & 1 deletion crates/wasmtime/src/runtime/vm/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ use std::cell::Cell;

pub mod mmap;
pub mod traphandlers;
pub mod unwind;
pub mod vm;

#[cfg(target_pointer_width = "32")]
pub mod unwind32;
#[cfg(target_pointer_width = "32")]
pub use unwind32 as unwind;
#[cfg(target_pointer_width = "64")]
pub mod unwind64;
#[cfg(target_pointer_width = "64")]
pub use unwind64 as unwind;

std::thread_local!(static TLS: Cell<*mut u8> = const { Cell::new(std::ptr::null_mut()) });

#[inline]
Expand Down
5 changes: 5 additions & 0 deletions crates/wasmtime/src/runtime/vm/sys/windows/traphandlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ unsafe extern "system" fn exception_handler(exception_info: *mut EXCEPTION_POINT
pc: context.Pc as usize,
fp: context.Anonymous.Anonymous.Fp as usize,
};
} else if #[cfg(target_arch = "x86")] {
let regs = TrapRegisters {
pc: context.Eip as usize,
fp: context.Ebp as usize,
};
} else {
compile_error!("unsupported platform");
}
Expand Down
23 changes: 23 additions & 0 deletions crates/wasmtime/src/runtime/vm/sys/windows/unwind32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Module for Windows x86 ABI unwind registry.
//!
//! Note that this is not implemented at this time because there is no Cranelift
//! backend foR windows.
use crate::prelude::*;
use std::mem;

pub enum UnwindRegistration {}

impl UnwindRegistration {
#[allow(missing_docs)]
pub const SECTION_NAME: &'static str = ".pdata";

#[allow(missing_docs)]
pub unsafe fn new(
_base_address: *const u8,
_unwind_info: *const u8,
_unwind_len: usize,
) -> Result<UnwindRegistration> {
bail!("unwind registration unimplemented on i686 windows")
}
}

0 comments on commit 8372018

Please sign in to comment.