Correct Way to Build an LLVM Pass


I wrote an LLVM transformation pass and I put my code inside the llvm-src/lib/Transforms/my-pass directory. I want to know what is the correct method for compiling it and building my plugin for the pass. After reading the page, I felt that I have to keep my pass inside the above said directory. But when I run make from inside my-pass directory but I am getting the errors -

…/…/…/Makefile.common:60: …/…/…/Makefile.config: No such file or directory
…/…/…/Makefile.common:68: /Makefile.rules: No such file or directory
make: *** No rule to make target `/Makefile.rules’. Stop.

Which kinds of makes sense as there is no Makefile.config in the llvm-src directory.

So I tried to place my-pass directory inside the llvm-build/lib/Transforms directory and run make from there. But got the following error -

make: *** No rule to make target /home/arnie/llvm-development/llvm/lib/Transforms/LoopMem/Makefile', needed by Makefile’. Stop.

However, if I configure and build the whole LLVM again (with my pass), it is able to produce the shared library. Is it the only way to integrate my pass into LLVM? Because, every time I modify my pass, I have to rebuilt LLVM which takes close to half-an-hour to build?

Thank you;

You do not have to keep it under llvm src tree. shows how to setup a project outside the src root
and it applies for writing a Pass. But as first step of practicing, staying inside the src
root will save some efforts.

Not sure about your errors. But one mistake I made is that configure was invokded using
…/llvm-src/configure from llvm-build, and then I put pass in llvm-src. make failed because
the top level is in llvm-build(if I understand it correctly). So I reinvoke ./configure in llvm-src
to let it re-generate Makefiles. And then it’s ok. Hope it helps.