Skip to content

[integration] static fast-interpreter/P2 component profile + multi-module hardening#9

Draft
matthargett wants to merge 2676 commits into
dev/cm_wasip2_completefrom
integration/cm-wasip2-all
Draft

[integration] static fast-interpreter/P2 component profile + multi-module hardening#9
matthargett wants to merge 2676 commits into
dev/cm_wasip2_completefrom
integration/cm-wasip2-all

Conversation

@matthargett

@matthargett matthargett commented Jun 14, 2026

Copy link
Copy Markdown
Member

Purpose

This is the WAMR integration line for the statically linked snqr Apple host. The target guest format is component-model wasm32-wasip2 on the stable WASI Preview 2 0.2.6 package set.

Existing core-Wasm guests and their raw import aliases remain available only for parity validation while canonical component bindings are adopted. Those legacy guests are not described as components.

Static Apple product profile

The checked profile builds a single full-LTO static archive with:

INTERP=1, FAST_INTERP=1, DEBUG_INTERP=0, MINI_LOADER=0
AOT=0, JIT=0, FAST_JIT=0, WAMR_COMPILER=0
COMPONENT_MODEL=1, LIBC_WASI_P2=1
LIBC_WASI=0, LIBC_UVWASI=0, LIBC_BUILTIN=0
THREAD_MGR=1
SHARED_MEMORY=0, LIB_PTHREAD=0, LIB_WASI_THREADS=0
MULTI_MODULE=1
SIMD=1, RELAXED_SIMD=1, EXCE_HANDLING=1, REF_TYPES=1
-O3, -Werror, -flto=full

All product host interfaces and component dependencies are statically linked. Dynamically loaded components remain forbidden. MULTI_MODULE=1 is retained solely for existing core-Wasm compatibility guests and their helper modules during the parity sweep; it is not a component plug-in system.

Because the shipping profile enables the core-module registry for those legacy helpers, the ownership hardening is part of the product contract: the registry owns copied names, module-reader buffers remain runtime-owned until safe destruction, callers have an explicit unregister/ownership transfer, and component-owned embedded core modules are immediately removed from the global registry.

Host-owned execution threads remain supported through the thread manager. Guest shared memory, guest pthreads, and WASI threads remain disabled. This permits the main component interpreter and separately started/stopped WebAudio worker or audio-node execution contexts without introducing dynamically loadable WASI components.

Integrated component and Preview 2 work

  • Preview 2 can be built without Preview 1, while legacy component defaults still select Preview 2.
  • Built-in standard WASI interfaces declare the implemented 0.2.6 package version and accept compatible patch-level imports in the correct direction.
  • Callback-scoped canonical-memory access and exact callback-state queries fail closed outside the active host callback.
  • Prepared flattened export calls provide reusable scratch storage and explicit post-return handling for allocation-free steady-state host calls.
  • Raw native component dispatch preserves and restores callback context.
  • Embedded core-module ownership is transferred back to the component tree so repeated component load and unload does not accumulate registry entries.
  • Fast-interpreter relaxed SIMD, exception handling, component parsing, canonical ABI, Apple portability, and failure cleanup remain integrated from the earlier stack.
  • Public API documentation uses the actual exported parameter names.

Focused Airbus-lineage changes remain split for review in airbus-forks#10 through bytecodealliance#17. The current-upstream registry lifetime stack is staged separately in review/multi-module-unregister-unload for upstream triage.

Local product proof

Final head: f0c9b78d8cd11ad52b586f0cdfafc330c0d83396.

  • The current dev/cm_wasip2_complete base was merged without changing the tested integration tree, preserving every focused commit.
  • Signed macOS and iOS Release builds completed from the static fast-interpreter profile.
  • An exact Rust wasm32-wasip2 command component ran with host=0 guest=0 on the local Mac and a physical iPhone XS.
  • The Dodeca guest rendered visibly on both targets and was verified with screenshots from each device.
  • Release archive verification passed for arm64, Preview 2-only component support, fast-interpreter-only engine selection, full LTO, and MULTI_MODULE=1.
  • Post-merge component parser tests passed 58/58; component execution tests passed 13/13.
  • Repeated component load/instantiate/add/deinstantiate/unload passed all eight cycles without retained embedded modules.
  • Registry ownership tests passed under macOS ASan and Linux GCC ASan with leak detection; static analysis reported no findings.
  • The raw WAMR bit-crusher plus WebAudio worker start/stop lifecycle sanitizer passed.
  • Clang-format 14 coding-guideline checks passed for the focused and integration commits.
  • The consolidated Linux unit job passed 867/867, including explicit rejection of all seven checked-in rustc 1.94.1 / WASI 0.2.9 fixtures, null-module unload, and the formerly aborting unknown-module-type case.

