Running julia on wasm
There's two ways to try out the current state of the wasm port without building anything yourself. 1. An instance of the Web REPL hosted at https://keno.github.io/julia-wasm/website/repl.htm 2. Using the iodide IDE plugin (see https://alpha.iodide.io/notebooks/225/ to get started).
Both use a pre-built version. Please note that this is an extremely early alpha and many things are likely (and known) to be broken.
This repo contains various experiments for setting up julia on wasm. It's intended for collaboration and issue tracking before things are working sufficiently to switch to the appropriate upstream repo: There's three scripts in this repo: -
configure_julia_wasm.shwhich will setup all the directories -
build_julia_wasm.shwhich will build two copies of julia (one natively for cross compiling the system image, one for wasm) -
rebuild_js.shwhich will rebuild just the wasm parts and dump it into the website/ directory which is a hacked up copy of https://github.com/vtjnash/JuliaWebRepl.jl
gcc-multiliband
g++-multilib
First install the emscripten SDK ```sh
git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install emscripten-incoming-64bit binaryen-master-64bit ./emsdk activate emscripten-incoming-64bit binaryen-master-64bit ```
Then build and install upstream LLVM ```sh
git clone https://github.com/llvm/llvm-project mkdir llvm-build cd llvm-build cmake -G Ninja -DLLVMENABLEPROJECTS="clang;lld" -DCMAKEBUILDTYPE=Release ../llvm-project/llvm ninja ```
LLVM_ROOT = '/llvm-build/bin'to
$HOME/.emscripten
llvm-build/binto
$PATH
Finally, you're ready to build julia for wasm ```sh
./configure-julia-wasm.sh
./build-julia-wasm.sh ```
This command may fail at the very end with an error like the following:
JULIA build-native/usr/lib/julia/sys-o.a syntax: incomplete: premature end of inputErrorException("") ERROR: LoadError: syntax: incomplete: premature end of input Stacktrace: [1] top-level scope at /root/julia-wasm/julia/contrib/generate_precompile.jl:7This is expected (we're using a 32bit linux build, but telling it it's wasm to generate a compatible system image, so things are a bit confused). Afterwards, build the wasm build using:
# Do this after you change something on the wasm side ./rebuild_js.shAfterwards you may set up a webserver using:
emrun --no_browser --port 8888 website/repl.htm &At the moment
Firefox Nightlyseems to have the most complete wasm support and seems to be the fastest, so I'd recommend trying that. After starting the server above, just navigate to
localhost:8888/repl.htm
In
about:configenable
javascript.options.wasm_gc
google-chrome-unstable --jsflags="--experimental-wasm-anyref"