GitXplorerGitXplorer
H

dyn-samples

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
2b52d74079ee34540d0709b27b694fb7748c7ab3

Examples for emscripten::val

HHonry committed 3 years ago
Unverified
ccebea253569b84ca466f8a558cb1a9950de209a

Update README.md

HHonry committed 3 years ago
Unverified
113751cb980927606c1f2825b4a2109347172e3b

Add initial sample for dynamic linking

HHonry committed 3 years ago
Verified
2cefbc225eb81f1e6a8235acbe6a94604aff4d79

Initial commit

HHonry committed 3 years ago

README

The README file for this repository.

dyn-samples

Dynamic Linking samples

Key Files / Functions Introduction

calculate_primes.cc: A WebAssembly side module that will be linked to the main module: main.cc. This file exports a FindPrimes function to be called in main module.

main.cc: A WebAssembly main module that can link to side module.

emscripten_async_wget(): A function to download the side module to Emscripten's file system.

dlopen(): A function to load side modules after the program is already running.

dlsym(): A function to get symbols exported by side modules.

Build

Side Module: $ emcc calculate_primes.cc -s SIDE_MODULE=1 -O1 -o calculate_primes.wasm

Main Module: $ emcc main.cc -s MAIN_MODULE=1 -o main.html

Reduce Code Size

Modules disable dead code elimination, use normal dead code elimination by building with SIDE_MODULE=2

  • emcc calculate_primes.cc -s SIDE_MODULE=2 -O1 -o calculate_primes.wasm
  • emcc main.cc -s MAIN_MODULE=2 -s EXPORTED_FUNCTIONS=['_putchar','_main','_iprintf'] -o main.html

Demo

https://honry.github.io/dyn-samples/main.html