Skip to content

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

Notifications You must be signed in to change notification settings

zw3rk/wasmception

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wasmception

Minimal toolset for building wasm files

Export functions

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.

Compile C file

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

Compile C++ file

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

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Makefile 48.5%
  • Python 22.2%
  • CMake 9.5%
  • JavaScript 8.7%
  • HTML 7.3%
  • C 3.8%