[LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so

Shuguang Feng shuguang.feng at gmail.com
Sun Jul 19 14:42:34 PDT 2009


Hey Chuck,

I'm afraid I can't reproduce your error but...a problem you may run
into later is that opt will complain with

opt: llvm/lib/VMCore/Pass.cpp:149:
void<unnamed>::PassRegistrar::RegisterPass(const llvm::PassInfo&):
Assertion `Inserted && "Pass registered multiple times!"' failed.
Aborted

I "fixed" this by replacing the LLVMLIBS line in the Makefile with
LINK_COMPONENTS according to this tutorial http://llvm.org/docs/MakefileGuide.html#LoadableModules
and was able to build/run my pass properly.

-shu

On Jul 17, 11:48 am, Chuck Zhao <cz... at eecg.toronto.edu> wrote:
> While learning to write LLVM passes and following the precise
> instructions underhttp://llvm.org/docs/WritingAnLLVMPass.html,
> <http://llvm.org/docs/WritingAnLLVMPass.html>
> I got this error when loading the hello pass to run the test program:
>
> opt -load ./Release/lib/Hello.so -hello < test/test.bc > /dev/null
> Error opening './Release/lib/Hello.so': ./Release/lib/Hello.so:
> undefined symbol:
> _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_i
>   -load request ignored.
>   opt: Unknown command line argument '-hello'.  Try: 'opt --help'
>   make: *** [run_lib] Error 1
>
> I think I might have missed a LLVM lib file, but can't figure out which.
>
> I double checked the Makefile, it does have the libLLVMCore.a,
> libLLVMSystem.a and libLLVMSupport.a specified.
>
> Could people suggest?
>
> All are based on the LLVM  2.5 release, running on Debian4-i386.
>
> Thank you very much
>
> Chuck
>
> Hello.cpp file:
> #include "llvm/Pass.h"
> #include "llvm/Function.h"
>
> using namespace llvm;
>
> namespace {
>   struct Hello : public FunctionPass {
>
>     static char ID;
>     Hello() : FunctionPass(&ID) {}
>
>     virtual bool runOnFunction(Function &F) {
>       llvm::cerr << "Hello: " << F.getName() << "\n";
>       return false;
>     }
>   };
>
>   char Hello::ID = 0;
>   RegisterPass<Hello> X("hello", "Hello World Pass");
>
> }
>
> Makefile:
> # Makefile for hello pass
>
> # Path to top level of LLVM heirarchy
> LEVEL = .
>
> # Name of the library to build
> LIBRARYNAME = Hello
>
> # Make the shared library become a loadable module so the tools can
> # dlopen/dlsym on the resulting library.
> LOADABLE_MODULE = 1
>
> # Tell the build system which LLVM libraries your pass needs. You'll
> probably
> # need at least LLVMSystem.a, LLVMSupport.a, LLVMCore.a but possibly several
> # others too.
> LLVMLIBS = LLVMCore.a LLVMSupport.a LLVMSystem.a
>
> # Include the makefile implementation stuff
> include $(LEVEL)/Makefile.common
>
> _______________________________________________
> LLVM Developers mailing list
> LLVM... at cs.uiuc.edu        http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list