Minimal C/C++ language toolset for building wasm files
Makefile
136
53 commits
updated Apr 5, 2019
NOTE: this project is archived in favor of WASI SDK.
Minimal toolset for building wasm files
Use linker's --export parameter to specify exports (with clang use -Wl,--export, e.g. -Wl,--export=foo,--export=bar). The use of __attribute__ ((visibility ("default"))) is no longer preferable way to make methods visible -- --export-dynamic needs to be added.
$(WASMCEPTION)/dist/bin/clang --sysroot=$(WASMCEPTION)/sysroot/ hi.c -o hi.wasm -nostartfiles -Wl,--no-entry,--export=foo
$(WASMCEPTION)/dist/bin/clang++ --sysroot=$(WASMCEPTION)/sysroot/ hi.cpp -o hi.wasm -nostartfiles -Wl,--no-entry,--export=bar -fno-exceptions
main and _start functionsThe -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.
Makefile
44.8%
Python
23.9%
CMake
9.9%
JavaScript
9.4%
HTML
7.9%
C
4.1%
Minimal C/C++ language toolset for building wasm files
Makefile
136
53 commits
updated Apr 5, 2019
NOTE: this project is archived in favor of WASI SDK.
Minimal toolset for building wasm files
Use linker's --export parameter to specify exports (with clang use -Wl,--export, e.g. -Wl,--export=foo,--export=bar). The use of __attribute__ ((visibility ("default"))) is no longer preferable way to make methods visible -- --export-dynamic needs to be added.
$(WASMCEPTION)/dist/bin/clang --sysroot=$(WASMCEPTION)/sysroot/ hi.c -o hi.wasm -nostartfiles -Wl,--no-entry,--export=foo
$(WASMCEPTION)/dist/bin/clang++ --sysroot=$(WASMCEPTION)/sysroot/ hi.cpp -o hi.wasm -nostartfiles -Wl,--no-entry,--export=bar -fno-exceptions
main and _start functionsThe -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.
Makefile
44.8%
Python
23.9%
CMake
9.9%
JavaScript
9.4%
HTML
7.9%
C
4.1%