Skip to content

Commit e4d20d4

Browse files
committed
Workaround unused wasi imports with recent emscripten
1 parent 4e0d68e commit e4d20d4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,28 @@ following steps:
4848

4949
```shell
5050
./combine.sh -r ../../lib -o zstddeclib.c zstddeclib-in.c
51-
emcc zstddeclib.c -Oz -s EXPORTED_FUNCTIONS="['_ZSTD_decompress', '_ZSTD_findDecompressedSize', '_ZSTD_isError', '_malloc', '_free']" -Wl,--no-entry -s STANDALONE_WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s MALLOC=emmalloc -o zstddec.wasm
51+
```
52+
53+
Add the following to the end of *zstddeclib.c* to [shim out unused wasi
54+
imports](https://github.com/emscripten-core/emscripten/issues/17331),
55+
56+
```c
57+
int __wasi_fd_write(int, int, int, int) {
58+
__builtin_trap();
59+
}
60+
int __wasi_fd_seek(int, int64_t, int, int) {
61+
__builtin_trap();
62+
}
63+
int __wasi_fd_close(int) {
64+
__builtin_trap();
65+
}
66+
_Noreturn void __wasi_proc_exit(int) {
67+
__builtin_trap();
68+
}
69+
```
70+
71+
```shell
72+
emcc zstddeclib.c -Oz -s EXPORTED_FUNCTIONS="['_ZSTD_decompress', '_ZSTD_findDecompressedSize', '_ZSTD_isError', '_malloc', '_free']" -Wl,--no-entry -s ALLOW_MEMORY_GROWTH=1 -s MALLOC=emmalloc -o zstddec.wasm
5273
base64 -w 0 zstddec.wasm > zstddec.txt
5374
```
5475

zstddec.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)