Using the llvm D-bindings [solved]
Manuel König
manuelk89 at gmx.net
Wed Oct 6 07:33:15 PDT 2010
Am Wed, 6 Oct 2010 14:36:16 +0200
schrieb Manuel König <manuelk89 at gmx.net>:
> >
> > You should probably ask LDC guys (irc://irc.freenode.net/ldc)
>
> Thanks, I'll try. But I think the development of LDC was put on hold
> due to lack of time and interest, let's see if I can find someone
> there :)
>
Well, the channel was actually full of people, and the problem was
solved quickly. Actually the solution was method (1), linking in the
stdc++ lib. For the record, here are some usage instructions for the
llvm bindings. I will commit them to the repositority later, but I'll
wait a bit and see if you have something to add.
Initial setup:
==============
(1) checkout from svn
(2) cd /path/to/llvm-2.7
(3) run prebuild.sh, this builds Target.o and Ext.o which have
to be passed to the linker. For convenience, these *.o files
are also merged into a single library libllvm-c-ext.a.
Note: Target.o and Ext.o are usually not needed for the regular llvm c
interface. But the D bindings add some extra bindings, because the
official c interface just doesn't expose all functionality from the c++
interface. These are implemented as a "c++ to c to d" bridge (c++ to c
is Target.cpp and Ext.cpp, c to d is Target.d and Ext.d).
Building your application:
==========================
To compile and link a file main.d, run
LLVMD=/path/to/llvm-dbindings
LLVM_LIBS=`llvm-config --libs | sed 's/-l/-L-l'`
ldc -I=$LLVMD \
-L=$LLVMD/{Target,Ext}.o \
$LLVM_LIBS \
-L-ldl -L-lstdc++ -relocation-model=pic \
main.d
Parameters:
LLVM_LIBS a list of all llvm libraries, formatted for
ldc -L=$LLVMD/{Target,Ext}.o only needed when you use Target.d or Ext.d
-L-lstdc++ links in the c++ standard library (llvm at
it's core is c++) -relocation-model=pic necessary for calling code
in your app from inside of the llvm vm
More information about the Digitalmars-d-learn
mailing list