Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login
Version 68 (modified by ChristianK, 16 years ago)
--

LLVM D Compiler

LLVMDC is a compiler for the D programming Language. It is based on the latest DMD 1.0 frontend and uses LLVM 2.3 as backend. LLVM provides a fast and modern backend for high quality code generation.

While x86, x86-64, PPC and PPC64 architectures should be supported, only x86 and x86-64 on Linux have been tested. There may be problems on other platforms and architectures. Some work has been done getting LLVMDC running on Win32 using the MinGW/MSYS toolkit. See the LLVMDC on Windows? page for more information.

Quite a bit of D code already compiles but LLVMDC is not yet close to being production 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 LLVMDC revisions among themselves and to DMD. However, some of the test cases in DStress are not correct, help us make our list of broken DStress tests complete.

If you're still looking for something to do, take a look at the broken Tango modules? page for inspiration ;)

Any feedback is much appreciated, either on IRC (#llvmdc at FreeNode), the forum or through the tracker. Alternatively you can send me a gmail at: 'tomas.l.olsen'.

D binding for LLVM

While not part of the LLVMDC compiler, a binding to LLVM for D can also be found in the subversion 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.

How To Compile

Dependencies:

First get LLVM 2.3, download it from the LLVM website: http://llvm.org/releases/download.html#2.3

You will also need Premake to generate the Makefile, as well as (optionally) the Hans Boehm GC for C/C++ (ArchLinux users get the 'gc' package, Gentoo users - emerge 'boehm-gc', don't forget to check what version you are installing).

Grab LLVMDC from the SVN repository:

svn co http://svn.dsource.org/projects/llvmdc/trunk llvmdc
cd llvmdc

Alternatively, you can use the hgsvn-assisted Mercurial repository (updated nightly). It's useful for experimental work:

hg clone http://hg.andersman.org/llvmdc-svn
cd llvmdc-svn

Generate the makefile:

premake --target gnu

If you don't want to use the Boehm GC, pass --no-boehm to premake as well.

Compile LLVMDC:

make

Put LLVMDC into your path. This is necessary if you want it to be easy:

export PATH=$PATH:`pwd`/bin

Compile the runtime (Tango) for your architecture:

cd tango/lib
make -f llvmdc-posix.mak

Symlink the .a files to the place where the compiler will look for them:

cp -s `pwd`/*-llvmdc*.a ../../lib
cd ../../

Try it out, for instance on the tests in tangotests/. Note that only some of them contain a main(). Please report any problems you might have, and good luck :)

Using Rebuild

Finally, if you want to use dsss or rebuild with llvmdc, install the llvmdc-posix and llvmdc-posix-internal rebuild profiles:

mkdir -p $HOME/.rebuild
ln -s `pwd`/llvmdc-posix $HOME/.rebuild
ln -s `pwd`/llvmdc-posix-internal $HOME/.rebuild

After you made sure that llvmdc is in PATH, you can use rebuild from anywhere.

export PATH=$PATH:`pwd`/bin
rebuild -dc=llvmdc-posix test.d
Copyright © 2008, LDC Development Team.