<p dir="ltr">On Oct 3, 2013 11:47 PM, "Rekha R" <<a href="mailto:rekharamapai@nitc.ac.in">rekharamapai@nitc.ac.in</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I was trying to write a sample optimization pass in LLVM, by following instructions in LLVM doc for Writing a New Pass. But then ran into make issues. The issue is with having separate source and build directories. The LLVM doc for 'Getting Started' suggests keeping the two separate, but the 'Writing a new pass' doc assumes they are merged. Hence the make issue.<br>
><br>
> I did a bit of googling and could not find a desired solution. The solutions proposed were to combine the source and build directories. <br>
><br>
> I am happy to say that I could find a solution with keeping source and build directories separate, as desired. I thought I could share it with newbies like me. <br>
><br>
> 0. Download LLVM source into /llvm-src and build it into /llvm-build directories.<br>
> 1. Write a new pass and Makefile as mentioned in LLVM doc 'Writing a new pass'. Assume it is created in /llvm-src/lib/Transforms/NewPass directory.<br>
> 2. Modify the Makefile in /llvm-src/lib/Transforms directory by adding NewPass under PARALLEL_DIRS.<br>
> 3. make in /llvm-build directory.<br>
> 4. Thats it. If things go fine, newpass.so will be created in /llvm-build/Debug+Asserts/lib directory.<br>
> 5. The new pass can be loaded by modifying the command mentioned in the LLVM doc (for Writing a new pass) as<br>
> <br>
><br>
> opt -load /llvm-build/Debug+Asserts/lib/newpass.so -newpass < hello.bc > /dev/null<br>
><br>
> Hope this helps.<br>
><br>
> -- <br>
> Rekha<br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
></p>
<p dir="ltr">A long ago I've added support for developing passes outside source dir for CMake build system. There should be documentation on this.</p>