[LLVMdev] Pass options to the linker
Jorge A. Navas
navas at comp.nus.edu.sg
Tue Nov 15 01:54:09 PST 2011
On Tuesday, November 15, 2011 at 10:11:25 (+0100), Duncan Sands wrote:
>> Hi Jorge,
>>
>> > I'm trying to use the PPL (Parma Polyhedra Library,
>> > bugseng.com/products/ppl) in one of my LLVM passes getting the error:
>> >
>> >> Error opening
>> >> '/home/jorge/SvnReps/Systems/llvm/build/Debug+Asserts/lib/MyAnalysis.so':
>> >> /home/jorge/SvnReps/Systems/llvm/build/Debug+Asserts/lib/MyAnalysis.so:
>> >> undefined symbol: _ZNK23Parma_Polyhedra_Library13PIP_Tree_Node2OKEv
>> >> -load request ignored.
>>
>> was MyAnalysis.so linked with the PPL library? Run
>> ldd MyAnalysis.so
>> to see what it was linked with.
>>
Not ;-( the output of ldd MyAnalysis.so is:
linux-gate.so.1 => (0xb78ce000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb7897000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb77ac000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb778d000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7611000)
/lib/ld-linux.so.2 (0xb78cf000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb75e7000)
So I guess, my problem is in LD.Flags ?
>> LEVEL=../../../..
>> LIBRARYNAME=MyAnalysis
>> LOADABLE_MODULE=1
>> SHARED_LIBRARY=1
>> include $(LEVEL)/Makefile.common
>>
>> # These two lines are new:
>> CXX.Flags += -I/home/jorge/include -fexceptions -Wno-variadic-macros
>> LD.Flags += -L/home/jorge/lib -lppl -lgmp
>> Ciao, Duncan.
>>
>> >
>> > Let me explain how I get to this point.
>> >
>> > To make simpler my explanation I took the "Hello World" pass provided
>> > in the directory llvm/lib/Transforms/Hello/Hello.cpp.
>> >
>> > I compiled Hello.cpp using the Makefile:
>> >
>> >> LEVEL=../../../..
>> >> LIBRARYNAME=MyAnalysis
>> >> LOADABLE_MODULE=1
>> >> SHARED_LIBRARY=1
>> >> include $(LEVEL)/Makefile.common
>> >
>> > and then:
>> >
>> > clang test.c -c -emit-llvm -o test.bc
>> > opt -load /home/jorge/SvnReps/Systems/llvm/build/Debug+Asserts/lib/MyAnalysis.so -hello -stats test.bc
>> >
>> >> Hello: modulo
>> >> ===-------------------------------------------------------------------------===
>> >> ... Statistics Collected ...
>> >> ===-------------------------------------------------------------------------===
>> >> 1 hello - Counts number of functions greeted
>> >
>> > So far, so good. No compiler/linker errors and I get the expected
>> > output.
>> >
>> > Now, in order to use PPL from my Hello pass I just need (based on PPL
>> > documentation) to add in Hello.cpp the header:
>> >
>> > #include<ppl.hh>
>> >
>> > and then I modify the above Makefile as follows:
>> >
>> >> LEVEL=../../../..
>> >> LIBRARYNAME=MyAnalysis
>> >> LOADABLE_MODULE=1
>> >> SHARED_LIBRARY=1
>> >> include $(LEVEL)/Makefile.common
>> >
>> >> # These two lines are new:
>> >> CXX.Flags += -I/home/jorge/include -fexceptions -Wno-variadic-macros
>> >> LD.Flags += -L/home/jorge/lib -lppl -lgmp
>> >
>> > Then, it's when I get the above error:
>> >
>> >> Error opening
>> >> '/home/jorge/SvnReps/Systems/llvm/build/Debug+Asserts/lib/MyAnalysis.so':
>> >> /home/jorge/SvnReps/Systems/llvm/build/Debug+Asserts/lib/MyAnalysis.so:
>> > >undefined symbol: _ZNK23Parma_Polyhedra_Library13PIP_Tree_Node2OKEv
>> >
>> > It's important to mention that I can compile/link programs with the
>> > header "#include<ppl.hh>" without any problem using the command:
>> >
>> > g++ test.c -L/home/jorge/lib -lppl -lgmp -o test
>> >
>> > I guess the problem is how I pass the flags to the linker. Does
>> > anybody have a clue what I'm doing wrong?
>> >
>> > Thanks!
>> >
>> > Jorge
>> >
>> >
>> > _______________________________________________
>> > LLVM Developers mailing list
>> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list