Minimal toolset for building wasm files
Use __attribute__ ((visibility ("default")))
to make methods visible
$(WASMCEPTION)/dist/bin/clang --target=wasm32-unknown-unknown-wasm --sysroot=$(WASMCEPTION)/sysroot/ hi.c -o hi.wasm -nostartfiles -Wl,--no-entry
$(WASMCEPTION)/dist/bin/clang++ --target=wasm32-unknown-unknown-wasm --sysroot=$(WASMCEPTION)/sysroot/ hi.cpp -o hi.wasm -nostartfiles -Wl,--no-entry
The -nostartfiles
will not require you to define the main
function, but will be looking for the _start
function:
use -Wl,--no-entry
clang (linker) option to avoid specified entry point. As alternative, you can add void _start() {}
(or extern "C" void _start() { }
in C++) to make linker happy due to -nostartfiles
.