LLVM D Compiler
LDC is a compiler for the D programming Language. It is based on the latest DMD frontend and uses LLVM 2.4 as backend. LLVM provides a fast and modern backend for high quality code generation. LDC is released under a BSD license with exceptions for the DMD frontend and code from GDC.
The development takes place mostly on x86-32 Linux and that is where LDC works best. Support for other platforms and architectures is under development, but we are still looking for people to help test and adjust LDC for those platforms!
LDC already compiles a lot of D code, but should still be considered beta quality. Take a look at the tickets to get a better impression on what still needs to be implemented.
We have two sets of tests living in the tests directory. The mini testsuite in mini/ and minicomplex/ contains a few tests that are supposed to compile or run and is mostly used when fixing a bug. There is also the larger DStress based test suite comparing LDC revisions among themselves and to DMD.
Project Status
- The first release is near!
- x86 Linux: Several large projects are working, including:
- Tango
- MiniD
- GtkD
- (please add :)
- Help is welcome for getting LDC to work on other platforms!
- D2 support has been started but is not yet fully working, if you want that to change, help out!
See the tickets for more details.
Communication
Feedback is much appreciated, you can contact us via IRC in the #ldc channel on FreeNode or the mailing list at ldc-dev@googlegroups.com.
The dsource forum is hardly ever looked at by the developers, please use the mailing list instead. If you've found a bug, feel free to report it directly.
D binding for LLVM
While not part of the LDC compiler, a llvm binding to LLVM for D can be found in the old SVN repository. The binding is a wrapper around the LLVM C interface with a few extensions. See the source/samples for more information.
Documentation
Documentation is still sparse, but there is a little on the versions and pragmas. There is also the beginnings of a hacker's guide. And the release checklist.
How To Compile
(Gentoo users may want to check out this overlay: d-overlay)
Dependencies:
- LLVM 2.4
- cmake 2.6+
- optional Hans Boehm GC 7.0 (direct download link) (for ldc itself, buggy and not recommended)
- optional DSSS
- optional GDC or DMD with Phobos (for building the test drivers)
Download, Compile and install LLVM 2.4
wget http://llvm.org/releases/2.4/llvm-2.4.tar.gz tar -xvzf llvm-2.4.tar.gz mv llvm-2.4 llvm-2.4-src mkdir llvm-2.4-obj cd llvm-2.4-obj ../llvm-2.4-src/configure --enable-optimized make su -c 'make install' cd ..
Grab LDC from the Mercurial repository:
hg clone http://hg.dsource.org/projects/ldc ldc
Fetch the tango runtime for D1
svn co http://svn.dsource.org/projects/tango/trunk ldc/tango
or
Fetch the druntime for D2 (this is experimental)
svn co http://svn.dsource.org/projects/druntime/trunk ldc/druntime
Generate the makefiles
mkdir ldc-build cd ldc-build ccmake ../ldc
check the settings, press 'c', press 'g'.
Compile ldc and the runtime and include ldc in your path
make
make runtime
export PATH=`pwd`/bin:${PATH}
Using Tango
While LDC does use the Tango runtime per default, you still need to compile the Tango user library to build most applications. Otherwise you'll get linking errors when calling into tango code.
To build the Tango user library, go to the tango/lib directory and run bash build-tango.sh ldc. Copy the resulting libtango-user-ldc.a to LDC's lib directory and adjust your bin/ldc.conf to include -L-ltango-user-ldc.
Alternatively you can use Rebuild ...
Using Rebuild
Rebuild has some advantages to using a static Tango library (as described above). It compiles and links only to the modules you actually need, and changing the compiler options, for all the modules your application needs, is easy.
If you want to use DSSS or Rebuild with LDC, install the ldc-tango Rebuild profile from the root dir:
mkdir -p $HOME/.rebuild ln -s `pwd`/ldc-tango $HOME/.rebuild
After you made sure that LDC is in PATH, you can use Rebuild from anywhere.
export PATH=$PATH:`pwd`/bin rebuild -dc=ldc-tango test.d
Submitting Patches
Clone the Mercurial repository, make your changes, then use hg export and submit a ticket with patch attached. Alternatively send the output to either lindquist or ChristianK:
hg export <revision> > blah-blah.patch

