[llvm-dev] writing a pass, questions (original) (raw)
Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 10 22:06:28 PDT 2017
- Previous message: [llvm-dev] writing a pass, questions
- Next message: [llvm-dev] writing a pass, questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Can you double-check the shared objects LLVMZap.so references (ldd on Linux)? If you don't see LLVM's Core and Support libraries listed, you might hit this error.
One possible fix is to add this to CMakeLists.txt:
set(LLVM_LINK_COMPONENTS Core Support)
vedant
On Apr 10, 2017, at 8:57 PM, Preston Briggs via llvm-dev <llvm-dev at lists.llvm.org> wrote:
I'm moving a couple of dynamically loaded passes from an older version of LLVM to a newer one. I fixed various small compilation errors, and things compile now, but the resulting .so won't load without error. So I re-read the manual (Writing an LLVM Pass) and tried the first example, Hello.cpp which produces LLVMHello.cpp The code's already there in the source tree and it builds and loads correctly. So I tried copying the directory and doing a little editing. It builds but again fails to load. Here's what I type opt -load LLVMZap.so -help and here's what I see Error opening 'LLVMZap.so': /home/briggs/llvm-cilk/newinstall/bin/../lib/LLVMZap.so: undefined symbol: ZNK4llvm12FunctionPass17createPrinterPassERNS11rawostreamERKNSt3_112basicstringIcNS311chartraitsIcEENS39allocatorIcEEEE -load request ignored. The error message is quite similar to what I see when I'm experimenting with my old pass. Any ideas? Here's the contents of CMake.txt # If we don't need RTTI or EH, there's no reason to export anything # from the hello plugin. if( NOT LLVMREQUIRESRTTI ) if( NOT LLVMREQUIRESEH ) set(LLVMEXPORTEDSYMBOLFILE ${CMAKECURRENTSOURCEDIR}/Zap.exports) endif() endif() addllvmloadablemodule( LLVMZap Zap.cpp DEPENDS intrinsicsgen PLUGINTOOL opt ) And the contents of Zap.cpp #include "llvm/IR/Function.h" #include "llvm/Pass.h" #include "llvm/Support/rawostream.h" using namespace llvm; namespace { struct Zap : public FunctionPass { static char ID; // Pass identification, replacement for typeid Zap() : FunctionPass(ID) {} bool runOnFunction(Function &F) override { errs() << "Zap! ";_ _errs().writeescaped(F.getName()) << '\n';_ _return false;_ _}_ _};_ _}_ _char Zap::ID = 0;_ _static RegisterPass X("zap", "Zap Pass"); Thanks, Preston
LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
- Previous message: [llvm-dev] writing a pass, questions
- Next message: [llvm-dev] writing a pass, questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]