Build ldc2 (LLVM D toolchain) like zig-bootstrap
| .gitignore | ldc-builder | |
| build | ldc-builder | |
| build.zig | update build.zig to zig v0.17.0 | |
| build.zig.zon | update build.zig to zig v0.17.0 | |
| LICENSE | Initial commit | |
| README.md | update build.zig to zig v0.17.0 | |
ldc2-build.zig
Build the LDC2 D toolchain with Zig — cross-compile anywhere.
Highlight
- Cross-compile like zig-bootstrap. Pick a target triple, get a native or cross
ldc2. - Right compiler for the LLVM. The ldc source flavor is auto-selected from the LLVM you point at:
LLVM target Source pulled mos6502 kassane/ldc#llvm-mos(MOS + sub-32-bitsize_t)xtensa kassane/ldc#espressif(Xtensa/RISC-V ABI fixes)stock ldc-developers/ldc(upstream)
Requirements
- ldc2 compiler (stable release)
- zig toolchain - v0.17.0 or higher
- A bootstrap LLVM tree (e.g.
../zig-bootstrap/out), set viaLDC_LLVM_ROOT. - LLVM-compiler-rt builtin source, set
COMPILER_RT_SRC
Use
export COMPILER_RT_SRC=../llvm/compiler-rt/lib/builtins
export LDC_LLVM_ROOT=../zig-bootstrap/out
./build <target> <mcpu> [flags...]
# samples tested
./build x86_64-linux-musl baseline
./build aarch64-linux-musl baseline
./build riscv64-linux-musl baseline
./build x86_64-windows baseline
./build aarch64-macos baseline
./build auto-detects the LLVM version and experimental targets, then forwards any extra flags to zig build.
Flags
| Flag | Effect |
|---|---|
-Dldc-source=auto|upstream|espressif|llvm_mos |
Override source pick (default auto). Decoupled from LLVM lib linking, so upstream builds against an Xtensa-capable LLVM too. |
-Dbuild-druntime |
Build druntime + phobos. |
-Dbuild-tools |
Build ldmd2, ldc-build-runtime, profdata/profgen, etc. |
-Dbuild-lto-libs / -Dbuild-debug-libs |
Extra LTO / debug runtime libs. |
-Dshared |
Build LDCShared as a shared library. |
Output
zig-out/bin/: ldc2, ldmd2, ldc-build-runtime, ldc-build-plugin, ldc-prune-cache, ldc-profdata, ldc-profgen, timetrace2txt.
License
MIT © kassane