Chuck Zhao
2009-Jul-17 15:48 UTC
[LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so
While learning to write LLVM passes and following the precise instructions under http://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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090717/28c1bd3c/attachment.html>
Shuguang Feng
2009-Jul-19 21:42 UTC
[LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so
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
Chuck Zhao
2009-Jul-19 22:08 UTC
[LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so
Thanks, Shu, I guess I haven't updated since my post went out. There are actually 2 problems: 1. mis-compilation: My LLVM-2.5 turned out to be mis-compiled using gcc-4.4.0 (surprise to me) on Debian4-32b. I tried a few different compilers, and gcc-4.0.4 (a relatively old one, again surprised me) seems to work out fine. Question: is there a good/quick/reliable way to figure out whether a certain gcc compiler will mis-compile? 2. I ran into exactly the problem you pointed out. (Thank you) The Makefile needs some update (after careful comparison between the tutorial Makefile and the makefile used for lib/Transformation/Hello), by commenting out the following line: #LLVMLIBS = LLVMCore.a LLVMSystem.a LLVMSupport.a I guess the tutorial needs some update, as with release 2.5 things might have changed a bit. Thanks for the reply Chuck Shuguang Feng wrote:> 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:48am, 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 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 >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090719/afb890e8/attachment.html>
Possibly Parallel Threads
- [LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so
- [LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so
- [LLVMdev] LLVM Hello Pass load error when using opt -load Hello.so
- [LLVMdev] Pass registered multiple times!
- [LLVMdev] Hello example plugin has unresolved symbol in llvm 2.7