## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# Cross compilation

We cross-compile the `resolc.js` frontend executable to Wasm for running it in a Node.js or browser environment.

The musl target is used to obtain statically linked ELF binaries for Linux.

## Wasm via emscripten

The `REVIVE_LLVM_TARGET_PREFIX` environment variable is used to control the target environment LLVM dependency. This requires a compatible LLVM build, obtainable via the `revive-llvm` build script. Example:

    # Build the host LLVM dependency with PolkaVM target support
    make install-llvm
    export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final

    # Build the target LLVM dependency with PolkaVM target support
    revive-llvm emsdk
    source emsdk/emsdk_env.sh
    revive-llvm --target-env emscripten build --llvm-projects lld
    export REVIVE_LLVM_TARGET_PREFIX=${PWD}/target-llvm/emscripten/target-final

    # Build the resolc frontend executable
    make install-wasm
    make test-wasm

## musl libc

rust-musl-cross is a straightforward way to cross compile Rust to musl. The Dockerfile is an executable example of how to do that.