Skip to content

Commit a4e161b

Browse files
committed
fix build
* `EXPORT_ES6` and `ENVIRONMENT=*node*` requires `USE_ES6_IMPORT_META` to be set. This changed in emscripten-core/emscripten#17915. * `_malloc` and `_free` must be declared as exported functions to avoid removal by the compiler. * Remove [`WASM_ASYNC_COMPILATION=0`](https://emsettings.surma.technology/#WASM_ASYNC_COMPILATION). The current code was broken by emscripten-core/emscripten#12650. Previously, `WASM_ASYNC_COMPILATION=0` would return `Promise<Module>`, but that PR made it return `Module` directly. (Took ages to find the cause of this!) Removing the flag to keep it async avoids a breaking change in this library. Node.js v14.8.0 and later support top-level await, so async isn't that ugly. Alternatively, the Node.js version could easily be changed to load synchronously. Node.js has no limit on the size of synchronously loaded WebAssembly modules, unlike Chromium.
1 parent 8dc5720 commit a4e161b

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ EMX_FLAGS :=
77
EMX_FLAGS += -Os
88
EMX_FLAGS += -s EXPORT_ES6=1
99
EMX_FLAGS += -s MODULARIZE=1
10-
EMX_FLAGS += -s USE_ES6_IMPORT_META=0
10+
EMX_FLAGS += -s USE_ES6_IMPORT_META=1
1111
EMX_FLAGS += -s EXPORT_NAME='promise'
12-
EMX_FLAGS += -s WASM_ASYNC_COMPILATION=0
1312
EMX_FLAGS += -s ALLOW_MEMORY_GROWTH=1
1413
EMX_FLAGS += -s ALLOW_TABLE_GROWTH=1
1514
EMX_FLAGS += -s INITIAL_MEMORY=8MB
@@ -31,14 +30,14 @@ node: lmfit
3130
emcc $(EMX_FLAGS) -I$(LMFIT_SRC)/lib $(LMFIT_SRC)/build/lib/liblmfit.a src/lmfit.js.c \
3231
-s ENVIRONMENT="node" \
3332
-s EXPORTED_RUNTIME_METHODS="[addFunction, removeFunction, getValue, cwrap]" \
34-
-s EXPORTED_FUNCTIONS="[_do_fit]" \
33+
-s EXPORTED_FUNCTIONS="[_do_fit, _malloc, _free]" \
3534
-o $(BUILD_DIR)/lmfit.js;
3635

3736
web: lmfit
3837
emcc $(EMX_FLAGS) -I$(LMFIT_SRC)/lib $(LMFIT_SRC)/build/lib/liblmfit.a src/lmfit.js.c \
3938
-s ENVIRONMENT="worker" \
4039
-s EXPORTED_RUNTIME_METHODS="[addFunction, removeFunction, getValue, cwrap]" \
41-
-s EXPORTED_FUNCTIONS="[_do_fit]" \
40+
-s EXPORTED_FUNCTIONS="[_do_fit, _malloc, _free]" \
4241
-o $(BUILD_DIR)/lmfit.web.js;
4342

4443
lmfit: dir lmfit-patch

dist/lm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lm.node.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lmfit.wasm

5.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)