[LLVMdev] Unable to load a new pass: opt -load=plugin.so not working?

Arpan Sen arpansen at gmail.com
Thu Feb 16 02:40:59 PST 2012

Hello LLVM Folks,

I just tried running the example off
http://llvm.org/docs/WritingAnLLVMPass.html#quickstart. I used the same
code in the example to create a new pass called hello, and tried compiling
the same like:

The code for pass.cpp:

#include "llvm/Pass.h"
#include "llvm/Function.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {
  struct Hello : public FunctionPass {

    static char ID;
    Hello() : FunctionPass(ID) {}

    virtual bool runOnFunction(Function &F) {
      errs() << "Hello: ";
      errs().write_escaped(F.getName()) << '\n';
      return false;


char Hello::ID = 0;
static RegisterPass<Hello> X("hello", "Hello World Pass", false, false);

Compile Steps:
g++ -c pass.cpp -I/usr/local/include `llvm-config --cxxflags`
g++ -shared -o pass.so pass.o -L/usr/local/lib `llvm-config --ldflags

Followed by:
opt -load=pass.so -help

But I see no mention of hello in the output. I am using MacOSX Lion, and
the llvm code is something that I checked out recently from the trunk. I
ran nm on pass.so and the symbols for hello are present just fine.

Not sure what is that I missing here. Any help?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120216/0ff91a08/attachment.html>

More information about the llvm-dev mailing list