LDC
The LDC project aims to provide a portable D programming language compiler with modern optimization and code generation capabilities. The compiler uses the official DMD frontend to support the latest D2 version and relies on the LLVM Core libraries for code generation.
LDC is fully Open Source; the parts of the code not taken/adapted from other projects are BSD-licensed (see the LICENSE file for details).
D1 is no longer supported in the current development tree; the last version supporting it can be found at the d1 Git branch.
Contents
Getting started
- Latest binary releases and related forum thread
- Building LDC from source
- Building LDC on MinGW x86
- Building and hacking LDC on Windows using MSVC
- Installing LDC on Gentoo - Official Dlang Gentoo overlay
- Installing LDC on GNU Guix
- Using LDC (LDC-specific language changes — LDC inline assembly expressions — LDC inline IR)
- Reporting LDC issues — LDC contributor's guide
Project status
In general, LDC should work fine on most x86/x86-64 Unix-like systems, including Linux, OS X 10.7+, Solaris and most BSD flavors. Code generation should work for other platforms supported by the LLVM MC codegen infrastructure (for example, ARM or PowerPC), but druntime/Phobos support is sometimes lacking.
x86 Windows using MinGW
- LDC 2 from Git master compiles and builds druntime/Phobos, but requires recent MinGW and LLVM versions for a few critical bug fixes. See Building LDC on MinGW x86.
- Most programs work just fine (including TLS and exception handling).
- A small number of remaining test cases still fails, but many of the harder issues (real math precision, MS C runtime-caused problems, ABI differences) have already been solved.
- Estimate for making Windows x86/MinGW a »first class« target: 1 weekend of focused work, plus a Windows CI slave.
x86-64 Windows using MSVC
- LDC2 from master branch compiles cleanly.
- LLVM 3.7 (current trunk) is required.
- See Building and hacking LDC on Windows using MSVC for detailed instructions.
- There are no compile issues in druntime and phobos.
- Several unit tests still fail: https://github.com/ldc-developers/ldc/issues/758
- Contact: kai@redstar.de
- See also Latest pre-built LDC for Win64
OS X
- OS X version prior to 10.7 (Lion) are not supported in D2, because LLVM's thread-local storage support depends on functionality introduced in 10.7.
- homebrew users can install ldc with brew install ldc for the latest stable release or brew install ldc --devel for the latest beta / release candidate.
Android
- Almost all druntime/phobos tests pass on Android/ARM, and small GUI apps have been built.
- Android support is in alpha and not completely merged into the main LDC repo yet.
- You can download a cross-compiler for Android/ARM, test runners, and the patches used against LDC master at this github release page. There are also instructions on how to build everything from source yourself.
- Most of Android/x86 works, but it hasn't been tested in months. MIPS and the 64-bit architectures have not been tried.
ARM
- Get native ARM GNU/Linux binaries from the official release.
- LDC from Git branch ltsmaster passes most tests in the test suite (2 are failing).
- LDC has successfully been used to create a minimal free-standing ARM Cortex-M binary, see Minimal semihosted ARM Cortex-M "Hello_World".
- LDC cross-compiler for GNU/Linux on ARM architecture, using ARM GNU toolchain, see LDC cross-compilation for ARM GNU/Linux.
AArch64
- LDC from Git branch ltsmaster can be compiled with some druntime/Phobos tweaks (because of 128-bit IEEE floats).
- LLVM trunk (3.9) is required because of some LLVM bugs. (Open: PR26998)
- Complete test suite can be run but still has failures.
iOS (iPhone OS)
- Compiling D code for iOS is possible now, but it is experimental and not part of LDC main.
- Full druntime/phobos support
- Supports 32/64-bit ARM devices and iOS Simulator
- See https://github.com/smolt/ldc-iphone-dev. The README.md explains what is available and what is missing.
- Releases available: https://github.com/smolt/ldc-iphone-dev/releases
PowerPC 32-bit
- Requires at least LLVM 3.4 because of PR16556
- TLS support only for LocalExec model, see PR16555
- Code generation is known to work.
- There are no compile issues in druntime and phobos.
- Linux/PPC32 specific implementations are missing: core.cpuid, std.internal.math.bigintppc32, ...
- More testing is needed.
- Contact: kai@redstar.de
PowerPC 64-bit Big Endian and Little Endian
- PPC64 Big Endian requires at least LLVM 3.4. PPC64 Little Endian requires at least LLVM 3.5. Both are affected by PR21443.
- Only Linux because LLVM does not cleanly compile on AIX.
- Code generation is known to work.
- There are no compile issues in druntime and phobos.
- There are still some test failures. Most of the failures are related to math precision (e.g. unit test expects 80bit reals)
- See issue #1313 for test failures on PPC64 Little Endian
- Linux/PPC64 specific implementations are missing: core.cpuid, std.internal.math.bigintppc64, ...
- Multi-lib build is possible on Linux/PPC64 Big Endian.
- More testing is needed.
- Contact: kai@redstar.de
MIPS64
- Requires at least LLVM 3.6, LLVM 3.7 preferred.
- LDC and druntime compile cleanly but there are some issues in phobos with std.math.
- There seems to be an issue with ld and the integrated assembler: ld segfaults with binaries generated by ldc.
- Known failures with LLVM 3.7: std.math (SROA assert, optimization only), std.bitmap (assert in SelectionDAG), ...
- Current target is N32/N64 ABI.
- Contact: kai@redstar.de
Contributing
LDC is an entirely community-driven effort, so all contributions are warmly welcomed. The easiest way to help with development is to write high-quality bug reports for any issues you run into. For a quick guide on what a useful report should contain, please see Reporting LDC issues.
If you are interested in getting into compiler development, anecdotal evidence suggests that hacking on LDC might be a nice first step, particularly because the LLVM backend is very comfortable to work with. To get started, just browse through the issue list, find a ticket that tickles your fancy (some of them are specifically marked as "junior jobs"), and work on a fix – and of course don't hesitate to ask for advice at the mailing list or on IRC. An LDC contributor's guide is in the works. Have a look at LDC project ideas for a list of features/improvements to add to LDC.
We would also be excited to see LDC packages in more OS distributions, particular Debian and its derivatives. So, if you think you might be able to help, please just drop us a line at the development mailing list. We will actively try to make packaging as smooth as possible, but besides the fact that upstream-maintained packages are sometimes discouraged, it is hard to build good packages for a system you don't know well, so we need to rely on external contributors here.
Presentations
LDC is an active project and the team promotes the use of D and LDC.
- David's talk about LDC at DConf 2013: Slides Video HD Video SD
- Kai's talk about LDC in the LLVM devroom at FOSDEM'14: Slides (PPTX) Slides (PDF) Video
- Kai's talk about the LLVM assembler in the LLVM toolchain devroom at FOSDEM'15: Slides Video
- David's talk about DRuntime at DConf 2015: Slides Video HD Video SD
Useful Links
- Issue tracker (GitHub)
- Source code (GitHub)
- LDC discussion forum (also available via NNTP and a mailing list interface, see the forum index)
- LDC IRC channel (#ldc on Freenode)