[LLVMdev] How to link the right libraries?
Fernando Magno Quintao Pereira
fernando at CS.UCLA.EDU
Mon May 1 12:41:43 PDT 2006
Hello, llvmers. Could someone explain me a little about the opt tool? I am
having problems to load a MachineFunctionPass using opt. I have this pass:
#include "llvm/Pass.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include <iostream>
using namespace llvm;
namespace {
struct MacFoo : public MachineFunctionPass {
virtual bool runOnMachineFunction(MachineFunction &Fn) {
std::cerr << " calling run machine function.\n";
return false;
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
virtual const char *getPassName() const {
return "run on machine function";
}
};
RegisterOpt<MacFoo> Z("allocpty", "Register Allocation Prototype Pass");
struct FuncFoo : public FunctionPass {
virtual bool runOnFunction(Function &F) {
std::cerr << "Function name: " << F.getName() << "\n";
return false;
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
};
RegisterOpt<FuncFoo> X("funcPass", "Hello World Pass");
}
When I call:
$> opt -load ../../../../llvm/Debug/lib/LLVMTest.so -funcPass < hello.bc >
/dev/null
It works fine; when I try the machineFunctionPass class, it goes like
this:
$> opt -load ../../../../llvm/Debug/lib/LLVMTest.so -allocpty < hello.bc >
/dev/null
"opt: error while loading shared libraries:
../../../../llvm/Debug/lib/LLVMTest.so: undefined symbol:
_ZN4llvm15MachineFunction3getEPKNS_8FunctionE"
I would really appreciate if someone could tell me which files do I have
to link to make the 'allocpty' to work. My Makefile is this:
LEVEL = ../../.. # points to $HOME/llvm
LIBRARYNAME = LLVMTest
SHARED_LIBRARY = 1
LOADABLE_MODULE = 1
include $(LEVEL)/Makefile.common
warm regards,
Fernando
More information about the llvm-dev
mailing list