Skip to content

Commit

Permalink
fix: update plugin-wasm to export _free function (#475)
Browse files Browse the repository at this point in the history
Fixes #474
  • Loading branch information
chrispcampbell authored May 2, 2024
1 parent 28fe761 commit 1a77eed
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-wasm/docs/interfaces/WasmPluginOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ with) Emscripten versions 2.0.34 and 3.1.46, among others.
-s EXPORT_ES6=1
-s USE_ES6_IMPORT_META=0
-s ENVIRONMENT='web,webview,worker'
-s EXPORTED_FUNCTIONS=['_malloc','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']
-s EXPORTED_FUNCTIONS=['_malloc','_free','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']
-s EXPORTED_RUNTIME_METHODS=['cwrap']
```

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-wasm/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface WasmPluginOptions {
* -s EXPORT_ES6=1
* -s USE_ES6_IMPORT_META=0
* -s ENVIRONMENT='web,webview,worker'
* -s EXPORTED_FUNCTIONS=['_malloc','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']
* -s EXPORTED_FUNCTIONS=['_malloc','_free','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']
* -s EXPORTED_RUNTIME_METHODS=['cwrap']
* ```
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-wasm/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async function buildWasm(
// and Node.js contexts (tested in Emscripten 2.0.34 and 3.1.46).
addFlag(`ENVIRONMENT='web,webview,worker'`)
addFlag(
`EXPORTED_FUNCTIONS=['_malloc','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']`
`EXPORTED_FUNCTIONS=['_malloc','_free','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']`
)
addFlag(`EXPORTED_RUNTIME_METHODS=['cwrap']`)
}
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ $ emcc \
build/<mymodel>.c build/macros.c build/model.c build/vensim.c \
-Ibuild -o ./output/<mymodel>.js -Wall -Os \
-s STRICT=1 -s MALLOC=emmalloc -s FILESYSTEM=0 -s MODULARIZE=1 \
-s EXPORTED_FUNCTIONS="['_malloc','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']" \
-s EXPORTED_FUNCTIONS="['_malloc','_free','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']" \
-s EXPORTED_RUNTIME_METHODS="['cwrap']"
```
Note that the generated module must export the following functions at minimum:
- `_malloc`
- `_free`
- `_getInitialTime`
- `_getFinalTime`
- `_getSaveper`
Expand Down

0 comments on commit 1a77eed

Please sign in to comment.