[LLVMdev] How build a library with llvm-ld

jonathan bioinfornatics at gmail.com
Mon Oct 24 14:58:44 PDT 2011


In first, i hope i can discuss here
I would like generate a shared lib without gcc but i fail.
With my D compiler i do:
$ ldc2 --output-bc --output-o  -op -release -c -relocation-model=pic
-od=../build *.d

llvm bytecode finish with .wc and are in ../build directory

$ cd ../build
$ lvm-ld -link-as-library -o libDparser.bc -L/usr/local/lib64/
-L/usr/lib64 -ldruntime-ldc -llphobos2 -lm -ldl -lrt -soname=Dparser
*.bc
$ llc -relocation-model=pic libDparser.bcgcc -shared libDparser.s -o
libDparser.so
$ gcc -shared libDparser.s -o libDparser.so

it works

with gcc i can do this in one line:
$  gcc -Dlphobos2_EXPORTS -DDMDV2 -DIN_LLVM -D_DH -DOPAQUE_VTBLS -DPOSIX
-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC
-shared build/*.o -o libDparser.so


So why use first method? they are not a better way fully llvm ?


kind regards




More information about the llvm-dev mailing list