This document describes the Docker-based build environment that provides the LLVM and Enzyme toolchain required to compile algovivo. The Docker images ensure a hermetic, reproducible build environment with specific versions of LLVM 18, Clang, and the Enzyme automatic differentiation plugin across different platforms and CI/CD environments.
For information about the code generation process that produces the C++ source files, see 3.1 Code Generation Pipeline. For details on the LLVM compilation pipeline itself, see 3.2 Compilation with LLVM and Enzyme.
The build system utilizes Docker containers to provide a controlled environment containing the LLVM 18 toolchain and the Enzyme AD plugin. This approach eliminates environment-specific build issues and ensures that all developers and CI systems use identical toolchain versions for both WebAssembly and native library targets build.sh19-29
The environment includes:
Sources: build.sh4-7 utils/enzyme/Dockerfile-llvm187 utils/enzyme/Dockerfile-llvm1813-15
Docker images are hosted in the GitHub Container Registry (ghcr.io). While the project provides configurations for both LLVM 11 and LLVM 18, the current standard is LLVM 18 build.yml38
| Image | Description |
|---|---|
ghcr.io/juniorrojas/algovivo/llvm18-enzyme:latest | LLVM 18 with Enzyme v0.0.232 |
ghcr.io/juniorrojas/algovivo/llvm11-enzyme:latest | Legacy LLVM 11 environment |
Sources: .github/workflows/build.yml38 .github/workflows/build-enzyme-docker-image.yml80-82 utils/enzyme/Dockerfile-llvm111-24 utils/enzyme/Dockerfile-llvm181-24
The build environment supports multi-architecture manifests, allowing the same image tag to work on different hardware:
ubuntu-24.04 runners .github/workflows/build-enzyme-docker-image.yml25-26ubuntu-24.04-arm runners .github/workflows/build-enzyme-docker-image.yml27-28Sources: .github/workflows/build-enzyme-docker-image.yml22-29 .github/workflows/build-enzyme-docker-image.yml71-75
The environment is defined by Dockerfile-llvm18, which constructs the toolchain from source where necessary.
"Dockerfile-llvm18 Build Stages"
Sources: utils/enzyme/Dockerfile-llvm181-24
ninja-build and cmake utils/enzyme/Dockerfile-llvm185-11v0.0.232 for LLVM 18 utils/enzyme/Dockerfile-llvm1813-15 and a specific commit hash for LLVM 11 utils/enzyme/Dockerfile-llvm1113-15ENZYME (path to the shared library plugin) and LLVM_BIN_DIR (path to compiler binaries), which are consumed by the project's build.sh script utils/enzyme/Dockerfile-llvm1823-24 build.sh4-5Sources: utils/enzyme/Dockerfile-llvm181-24 utils/enzyme/Dockerfile-llvm111-24 build.sh4-5
The project uses the containerized environment to execute the build.sh script, which orchestrates the transformation from C++ to the final binary.
"Build Environment Data Flow"
Sources: build.sh23-64 utils/enzyme/Dockerfile-llvm1823-24 build.yml73-77
The environment supports two primary build modes controlled by the NATIVE environment variable build.sh19-21
Used for the browser-based library. The script detects the environment and uses the WASM target build.sh27-29
In this mode, build.sh uses llc -march=wasm32 and wasm-ld to produce the .wasm file build.sh56-62
Used for the Python interface py.yml32-41
In this mode, build.sh produces an architecture-specific .so shared library using clang -shared build.sh47-52
Sources: build.sh19-29 build.sh47-64 build.yml104-109 py.yml35-40
The Docker images themselves are managed via a dedicated GitHub Action workflow: build-enzyme-docker-image.yml .github/workflows/build-enzyme-docker-image.yml1
workflow_dispatch, choosing between LLVM 11 and LLVM 18 .github/workflows/build-enzyme-docker-image.yml4-13amd64 and arm64 architectures .github/workflows/build-enzyme-docker-image.yml22-29ghcr.io with tags corresponding to the Git SHA and architecture .github/workflows/build-enzyme-docker-image.yml47-53docker buildx imagetools create to unify the architecture-specific images under a single tag .github/workflows/build-enzyme-docker-image.yml71-82Sources: .github/workflows/build-enzyme-docker-image.yml1-82
Refresh this wiki