Running Scala in WebAssembly through Scala Native
Branch: master
Clone or download
Latest commit 06e00ad Jan 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project Initial commit Jan 12, 2019
src/main/scala Initial commit Jan 12, 2019
.gitignore Initial commit Jan 12, 2019
README.md Initial commit Jan 12, 2019
build.sbt Initial commit Jan 12, 2019

README.md

Scala Native on WebAssembly Demo

First, locally publish https://github.com/scala-native/scala-native/pull/1363 with sbt rebuild_x32.

Then, run the Scala Native linker with sbt nativeLink, this will produce errors during compilation and linking, but this is okay because we only care about the generated LLVM.

Finally, run Emscripten to compile to WebAssembly:

emcc target/scala-2.11/native/lib/*.c target/scala-2.11/native/lib/gc/none/**.c target/scala-2.11/native/lib/*.cpp target/scala-2.11/native/*.ll -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -o index.html

Then open up index.html in a web browser (you may need to serve the directory as a local server due to security restrictions).