CI policy for this update

The product batch was pushed only after the local component, sanitizer, static-analysis, LTO, Mac, and physical-device proof was green. One merge-only update resolved the current base conflict after the same parser, execution, and Apple archive checks passed on the merge head.

The first automatic matrix exposed two integration-specific unit failures: the multi-module ownership change had made wasm_runtime_unload(NULL) unsafe, and seven older checked-in Rust test binaries actually require WASI 0.2.9. The null path is a no-op again with a direct regression test; the newer binaries are now honest negative compatibility cases without weakening the 0.2.6 ceiling. Both fixes were locally validated and pushed together once. The null guard is also staged for current-upstream review on fix/null-module-unload, and the Airbus-lineage compatibility/error-reporting changes are included in airbus-forks#17.

A separate NuttX failure was hosted-runner disk exhaustion during checkout; configure and build never ran, the identical matrix slot was green previously, and no source workaround was added. No full hosted workflow was manually dispatched or re-run.

Final hosted result

The final automatic batch completed successfully without a manual dispatch or rerun: 11/11 workflows passed, representing 504/504 successful check records (470/470 distinct displayed check names). There are no failed, cancelled, skipped, queued, or pending checks on f0c9b78d8cd11ad52b586f0cdfafc330c0d83396.

lum1n0us and others added 30 commits December 1, 2025 17:10
…codealliance#4690)

* feat: add support for checking unsupported build configurations
* docs: improve clarity and formatting in build_wamr.md
* feat: add check for unsupported SHARED_HEAP + FAST_JIT configuration and update documentation warning
* feat: disable default SIMD setting for 64-bit platform in CMake configuration
* feat: update Android and macOS workflows to handle SIMD support in classic interp mode
* feat: update SGX compilation workflow to handle unsupported FAST_JIT and classic interp mode without SIMD support
* feat: enhance check for unsupported CLASSIC_INTERP configurations
* feat: disable fast interpreter for shared heap tests and update unsupported features test library
* feat: enhance unsupported combination checks and update build configurations for JIT and SIMD
* In regression tests, use llvm-jit and fast-jit to replace multi-tier-jit + running mode. Multi-tier-jit contains both fast-jit and llvm-jit. Fast-jit doesn't support SIMD, but llvm-jit does. So, should multi-tier-jit support SIMD? My answer is NO.
  - The regular form of multi-tier-jit uses fast-jit as tier1 and llvm-jit as
    tier2. Therefore, if fast-jit doesn't support SIMD, the entire multi-tier
    doesn't support SIMD either.
  - `--fast-jit` and `--llvm-jit` of multi-tier-jit  should adhere to the global
    limitations of multi-tier-jit.
* Explicitly specify SIMD, MULTI_MODULE, and their unsupported running modes.
- SIMD and Ref. types are enabled by default on linux and darwin. So remove duplicate feature testing from CI
- Apply new configuration for wasm-c-api compilation commands
…nce#4738)

