Self-hosting D compiler -- Coming Real Soon Now(tm)

Dan Olson via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 13 16:29:33 PDT 2014


"Kai Nacke" <kai at redstar.de> writes:

> On Friday, 12 September 2014 at 10:06:10 UTC, Sergey Korshunoff via
> Digitalmars-d wrote:
>>
>> LDC and LLVM allow to comvert a D source code to C source (and may
>> be
>> to C++). What wrong with this solution?
>
> There's nothing wrong with this solution. I think about this as a way
> to bootstrap LDC without requiring another D compiler.
>
> Regards,
> Kai

This seemed like a fun solution but I found out the LLVM C backend was
removed with LLVM 3.1.  There is also a cpp backend, but is different.
Cpp target generates C++ code using LLVM API that will rebuild LLVM IR.
I tried it on a simple D program to be sure and result is just IR.

$ ldc2 -output-ll hello.d
$ llc -march=cpp hello.ll -o output.cpp

and output.cpp has to be linked with some llvm libraries.  Also,
output.cpp needed some hand edits to get it to work despite the
"// Generated by llvm2cpp - DO NOT MODIFY!"  warning at the top.

when run output.cpp just prints IR (essentially same as hello.ll).

http://stackoverflow.com/questions/11597664/llvm-cpp-backend-does-it-replace-c-backend


More information about the Digitalmars-d mailing list