[LLVMdev] Pass options to the linker

Jorge A. Navas navas at comp.nus.edu.sg
Tue Nov 15 00:14:28 PST 2011


Hi all,

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.

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





More information about the llvm-dev mailing list