Skip to content

Commit

Permalink
fix(developer): fix breakage from emscripten 3.1.44
Browse files Browse the repository at this point in the history
- use wasmExports.malloc if available otherwise asm.malloc
  • Loading branch information
srl295 committed Jul 31, 2023
1 parent 64e1d13 commit 8c2cd89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion developer/src/kmc-kmn/src/compiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,13 @@ export class KmnCompiler implements UnicodeSetParser {
return null;
}

const buf = this.Module.asm.malloc(rangeCount * 2 * this.Module.HEAPU32.BYTES_PER_ELEMENT);
let malloc = this.Module?.wasmExports?.malloc || this.Module?.asm?.malloc;

if (!malloc) {
throw new Error(`Internal Error: missing wasmExports.malloc() / asm.malloc()`);
}

const buf = malloc(rangeCount * 2 * this.Module.HEAPU32.BYTES_PER_ELEMENT);
// TODO-LDML: Catch OOM
/** return code, if positive: range count */
const rc = this.Module.kmcmp_parseUnicodeSet(pattern, buf, rangeCount * 2);
Expand Down
2 changes: 1 addition & 1 deletion developer/src/kmcmplib/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if cpp_compiler.get_id() == 'emscripten'
# wasm-exceptions supported in Node 18+, Chrome 95+, Firefox 100+, Safari 15.2+
flags += ['-fwasm-exceptions']
lib_links = ['--whole-archive', '-sMODULARIZE', '-sEXPORT_ES6']
links += ['-fwasm-exceptions', '--bind', '-sEXPORTED_RUNTIME_METHODS=[\'UTF8ToString\']']
links += ['-fwasm-exceptions', '--bind', '-sEXPORTED_RUNTIME_METHODS=[\'UTF8ToString\',\'wasmExports\']']
endif

icu = subproject('icu-for-uset', default_options: [ 'default_library=static', 'cpp_std=c++17', 'warning_level=0', 'werror=false'])
Expand Down

0 comments on commit 8c2cd89

Please sign in to comment.