Currently, users of the D programming language can essentially choose between two mature compilers: DMD and GDC. I’ve started helping with the development of a third, LDC, and think the first public alpha version can’t be far off. In this post, I’ll give a short overview of the compilers available and say a few words about LDC.
First, there is the reference compiler DMD that is maintained and improved by D’s inventor Walter Bright. It has a stable branch for D 1.0 as well as a bleeding edge counterpart for version 2.0 of the D specification that’s still under development. One part of it, the front-end responsible for parsing code, building a syntax tree and running semantics, is open source, available under the GPL or Artistic license. Its back-end, however, is not available and thus only Walter can compile DMD.
This is not a failing in itself. Indeed most users will never have the need or desire to compile their compiler from source. Yet it also prohibits testing patches for the front-end, makes debugging nigh impossible and generally complicates helping with DMD’s development.
The alternative – and often the only alternative if your target is not x86 Linux or Windows – is GDC. David Friedman took the open front-end and tied it to the GCC back-end, he even supports D 2.0 to some extend. While it works well and is fully open source, it has, unfortunately, remained a one-man effort. For me it was a combination of GCC’s daunting code base and the fact that there had been no activity for several months that stopped me from helping out.
Instead I eventually joined a different project: LDC. It is similar to GDC in that it also takes the open DMD front-end and aims to combine it with an equally free code generator. The back-end, though, is different: as the name suggests LDC emits LLVM bitcode, which can be compiled to native code, but could also be used for Just-in-Time compilation among other things. I’m also happy to say that even though LLVM is a large and ambitious project, it remains surprisingly easy to learn and work with.
Almost the first thing I did when I started contributing to LDC a few months back, was to integrate Thomas Kühne’s exhaustive DStress test suite with LDC: it is very useful for finding bugs and regressions and can even serve as a sort of crude progress indicator (crude because there is no relationship between number of bugs and number of tests; there are about 1000 tests for inline assembly and only 30 or so for exception handling). As you can see, there are still a handful (517 at the last count) of regressions with respect to DMD, but their number has been decreasing steadily.
In the last months, Tomas Lindquist Olsen, who started the project about a year ago and is responsible for almost all of its existing functionality, and I have added the last major missing parts to the compiler: inline assembly (thanks to David Friedman for the asm parsing and rewriting code!), exception handling and the synchronized statement are now supported. With these out of the way, goals for the future are squashing bugs, fixing some linking issues and getting LDC to work properly on Windows.
Speaking of other platforms: As Tomas and I both develop on x86 Linux, other configurations didn’t get much testing yet. Some people reported partial successes on FreeBSD and Sparc but more testers would be welcome. You can generally contact us by email or in #ldc on freenode. All in all, we’ve made great progress and if we can keep it up, LDC will be in the same league as DMD and GDC soon.
Comments 6
“For me it was a combination of GCC’s daunting code base and the fact that there had been no activity for several months that stopped me from helping out.”
Actually I found that even if you post on digitalmars.D.gnu and say “I’d like to help. What can I do?” You get no answer.
Basically it seems Dave for some reason wants to keep GDC as his own one-man project, but at the same time he has no time for it. Oh well. So much for GDC.
Long live LLVMDC!
BTW, congrats on getting exceptions working, too.
Posted 10 Jul 2008 at 10:57 ¶Wow, you got the exception handling in? Grats! I can’t wait to try this out.
Posted 10 Jul 2008 at 21:01 ¶@baxissimo everyone can just grab gdc sources and implement what they want, when it is working, dave will be happy to include this patches in mainline repository. In Debian and FreeBSD ports there are some patches for example, and they are slowly merged with Dave’s sources.
Compiler is big project and needs good knowledge of whole code and attention to some obscure special cases. Any way, DMD is reference implementation and anything which can go to GDC are curenly bug fixes. Noone (currently) wants to start next version of D language even for experiments because it will lead to chaos and compatibility issue. IMHO experiments whould be easier in LLVM infrastructure than in GDC.
PS. Some day there will be D compiler in D, but who knows when.
Posted 10 Jul 2008 at 22:29 ¶LLVMDC will be a great D programming language compiler.
Posted 11 Jul 2008 at 3:33 ¶Awesome! I love to see that you guys are still keeping it up! This is going to help D so much. The backend and the open nature of the project are very promising.
Although i’m rather idealistic about D, i had to refrain from using it for my last 2 larger projects. And this was all compiler related.
I believe that LLVMDC will make those worries go away.
I’ll help with OpenMP and CUDA extensions for my next project next year or so ;)
Posted 11 Jul 2008 at 9:50 ¶At the moment, I have found GDC to have some major bugs with no time line for seeing them fixed. It is good to see another 64-bit compiler being actively worked on.
Posted 11 Jul 2008 at 17:26 ¶Thanks for your work. Can’t wait for a usable version.