[LLVMdev] Build problems with custom pass living in its own directory (under Transforms)

Frank Winter fwinter at jlab.org
Tue Jun 23 12:32:02 PDT 2015


I am having trouble integrating my custom pass into the build system 
such that it gets build along with the rest of the components and it's 
usable from code that links to LLVM.

My pass lives here:
ls -l lib/Transforms/qdp_jit/
LLVMBuild.txt  Makefile  qdp_jit.exports  qdp_jit_roll.cpp

Makefile:
----

LEVEL = ../../..
LIBRARYNAME = qdp_jit
LOADABLE_MODULE = 1
USEDLIBS =

# If we don't need RTTI or EH, there's no reason to export anything
# from the hello plugin.

ifneq ($(REQUIRES_RTTI), 1)
ifneq ($(REQUIRES_EH), 1)
EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/qdp_jit.exports
endif
endif

include $(LEVEL)/Makefile.common


qdp_jit.exports is an empty file


LLVMBuild.txt
----

[component_0]
type = Library
name = qdp_jit
parent = Transforms
library_name = qdp_jit
required_libraries = Analysis Core Support Target TransformUtils



cat lib/Transforms/LLVMBuild.txt

[common]
subdirectories = IPO InstCombine Instrumentation Scalar Utils Vectorize 
ObjCARC qdp_jit
...


cat lib/Transforms/Makefile

PARALLEL_DIRS = Utils Instrumentation Scalar InstCombine IPO Vectorize 
Hello ObjCARC qdp_jit


For simplicity I added the pass declaration to the already existent 
Transforms/Scalars.h
   //
   FunctionPass *create_qdp_jit_roll_pass();


cat LinkAllPasses.h

...
       (void) llvm::createSeparateConstOffsetFromGEPPass();
       (void) llvm::createRewriteSymbolsPass();
       (void) llvm::create_qdp_jit_roll_pass();/// <---
...



When building LLVM I keep getting:


llvm[2]: Linking Debug+Asserts executable opt
/home/fwinter/toolchain/build/llvm-3.6/tools/opt/Debug+Asserts/opt.o: In 
function `ForcePassLinking':
/home/fwinter/svn/llvm-3.6/include/llvm/LinkAllPasses.h:169: undefined 
reference to `llvm::create_qdp_jit_roll_pass()'




I then tried adding the library to opt's makefile (and LLVMBuild.txt) a la

LINK_COMPONENTS := bitreader bitwriter asmparser irreader 
instrumentation scalaropts objcarcopts ipo vectorize all-targets codegen 
qdp_jit

Same thing.

I remember this has happened to me in the past, my workaround was to put 
the pass into a pre-existing directory (say Transforms/Scalar). But this 
time I like it to reside in its own space.

Any ideas?
Frank







More information about the llvm-dev mailing list