Skip to content

Commit 5442662

Browse files
authored
Fix build on 32-bit Windows; consolidate CI platform checks (bytecodealliance#9883)
* Fix build on 32-bit Windows; consolidate CI platform checks 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 prtest:platform-checks * Add "join" node in CI * Who really knows yml syntax * Remove dead checks * Fix only-`runtime` build on Windows
1 parent 7c4f0c7 commit 5442662

File tree

5 files changed

+93
-82
lines changed

5 files changed

+93
-82
lines changed

.github/workflows/main.yml

+55-81
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ jobs:
193193
audit: ${{ steps.calculate.outputs.audit }}
194194
preview1-adapter: ${{ steps.calculate.outputs.preview1-adapter }}
195195
run-dwarf: ${{ steps.calculate.outputs.run-dwarf }}
196+
platform-checks: ${{ steps.calculate.outputs.platform-checks }}
196197
steps:
197198
- uses: actions/checkout@v4
198199
- id: calculate
@@ -215,6 +216,8 @@ jobs:
215216
run_full=true
216217
elif grep -q 'prtest:debug' commits.log; then
217218
echo run-dwarf=true >> $GITHUB_OUTPUT
219+
elif grep -q 'prtest:platform-checks' commits.log; then
220+
echo platform-checks=true >> $GITHUB_OUTPUT
218221
fi
219222
if grep -q crates.c-api names.log; then
220223
echo test-capi=true >> $GITHUB_OUTPUT
@@ -256,6 +259,7 @@ jobs:
256259
echo audit=true >> $GITHUB_OUTPUT
257260
echo preview1-adapter=true >> $GITHUB_OUTPUT
258261
echo run-dwarf=true >> $GITHUB_OUTPUT
262+
echo platform-checks=true >> $GITHUB_OUTPUT
259263
fi
260264
261265
# Build all documentation of Wasmtime, including the C API documentation,
@@ -440,29 +444,6 @@ jobs:
440444
- uses: ./.github/actions/cancel-on-failure
441445
if: failure()
442446

443-
# Checks for no_std support, ensure that crates can build on a no_std target
444-
no_std_checks:
445-
name: no_std checks
446-
runs-on: ubuntu-latest
447-
env:
448-
CARGO_NDK_VERSION: 2.12.2
449-
steps:
450-
- uses: actions/checkout@v4
451-
with:
452-
submodules: true
453-
- uses: ./.github/actions/install-rust
454-
455-
- run: rustup target add x86_64-unknown-none
456-
- run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,component-model
457-
- run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model
458-
- run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps
459-
- run: cargo check --target x86_64-unknown-none -p cranelift-control --no-default-features
460-
- run: cargo check --target x86_64-unknown-none -p pulley-interpreter --features encode,decode,disas,interp
461-
462-
# common logic to cancel the entire run if this job fails
463-
- uses: ./.github/actions/cancel-on-failure
464-
if: failure()
465-
466447
# Check that Clippy lints are passing.
467448
clippy:
468449
name: Clippy
@@ -512,10 +493,6 @@ jobs:
512493
env:
513494
CARGO_PROFILE_DEV_DEBUG_ASSERTIONS: false
514495

515-
# Check whether `wasmtime` cross-compiles to x86_64-unknown-freebsd
516-
- run: rustup target add x86_64-unknown-freebsd
517-
- run: cargo check --target x86_64-unknown-freebsd
518-
519496
# Re-vendor all WIT files and ensure that they're all up-to-date by ensuring
520497
# that there's no git changes.
521498
- name: Re-vendor WIT
@@ -531,44 +508,65 @@ jobs:
531508
- uses: ./.github/actions/cancel-on-failure
532509
if: failure()
533510

534-
checks_illumos:
535-
name: Check illumos
536-
runs-on: ubuntu-latest
511+
# Various checks that Wasmtime builds for a variety of platforms. Each
512+
# platform may not include the entire dependency tree and maybe just a few
513+
# features here and there, see the `include` matrix for more details.
514+
platform_checks:
515+
needs: determine
516+
if: needs.determine.outputs.platform-checks
517+
name: "Platform: ${{ matrix.target }}"
518+
runs-on: ${{ matrix.os }}
519+
strategy:
520+
fail-fast: true
521+
matrix:
522+
include:
523+
- target: x86_64-unknown-freebsd
524+
os: ubuntu-latest
525+
test: cargo check
526+
- target: aarch64-pc-windows-msvc
527+
os: windows-latest
528+
test: cargo check
529+
# While we're here testing a windows target also test a feature'd build
530+
# on Windows. Note that this isn't covered by `micro_checks` above since
531+
# that's for unix platforms, not Windows, so include a small check here
532+
# which isn't the full `micro_checks` matrix but hopefully enough bang
533+
# for our buck.
534+
- target: i686-pc-windows-msvc
535+
os: windows-latest
536+
test: cargo check && cargo build -p wasmtime --no-default-features --features runtime
537+
# This is used for general compatibility with `#![no_std]` targets and a
538+
# variety of crates are tested here.
539+
- target: x86_64-unknown-none
540+
os: ubuntu-latest
541+
test: >
542+
cargo check -p wasmtime --no-default-features --features runtime,component-model &&
543+
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model &&
544+
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps &&
545+
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps &&
546+
cargo check -p cranelift-control --no-default-features &&
547+
cargo check -p pulley-interpreter --features encode,decode,disas,interp
548+
# Use `cross` for illumos to have a C compiler/linker available.
549+
- target: x86_64-unknown-illumos
550+
os: ubuntu-latest
551+
cross: true
552+
test: cross build
553+
- target: wasm32-wasip1
554+
os: ubuntu-latest
555+
test: cargo build --no-default-features --features compile,cranelift,all-arch
537556
steps:
538557
- uses: actions/checkout@v4
539558
with:
540559
submodules: true
541560
- uses: ./.github/actions/install-rust
542-
543-
# Check whether `wasmtime` cross-compiles to illumos. We need to use `cross` for this (even for
544-
# cargo check) because of non-Rust dependencies.
561+
- run: rustup target add ${{ matrix.target }}
545562
- name: Install cross
546563
run: |
547564
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
548565
cargo binstall --no-confirm cross
549-
- name: Cross-compile to illumos
550-
run:
551-
cross build --target x86_64-unknown-illumos
552-
553-
# common logic to cancel the entire run if this job fails
554-
- uses: ./.github/actions/cancel-on-failure
555-
if: failure()
556-
557-
# Check whether `wasmtime` cross-compiles to aarch64-pc-windows-msvc
558-
# We don't build nor test it because it lacks trap handling.
559-
# Tracking issue: https://github.com/bytecodealliance/wasmtime/issues/4992
560-
checks_winarm64:
561-
needs: determine
562-
if: needs.determine.outputs.run-full
563-
name: Check Windows ARM64
564-
runs-on: windows-latest
565-
steps:
566-
- uses: actions/checkout@v4
567-
with:
568-
submodules: true
569-
- uses: ./.github/actions/install-rust
570-
- run: rustup target add aarch64-pc-windows-msvc
571-
- run: cargo check -p wasmtime --target aarch64-pc-windows-msvc
566+
if: ${{ matrix.cross }}
567+
- run: ${{ matrix.test }}
568+
env:
569+
CARGO_BUILD_TARGET: ${{ matrix.target }}
572570

573571
# common logic to cancel the entire run if this job fails
574572
- uses: ./.github/actions/cancel-on-failure
@@ -956,27 +954,6 @@ jobs:
956954
- uses: ./.github/actions/cancel-on-failure
957955
if: failure()
958956

959-
960-
build-wasmtime-target-wasm32:
961-
name: Build wasmtime-target-wasm32
962-
if: needs.determine.outputs.run-full
963-
needs: determine
964-
runs-on: ubuntu-latest
965-
steps:
966-
- uses: actions/checkout@v4
967-
with:
968-
submodules: true
969-
- uses: ./.github/actions/install-rust
970-
- run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
971-
- run: cargo build --target wasm32-wasip1 --no-default-features --features compile,cranelift,all-arch
972-
env:
973-
VERSION: ${{ github.sha }}
974-
975-
# common logic to cancel the entire run if this job fails
976-
- uses: ./.github/actions/cancel-on-failure
977-
if: failure()
978-
979-
980957
bench:
981958
needs: determine
982959
if: needs.determine.outputs.run-full
@@ -1171,19 +1148,16 @@ jobs:
11711148
- doc
11721149
- micro_checks
11731150
- fiber_tests
1174-
- no_std_checks
11751151
- clippy
11761152
- monolith_checks
1177-
- checks_illumos
1178-
- checks_winarm64
1153+
- platform_checks
11791154
- bench
11801155
- meta_deterministic_check
11811156
- verify-publish
11821157
- determine
11831158
- miri
11841159
- build-preview1-component-adapter
11851160
- build-preview1-component-adapter-provider
1186-
- build-wasmtime-target-wasm32
11871161
- test-min-platform-example
11881162
- check_js
11891163
if: always()

crates/wasmtime/src/runtime/vm/sys/windows/mod.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
33
use std::cell::Cell;
44

5+
#[cfg(feature = "signals-based-traps")]
56
pub mod mmap;
67
pub mod traphandlers;
7-
pub mod unwind;
88
pub mod vm;
99

10+
#[cfg(target_pointer_width = "32")]
11+
pub mod unwind32;
12+
#[cfg(target_pointer_width = "32")]
13+
pub use unwind32 as unwind;
14+
#[cfg(target_pointer_width = "64")]
15+
pub mod unwind64;
16+
#[cfg(target_pointer_width = "64")]
17+
pub use unwind64 as unwind;
18+
1019
std::thread_local!(static TLS: Cell<*mut u8> = const { Cell::new(std::ptr::null_mut()) });
1120

1221
#[inline]

crates/wasmtime/src/runtime/vm/sys/windows/traphandlers.rs

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ unsafe extern "system" fn exception_handler(exception_info: *mut EXCEPTION_POINT
109109
pc: context.Pc as usize,
110110
fp: context.Anonymous.Anonymous.Fp as usize,
111111
};
112+
} else if #[cfg(target_arch = "x86")] {
113+
let regs = TrapRegisters {
114+
pc: context.Eip as usize,
115+
fp: context.Ebp as usize,
116+
};
112117
} else {
113118
compile_error!("unsupported platform");
114119
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Module for Windows x86 ABI unwind registry.
2+
//!
3+
//! Note that this is not implemented at this time because there is no Cranelift
4+
//! backend foR windows.
5+
6+
use crate::prelude::*;
7+
use std::mem;
8+
9+
pub enum UnwindRegistration {}
10+
11+
impl UnwindRegistration {
12+
#[allow(missing_docs)]
13+
pub const SECTION_NAME: &'static str = ".pdata";
14+
15+
#[allow(missing_docs)]
16+
pub unsafe fn new(
17+
_base_address: *const u8,
18+
_unwind_info: *const u8,
19+
_unwind_len: usize,
20+
) -> Result<UnwindRegistration> {
21+
bail!("unwind registration unimplemented on i686 windows")
22+
}
23+
}

0 commit comments

Comments
 (0)