1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Meson cross-compilation file for Emscripten (wasm32).
# Used by the gonix WASM evaluator build:
#
#   meson setup build-wasm --cross-file wasm-cross.ini -Dwasm-eval-only=true ...
#   ninja -C build-wasm

[binaries]
c       = '/nix/store/f2hizi63xa20qzrblcb3axim5ix6q1wb-emscripten-4.0.12/bin/emcc'
cpp     = '/nix/store/f2hizi63xa20qzrblcb3axim5ix6q1wb-emscripten-4.0.12/bin/em++'
ar      = '/nix/store/f2hizi63xa20qzrblcb3axim5ix6q1wb-emscripten-4.0.12/bin/emar'
ranlib  = '/nix/store/f2hizi63xa20qzrblcb3axim5ix6q1wb-emscripten-4.0.12/bin/emranlib'
strip   = '/nix/store/f2hizi63xa20qzrblcb3axim5ix6q1wb-emscripten-4.0.12/bin/emstrip'

[host_machine]
system     = 'emscripten'
cpu_family = 'wasm32'
cpu        = 'wasm32'
endian     = 'little'

[built-in options]
# Core emscripten compile flags.
# Header-only dep includes are added via add_project_arguments in meson.build.
# wasm-shims provides stub kj/ and other headers.
# -pthread enables WASM atomics/bulk-memory features required by this emscripten
# sysroot (which was pre-compiled with threading support in the nix derivation).
# We don't actually use threads — GC_start_mark_threads is guarded out —
# but the flag is needed for ABI consistency with the emscripten runtime libs.
# Use -fexceptions (JavaScript-based exception model) instead of -fwasm-exceptions.
# -fwasm-exceptions emits WASM try/catch opcodes (tag section, id=13) which
# wazero does not yet support. -fexceptions implements C++ exceptions via calls
# into the Emscripten runtime — no special WASM opcodes, fully compatible with wazero.
# No -pthread: single-threaded WASM avoids the (import "env" "memory") shared
# memory import that wazero's HostModuleBuilder cannot satisfy.
# -fno-PIC: disable Position Independent Code.
# Meson auto-injects -fPIC for library targets; with emscripten this triggers
# GOT-based indirect dispatch and __wasm_apply_data_relocs relocation patching
# which is never called in a standalone WASM binary, leaving all GOT.func
# globals as zero at runtime and breaking invoke_* indirect calls.
cpp_args    = ['-fexceptions', '-sSTANDALONE_WASM=1', '-DHAVE_BOEHMGC=0', '-I../lix/wasm-shims']
c_args      = ['-fexceptions', '-sSTANDALONE_WASM=1', '-DHAVE_BOEHMGC=0', '-I../lix/wasm-shims']
b_staticpic = false