Re: Using the llvm D-bindings [solved]

2010-10-06 Thread mwarning
On Wed, 06 Oct 2010 16:57:09 +0200, Manuel König wrote:

> LLVM_LIBS=`llvm-config --libs | sed 's/-l/-L-l'`

typo detected, you need:
sed 's/-l/-L-l/g'

:)


Re: Using the llvm D-bindings [solved]

2010-10-06 Thread Manuel König
The previous "Initial setup" description didn't pass the "copy paste"
test, now it's more instructive. The same should work for llvm 2.6 and
2.8, too (yes, 2.8 was just released and the bindings are already
there :)

Initial setup:
==

svn co http://svn.dsource.org/projects/bindings/trunk/llvm-2.7
cd llvm-2.7
./prebuild.sh

prebuild.sh 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.

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 \
$LLVM_LIBS \
-L=$LLVMD/libllvm-c-ext.a \
-L-ldl -L-lstdc++ -relocation-model=pic \
main.d 

Parameters:
LLVM_LIBS a list of all llvm libraries, formatted for
ldc -L=$LLVMD/libllvm-c-ext.a 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


Re: Using the llvm D-bindings [solved]

2010-10-06 Thread Manuel König
Am Wed, 6 Oct 2010 14:36:16 +0200
schrieb Manuel König :

> > 
> > 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