Just choose one of the following — I’d like to say so. But IDK why while it’s said “clang has WASI support out of box, my installing clang&llvm without following SDK only results in header-missing when compiling
# ./nim.cfg, you can just place it in $CWD
--cpu:wasm32
#--os:wasi
--os:linux
--threads:off
--cc:clang
clang.options.always="--target=wasm32-wasi "
clang.options.always%="${clang.options.always} -D_WASI_EMULATED_MMAN "
# demo for `--export` usage:
# clang.options.linker="-Wl,--export=abcdef "
clang.options.linker%="${clang.options.linker} -Wl,-lwasi-emulated-mman "
# check for -d:noSignalHandler
@if not noSignalHandler:
clang.options.always%="${clang.options.always} -D_WASI_EMULATED_SIGNAL "
clang.options.linker%="${clang.options.linker} -Wl,-lwasi-emulated-signal "
@end
To make function symbol exported to wasm, 3 methods:
-Wl,--export-all to linker-Wl,--export=NAME[,...] to linkerexport_name attribute https://clang.llvm.org/docs/AttributeReference.html#export-name-funcrefutil to gen export_name attribute