freetype port: add variant for standardized Wasm EH (WASM_LEGACY_EXCEPTIONS=0)#26729
freetype port: add variant for standardized Wasm EH (WASM_LEGACY_EXCEPTIONS=0)#26729leehyeonseop wants to merge 5 commits intoemscripten-core:mainfrom
Conversation
|
You you update the test_freetype test in test_other such that it triggers the issue this fixes. It does look like do currently build this configuration: |
Verify that the correct port variant (libfreetype-wasmsjlj.a) is selected when building with -fwasm-exceptions -sWASM_LEGACY_EXCEPTIONS=0 -sSUPPORT_LONGJMP=wasm. Without the fix, libfreetype-legacysjlj.a is used instead, producing a binary with mixed legacy and new EH instructions that fails at instantiation time in browsers.
Added The test builds a C++ file that uses both try/catch (to emit new-EH instructions) and FT_Init_FreeType() (to link FreeType) with -fwasm-exceptions -sWASM_LEGACY_EXCEPTIONS=0 -sSUPPORT_LONGJMP=wasm. It verifies via -v build output that libfreetype-wasmsjlj.a (new-EH variant) is selected, not libfreetype-legacysjlj.a. Without the fix the assertion fails because the port falls back to the legacy variant. Note: The test runner uses Node.js 22 with --experimental-wasm-exnref. In our testing, this configuration runs the mixed-EH binary without error, so the runtime instantiation failure cannot be reproduced here. The test therefore verifies the correct port variant by checking the library name in -v build output |
-sSUPPORT_LONGJMP=wasm already implies the necessary backend flags (-exception-model=wasm, -wasm-use-legacy-eh=0) so -fwasm-exceptions is not needed for this pure-C library.
| proc = self.run_process([ | ||
| EMCC, '-v', | ||
| test_file('test_freetype_exc.cpp'), | ||
| '-fwasm-exceptions', |
There was a problem hiding this comment.
Remove this here and below?
Summary
The freetype port's
SUPPORT_LONGJMP=wasmvariant (freetype-legacysjlj) hardcodesWASM_LEGACY_EXCEPTIONS: 1, forcing legacy exception handling instructions. Projects using standardized Wasm EH (-fwasm-exceptions -sWASM_LEGACY_EXCEPTIONS=0 -sSUPPORT_LONGJMP=wasm) cannot link with this port without hitting:WebAssembly.instantiate(): Compiling function failed:
module uses a mix of legacy and new exception handling instructions
Changes
freetype-wasmsjljwithWASM_LEGACY_EXCEPTIONS: 0get_lib_name()to returnlibfreetype-wasmsjlj.awhenSUPPORT_LONGJMP=wasmandWASM_LEGACY_EXCEPTIONS=0-fwasm-exceptionsand-sWASM_LEGACY_EXCEPTIONS=0to build flags for the new variantReproduction
The existing freetype-legacysjlj variant and its behavior are unchanged. Other ports with similar WASM_LEGACY_EXCEPTIONS: 1 hardcoding (e.g. harfbuzz, sdl2_ttf) may need the same treatment in follow-up PRs.