File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -926,13 +926,20 @@ namespace :wasm do
926926
927927 desc "Build the RBS parser as a WebAssembly module (requires WASI_SDK_PATH)"
928928 task :build do
929+ # `-DNDEBUG` compiles out `RBS_ASSERT`, the same way ext/rbs_extension does
930+ # for the MRI extension. The assertions sit in the lexer and the constant
931+ # pool, so keeping them costs about 20% of parse time; set `DEBUG=1` to keep
932+ # them when debugging the module itself.
933+ debug_flags = ENV [ "DEBUG" ] ? [ ] : [ "-DNDEBUG" ]
934+
929935 mkdir_p WASM_DIR
930936 sh wasi_clang ,
931937 "--target=wasm32-wasip1" ,
932938 # No `main`; the host calls `_initialize` and then the exported functions.
933939 "-mexec-model=reactor" ,
934940 "-std=gnu11" ,
935941 "-O2" ,
942+ *debug_flags ,
936943 "-Wno-unused-parameter" ,
937944 "-I#{ File . join ( __dir__ , "include" ) } " ,
938945 "-o" , WASM_OUTPUT ,
Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ $ rake wasm:install_jars # download the Chicory/ASM jars into ~/.m2 (run on JRub
2727
2828The compiled ` rbs_parser.wasm ` is a build artifact and is not checked in.
2929
30+ Like the MRI extension, the module is compiled with ` -DNDEBUG ` , which removes the
31+ ` RBS_ASSERT ` checks — they sit in the lexer and the constant pool, so leaving them
32+ in costs around 20% of parse time. ` DEBUG=1 rake wasm:build ` keeps them, which is
33+ what you want when debugging the parser itself through the module.
34+
3035The WASI SDK is needed for the * build* , not for running the result — the host clang already
3136knows the ` wasm32 ` target, but there is no wasm32 libc on a normal machine, so it picks up the
3237host headers and fails on the first ` #include ` . That is what the SDK supplies, along with the
You can’t perform that action at this time.
0 commit comments