Cross-Compiling Common Lisp to WASM

https://news.ycombinator.com/rss Hits: 6
Summary

Tagged as lisp, webassembly Written on 2025-11-28 by Daniel Kochma艅ski Table of Contents Building ECL Building WECL Building user programs Extending ASDF Funding Using Common Lisp in WASM enabled runtimes is a new frontier for the Common Lisp ecosystem. In the previous post Using Common Lisp from inside the Browser I've discussed how to embed Common Lisp scripts directly on the website, discussed the foreign function interface to JavaScript and SLIME port called LIME allowing the user to connect with a local Emacs instance. This post will serve as a tutorial that describes how to build WECL and how to cross-compile programs to WASM runtime. Without further ado, let's dig in. Building ECL To compile ECL targeting WASM we first build the host version and then we use it to cross-compile it for the target architecture. git clone https://gitlab.com/embeddable-common-lisp/ecl.git cd ecl export ECL_SRC=`pwd` export ECL_HOST=${ECL_SRC}/ecl-host ./configure --prefix=${ECL_HOST} && make -j32 && make install Currently ECL uses Emscripten SDK that implements required target primitives like libc. In the meantime, I'm also porting ECL to WASI, but it is not ready yet. In any case we need to install and activate emsdk: git clone https://github.com/emscripten-core/emsdk.git pushd emsdk ./emsdk install latest ./emsdk activate latest source ./emsdk_env.sh popd Finally it is time to build the target version of ECL. A flag --disable-shared is optional, but keep in mind that cross-compilation of user programs is a new feature and it is still taking shape. Most notably some nuances with compiling systems from .asd files may differ depending on the flag used here. make distclean # removes build/ directory export ECL_WASM=${ECL_SRC}/ecl-wasm export ECL_TO_RUN=${ECL_HOST}/bin/ecl emconfigure ./configure --host=wasm32-unknown-emscripten --build=x86_64-pc-linux-gnu \ --with-cross-config=${ECL_SRC}/src/util/wasm32-unknown-emscripten.cross_config \ --prefix=${ECL_WASM} --disable-shared --with-t...

First seen: 2025-12-03 22:00

Last seen: 2025-12-04 03:04