<div dir="ltr">I'm moving a couple of dynamically loaded passes <div>from an older version of LLVM to a newer one.<div>I fixed various small compilation errors, and things compile now,</div><div>but the resulting .so won't load without error.</div></div><div><br></div><div>So I re-read the manual (Writing an LLVM Pass) and tried the</div><div>first example, Hello.cpp which produces LLVMHello.cpp</div><div>The code's already there in the source tree and it builds</div><div>and loads correctly. So I tried copying the directory</div><div>and doing a little editing. It builds but again fails to load.</div><div><br></div><div>Here's what I type</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>opt -load LLVMZap.so -help</div></div></blockquote><div><div><br></div><div>and here's what I see</div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>Error opening 'LLVMZap.so': /home/briggs/llvm-cilk/new_install/bin/../lib/LLVMZap.so: undefined symbol: _ZNK4llvm12FunctionPass17createPrinterPassERNS_11raw_ostreamERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE</div></div><div><div>  -load request ignored.</div></div></blockquote><div><br></div><div>The error message is quite similar to what I see when I'm experimenting with my old pass.</div><div><br></div><div>Any ideas?</div><div><br></div><div>Here's the contents of CMake.txt</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div># If we don't need RTTI or EH, there's no reason to export anything</div></div><div><div># from the hello plugin.</div></div><div><div>if( NOT LLVM_REQUIRES_RTTI )</div></div><div><div>  if( NOT LLVM_REQUIRES_EH )</div></div><div><div>    set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Zap.exports)</div></div><div><div>  endif()</div></div><div><div>endif()</div></div><div><div><br></div></div><div><div>add_llvm_loadable_module( LLVMZap</div></div><div><div>  Zap.cpp</div></div><div><div><br></div></div><div><div>  DEPENDS</div></div><div><div>  intrinsics_gen</div></div><div><div>  PLUGIN_TOOL</div></div><div><div>  opt</div></div><div><div>  )</div></div></blockquote><div><br></div><div>And the contents of Zap.cpp</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><br></div><div><div>#include "llvm/IR/Function.h"</div></div><div><div>#include "llvm/Pass.h"</div></div><div><div>#include "llvm/Support/raw_ostream.h"</div></div><div><div>using namespace llvm;</div></div><div><div><br></div></div><div><div>namespace {</div></div><div><div>  struct Zap : public FunctionPass {</div></div><div><div>    static char ID; // Pass identification, replacement for typeid</div></div><div><div>    Zap() : FunctionPass(ID) {}</div></div><div><div><br></div></div><div><div>    bool runOnFunction(Function &F) override {</div></div><div><div>      errs() << "Zap! ";</div></div><div><div>      errs().write_escaped(F.getName()) << '\n';</div></div><div><div>      return false;</div></div><div><div>    }</div></div><div><div>  };</div></div><div><div>}</div></div><div><div><br></div></div><div><div>char Zap::ID = 0;</div></div><div><div>static RegisterPass<Zap> X("zap", "Zap Pass");</div></div></blockquote></div><div><br></div><div>Thanks,</div><div>Preston</div><div><br></div></div>