1
0
Fork
You've already forked ldc2-build.zig
0
Build ldc2 (LLVM D toolchain) like zig-bootstrap
  • Zig 95.6%
  • Shell 4.4%
2026年06月04日 17:37:05 -03:00
.gitignore ldc-builder 2026年05月30日 17:24:50 -03:00
build ldc-builder 2026年05月30日 17:24:50 -03:00
build.zig update build.zig to zig v0.17.0 2026年06月04日 17:37:05 -03:00
build.zig.zon update build.zig to zig v0.17.0 2026年06月04日 17:37:05 -03:00
LICENSE Initial commit 2026年05月30日 22:07:56 +02:00
README.md update build.zig to zig v0.17.0 2026年06月04日 17:37:05 -03:00

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-bit size_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 via LDC_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