GitHub

Original file line numberDiff line numberDiff line change

@@ -5,14 +5,35 @@ MRuby::Toolchain.new(:emscripten) do |conf|

55

# - https://emscripten.org/docs/tools_reference/emcc.html

66

# - https://emscripten.org/docs/tools_reference/settings_reference.html

77

# - https://github.com/emscripten-core/emscripten/blob/main/src/settings.js

8+

#

9+

# == WASM Exception Handling ==

10+

#

11+

# mruby uses setjmp/longjmp for non-local exits (exceptions, break/return

12+

# from blocks). This toolchain uses native WASM exception handling which

13+

# is more efficient than Asyncify-based emulation:

14+

#

15+

# - Minimal memory overhead (no shadow stack)

16+

# - No code size penalty

17+

# - Works with both C and C++ code

18+

#

19+

# Supported runtimes (as of 2024):

20+

# - Chrome 95+, Firefox 100+, Safari 15.2+

21+

# - Node.js 17+, Wasmtime, Wasmer

22+

#

23+

# For older runtimes, override with CFLAGS/LDFLAGS environment variables.

24+

#

25+

# See: https://emscripten.org/docs/porting/exceptions.html

26+

# https://emscripten.org/docs/porting/setjmp-longjmp.html

827

compile_and_link_flags = [

28+

'-fwasm-exceptions',

929

]

1030

compile_flags = [

1131

*compile_and_link_flags,

1232

'-Wno-unused-but-set-variable',

1333

]

1434

link_flags = [

1535

*compile_and_link_flags,

36+

'-sSUPPORT_LONGJMP=wasm',

1637

]

1738
1839

conf.cc do |cc|

Read the original on github.com ↗