mirror of
https://github.com/Z3Prover/z3
synced 2026-07-17 04:25:44 +00:00
Add single-threaded WASM build for z3-solver without SharedArrayBuffer
- Add makeCCSinglethreadWrapper() in make-cc-wrapper.ts that generates
synchronous async wrappers using EM_ASM instead of threads +
MAIN_THREAD_ASYNC_EM_ASM. Refactor shared error-handler code into a
SHARED_ERROR_HANDLERS constant used by both variants.
- Add build-wasm-singlethread.ts: new build script that compiles a
separate libz3.a (in build-singlethread/) and z3-built-singlethread.js
without -pthread / USE_PTHREADS=1. Uses -DSINGLE_THREAD -DPOLLING_TIMER
and ALLOW_MEMORY_GROWTH instead of a fixed 2 GB SharedArrayBuffer.
- Add src/node-singlethread.ts and src/browser-singlethread.ts entry
points. Browser variant reads initZ3SingleThread from global scope
(load z3-built-singlethread.js via importScripts in a Web Worker).
- Add tests for both new entry points (node-singlethread.test.ts,
browser-singlethread.test.ts).
- Update package.json: add build:wasm:singlethread script; add exports
map so users can do import { init } from 'z3-solver/singlethread'.
- Update PUBLISHED_README.md: document the single-threaded variant,
explain when to use it (no COOP/COEP headers), and provide a Web
Worker usage example.
- Update wasm.yml CI: add check-singlethread parallel job.
- Update wasm-release.yml: build single-threaded artifact before publish.
- Guard scoped_timer.cpp with #if defined(SINGLE_THREAD) &&
!defined(__EMSCRIPTEN_PTHREADS__) so that thread-based timer creation
is skipped in single-threaded Emscripten builds (POLLING_TIMER covers
the primary cancel_eh<reslimit> use-case).
This commit is contained in:
parent
b964e1a0e8
commit
66b0f58e23
11 changed files with 419 additions and 22 deletions
7
.github/workflows/wasm-release.yml
vendored
7
.github/workflows/wasm-release.yml
vendored
|
|
@ -48,7 +48,7 @@ jobs:
|
|||
- name: Build TypeScript
|
||||
run: npm run build:ts
|
||||
|
||||
- name: Build wasm
|
||||
- name: Build wasm (threaded)
|
||||
run: |
|
||||
emsdk install ${EM_VERSION}
|
||||
emsdk activate ${EM_VERSION}
|
||||
|
|
@ -57,6 +57,11 @@ jobs:
|
|||
which clang++
|
||||
npm run build:wasm
|
||||
|
||||
- name: Build wasm (single-threaded)
|
||||
run: |
|
||||
source $(dirname $(which emsdk))/emsdk_env.sh
|
||||
npm run build:wasm:singlethread
|
||||
|
||||
- name: Test
|
||||
run: npm test
|
||||
|
||||
|
|
|
|||
36
.github/workflows/wasm.yml
vendored
36
.github/workflows/wasm.yml
vendored
|
|
@ -17,7 +17,7 @@ permissions:
|
|||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
name: Check (threaded)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
@ -52,3 +52,37 @@ jobs:
|
|||
|
||||
- name: Test
|
||||
run: npm test
|
||||
|
||||
check-singlethread:
|
||||
name: Check (single-threaded)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7.0.0
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
|
||||
- name: Setup emscripten
|
||||
uses: mymindstorm/setup-emsdk@v16
|
||||
with:
|
||||
no-install: true
|
||||
version: ${{env.EM_VERSION}}
|
||||
actions-cache-folder: "emsdk-cache"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build TypeScript
|
||||
run: npm run build:ts
|
||||
|
||||
- name: Build single-threaded wasm
|
||||
run: |
|
||||
emsdk install ${EM_VERSION}
|
||||
emsdk activate ${EM_VERSION}
|
||||
source $(dirname $(which emsdk))/emsdk_env.sh
|
||||
which node
|
||||
which clang++
|
||||
npm run build:wasm:singlethread
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue