link error for analysis pass

Hi all,

I create a folder containing my new alias analysis pass in the lib/Analysis folder of the source tree.
I mimic the way IPA did to create a LLVMipa.a library. That is, I write a Makefile to create my library
and I change the Makefile correspondingly in the Analysis folder.

However, when I want to use my new alias analysis in the Codegen. The compiler will complain
“undefined error” during the link phase. Could anyone point me out where I need to change in order
to use my new alias analysis pass in the Codegen?


Can you provide the link command that fails and the output?


Hi Mehdi,

I meant when I build the LLVM and it will give the following errors:

make[2]: Entering directory /home/alex/new/llvm-obj/tools/llc' llvm[2]: Linking Debug+Asserts executable llc /home/alex/new/llvm-obj/Debug+Asserts/lib/libLLVMCodeGen.a(Passes.o): In function llvm::TargetPassConfig::addIRPasses()’:
/home/alex/new/llvm-3.1.src/lib/CodeGen/Passes.cpp:295: undefined reference to llvm::createMyAliasAnalysisPass()' collect2: ld returned 1 exit status make[2]: *** [/home/alex/new/llvm-obj/Debug+Asserts/bin/llc] Error 1 make[2]: Leaving directory /home/alex/new/llvm-obj/tools/llc’
make[1]: *** [llc/.makeall] Error 2
make[1]: Leaving directory `/home/alex/new/llvm-obj/tools’
make: *** [all] Error 1


Since you created a new library, you need to add it as a dependency wherever you’re calling into it: see lib/CodeGen/LLVMBuild.txt

Also, on a side note, the Makefile/autotools build is deprecated, you may want to look at cmake.

Thanks a lot! Mehdi. I tried to change the LLVMBuild.txt. However, it doesn’t help under Makefile/autotools.
I will try cmake to rebuild the system again.

Thanks again,