Others / wasmception

Minimal C/C++ language toolset for building wasm files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wasmception

Minimal toolset for building wasm files

Export functions

Use __attribute__ ((visibility ("default"))) to make methods visible

Compile C file

$(WASMCEPTION)/dist/bin/clang --target=wasm32-unknown-unknown-wasm --sysroot=$(WASMCEPTION)/sysroot/ hi.c -o hi.wasm -nostartfiles -Wl,--no-entry

Compile C++ file

$(WASMCEPTION)/dist/bin/clang++ --target=wasm32-unknown-unknown-wasm --sysroot=$(WASMCEPTION)/sysroot/ hi.cpp -o hi.wasm -nostartfiles -Wl,--no-entry

Required main and _start functions

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.

About

Minimal C/C++ language toolset for building wasm files


Languages

Language:Makefile 57.5%Language:CMake 13.7%Language:JavaScript 12.5%Language:HTML 10.5%Language:C 5.8%