Bumps [actions/checkout](https://github.com/actions/checkout) from 5.0.1 to 6.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](actions/checkout@v5.0.1...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ealliance#4739)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.5 to 4.31.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](github/codeql-action@v4.31.5...v4.31.6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…nce#4747)

Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.0 to 6.0.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](actions/checkout@v6...v6.0.1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ealliance#4746)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.6 to 4.31.7.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](github/codeql-action@v4.31.6...v4.31.7)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* add new runtime api for reset shared heap(chain)
* add new unit test case
…ealliance#4757)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.7 to 4.31.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](github/codeql-action@v4.31.7...v4.31.8)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…dealliance#4756)

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5.0.0 to 6.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Ensure --addr-pool mask accepts numbers only
* Add mask validation
* Replace mask assignment position
* Use a thread-safe function and free allocated memory

Co-authored-by: liang.he <liang.he@intel.com>
…ealliance#4767)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.8 to 4.31.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](github/codeql-action@v4.31.8...v4.31.9)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix: update macOS workflow configurations to use macos-15 and macos-15-intel
* fix: remove unsupported build options for macOS workflows
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
* fix: Wrong compiler parameter on MSVC
* refactor: Move gcc flags to common build script.
* refactor: Add both C/CXX flags
The goal is to keep the devcontainer image minimal and its build time as fast as possible.
- Remove all rarely used tools.
- Change the base image to the latest template.
- Synchronize the WASI-SDK and WABT versions with those used by the CI.

Add libzstd for LLVM linking
…tecodealliance#4750)

* docs: update tiered support documentation with detailed tier definitions and feature classifications and improved compilation flags and links for clarity
* update tiered support documentation to clarify feature support levels and enhance readability
  - Revised descriptions for Tier A to specify that features have been used in products.
  - Reformatted notes on testing, maintenance, and support definitions for better clarity.
  - Added a new section for privileged features with detailed explanations.
  - Updated tables for Tier A, Tier B, and Tier C to include additional targets and compilation flags.
* fix: clear exec_env_tls when destroying exec_env

When an exec_env is destroyed, check if it matches the current thread's
exec_env_tls and clear it to avoid dangling pointer issues.

Without this fix, in daemon-style execution where the same thread runs
multiple WASM modules sequentially (like Cloudflare Workers), the
exec_env_tls can point to freed memory after an exec_env is destroyed,
causing crashes on subsequent executions when the signal handler tries
to access it.

This is critical for AOT mode with hardware bounds checking enabled,
where signal handlers rely on exec_env_tls to handle SIGSEGV properly.

* test(exec_env): add reproducer for exec_env_tls dangling pointer bug

Add test case that reproduces the bug where exec_env_tls is not cleared
on early return paths in invoke_native_with_hw_bound_check.

The test triggers native stack overflow check failure, which causes
wasm_runtime_call_wasm to return early after setting exec_env_tls but
without clearing it. This leaves exec_env_tls pointing to a destroyed
exec_env, causing subsequent calls to fail with "invalid exec env".

Test confirms the fix in wasm_exec_env_destroy correctly clears
exec_env_tls when destroying the exec_env it points to.

* fix(runtime): clear exec_env_tls on early return from stack overflow check

Move the fix to clear exec_env_tls at the source - in the early return
path of invoke_native_with_hw_bound_check when native stack overflow
check fails.
* fix(aot): reserve x18 register on macOS ARM64

Apple reserves CPU register x18 for TLS on ARM64. When generating AOT
code for aarch64 on macOS, LLVM may use x18, causing crashes when the
AOT code runs on macOS ARM64 (M1/M2/M3).

This patch:
1. Detects darwin/macho ABI and sets correct vendor string
2. Detects darwin/apple in default triple for platform detection
3. Adds +reserve-x18 to LLVM target features for aarch64 on macOS

The fix only applies when compiling on macOS ARM64 hosts, ensuring
generated AOT code is compatible with Apple's platform requirements.

* test(aot): add x18 register reservation test for macOS ARM64

Add a standalone test to verify that the +reserve-x18 LLVM flag is
correctly applied when compiling AOT for macOS ARM64.

On macOS ARM64, x18 is reserved by Apple for TLS (Thread Local Storage).
Without the +reserve-x18 flag, LLVM may generate code that uses x18,
causing random SIGSEGV crashes (~80% crash rate in testing).

The test:
- Creates a WASM module with 24 local variables to stress register allocation
- Compiles to AOT with -O3 optimization (which would use x18 without the fix)
- Runs 1000 iterations to verify no crashes occur
- Only runs on macOS ARM64 (skipped on other platforms)

Test results:
- Without fix: 82/100 crash rate
- With fix: 0/100 crash rate (1000 iterations verified)
…#4788)

correct boundary check in check_dynamic_offset_pop when dynamic_offset is 0. When dynamic_offset = 0, check_dynamic_offset_pop will always return true, which may wrongly update dynamic_offset.
also include a typo fix in SET_OPERAND_REF

Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
…dealliance#4794)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.9 to 4.31.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](github/codeql-action@v4.31.9...v4.31.10)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Comment thread core/iwasm/common/component-model/wasm_component_runtime.c Fixed
Comment thread core/iwasm/interpreter/wasm_interp_fast.c Fixed
elems[i] = wit_resource_ctor(reps[i]);
if (!elems[i]) {
while (i > 0) {
free_wit_value(elems[--i]);
@matthargett
matthargett force-pushed the integration/cm-wasip2-all branch from 2227ab6 to dc9a27d Compare July 11, 2026 08:43
@matthargett
matthargett marked this pull request as draft July 11, 2026 11:48
@matthargett matthargett changed the title [integration] component/fast-interp stack + Apple App Store interpreter gate [integration] static fast-interpreter/P2 component profile + multi-module hardening Jul 11, 2026
raw_cx.borrow_scope_type = BORROW_SCOPE_NONE;
raw_cx.borrow_scope.task = NULL;
exec_env->memory = raw_memory;
exec_env->cx = &raw_cx;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.