Reputation: 241
I am new to LLVM and I am trying to build my own pass. After reading through the documentation on Writing an LLVM Pass. I tried to create my own pass by adding a directory in the Transforms directory. However, when I try to make my source, it gives an error "make: * No rule to make target".
Do I have to rebuild LLVM if I want to make a new pass? If so, it would be very time consuming as I am running this on a Debian VM and it takes approximately half an hour to build it.
Let me know if there is a way around this. Any advice is appreciated. Thanks.
EDIT: Yes, I have the makefile. I am following the steps mentioned in the documentation.
# Makefile for hello pass
# Path to top level of LLVM hierarchy
LEVEL = ../../..
# Name of the library to build
LIBRARYNAME = Trial
# Make the shared library become a loadable module so the tools can
# dlopen/dlsym on the resulting library.
LOADABLE_MODULE = 1
# Include the makefile implementation stuff
include $(LEVEL)/Makefile.common
I am trying to make a simple function pass named Trial.
Upvotes: 0
Views: 1325
Reputation: 323
If you have an working installation of llvm
in your $PATH
then instead of putting the files in the Transforms directory as the documentation mentions, you can do the following
<create basic_block_pass.cpp with pass name myPass in any location>
$ clang++ -c basic_block_pass.cpp `llvm-config --cxxflags`
$ clang++ -shared -o pass.so basic_block_pass.o `llvm-config --ldflags`
$ opt -load ./pass.so -myPass < hello.bc > /dev/null
If you create a Makefile
to do the above steps you have a nice build system in place.
Upvotes: 6