From 917d03c22fa8e759999fba4d9736bf160c465a50 Mon Sep 17 00:00:00 2001 From: Viktor Vaczi Date: Tue, 30 Jun 2026 13:25:00 +0200 Subject: [PATCH] fix(wasm-eh): native-EH link flags for the GAL WebGL test app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The native-EH migration left tests/gal-regression/wasm/Makefile on the old Emscripten JS-exception model (-sNO_DISABLE_EXCEPTION_CATCHING, no -fwasm-exceptions). The wxWidgets libs it links are now built with -fwasm-exceptions, so wasm-ld couldn't resolve __cpp_exception / __c_longjmp and the "Build GAL WebGL test app" CI step failed. This was masked until now because the host post-process (finalize) bug killed every run before this step ran. Compile and link with DEPS_EH_FLAGS (-fwasm-exceptions -sSUPPORT_LONGJMP=wasm -sWASM_LEGACY_EXCEPTIONS=1), honoring the value build-gal-webgl-test.sh exports via env.sh with a Makefile ?= fallback — matching the wxWidgets test-app build. Drop the now-incompatible -sNO_DISABLE_EXCEPTION_CATCHING. Verified locally: ./scripts/build-gal-webgl-test.sh links clean against the native-EH wx libs and produces gal_webgl_test.{js,wasm}. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/gal-regression/wasm/Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/gal-regression/wasm/Makefile b/tests/gal-regression/wasm/Makefile index 3dd0810..9ee0041 100644 --- a/tests/gal-regression/wasm/Makefile +++ b/tests/gal-regression/wasm/Makefile @@ -57,14 +57,21 @@ else DEBUG_LDFLAGS = endif +# Native WebAssembly exceptions. The wxWidgets libs (and KiCad) are built with +# -fwasm-exceptions (scripts/common/env.sh DEPS_EH_FLAGS), so this test must compile AND +# link the same way, or wasm-ld can't resolve __cpp_exception / __c_longjmp from the wx +# archives. ?= honors the value build-gal-webgl-test.sh exports via env.sh; the fallback +# keeps a bare `make` working. +DEPS_EH_FLAGS ?= -fwasm-exceptions -sSUPPORT_LONGJMP=wasm -sWASM_LEGACY_EXCEPTIONS=1 + # -MMD -MP generates .d dependency files for header tracking # This ensures header changes trigger rebuilds (prevents stale object issues) -CXXFLAGS = $(OPT_FLAGS) $(WX_CXXFLAGS) $(KICAD_INCLUDES) -std=c++20 -MMD -MP +CXXFLAGS = $(OPT_FLAGS) $(DEPS_EH_FLAGS) $(WX_CXXFLAGS) $(KICAD_INCLUDES) -std=c++20 -MMD -MP # Emscripten flags -BASE_LDFLAGS = -sALLOW_MEMORY_GROWTH=1 \ +BASE_LDFLAGS = $(DEPS_EH_FLAGS) \ + -sALLOW_MEMORY_GROWTH=1 \ -sERROR_ON_UNDEFINED_SYMBOLS=0 \ - -sNO_DISABLE_EXCEPTION_CATCHING \ -sEXPORTED_FUNCTIONS=['_main','_runScenario','_getTotalScenarios','_getCurrentScenario','_getCanvasWidth','_getCanvasHeight'] \ -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap','HEAPU8'] \ -sMODULARIZE=1 \