Joe
Joe

Reputation: 4514

Writing an LLVM Pass - failing

I'm working though http://llvm.org/docs/WritingAnLLVMPass.html, trying to write a very simple pass. (Assume I'm using 'Joe' rather than 'hello', because there is already a 'hello' in the relevant directory)

I create the directory 'joe' where I should , I create the suggested cpp file in 'joe' (although I note that none of the nearby directory's have any cpp files in them) and I name it 'joe.cpp' because I don't believe I've been told differently...

I reach the part of the documentation where it says 'compile the file with a simple "gmake" command in the local directory' but I get the error

make: *** No rule to make target /Users/joXXXXX/llvm/llvm/lib/Transforms/joe/Makefile', needed byMakefile'. Stop.

which is utterly confusing. I note the similarity to this case, but in that case running ../config and then a make in the root directory solved in the problem. In my task this takes 20 minutes and then nothing has changed... could anyone tell me what is meant to have happened or give me a trace of what success looks like?

Edit - Local Makefile looks like this:

# Makefile for hello pass
#
# # Path to top level of LLVM hierarchy
LEVEL = ../../..
#
# # Name of the library to build
LIBRARYNAME = joe
#
# # Make the shared library become a loadable module so the tools can 
# # dlopen/dlsym on the resulting library.
# LOADABLE_MODULE = 1
BUILD_ARCHIVE = 1
# # Include the makefile implementation stuff
include $(LEVEL)/Makefile.common

Upvotes: 1

Views: 1975

Answers (2)

Phu
Phu

Reputation: 51

I faced the same problem and resolved this by re-reading the tutorial:

First, configure and build LLVM. This needs to be done directly inside the LLVM source tree rather than in a separate objects directory.

It means that you should not create a "build" folder as recommended in LLVM get started. Assume you downloaded the llvm source in $LLVM, here is list that I made it works:

  • create a new folder, let says MyHello, in $LLVM/lib/Transforms/ and necessary files for a pass as in the tutorial.

  • $cd $LLVM

  • $./configure

  • $make

  • $cd lib/Transforms/MyHello

  • $make

Upvotes: 5

Joe
Joe

Reputation: 4514

So it turns out that when the helpfile says 'lib/Transforms/Hello' it means 'somestuff/llvm/lib/Transforms/Hello' not '/somestuff/build/lib/Transforms/Hello'. In hindsight this is not as opaque as it could be, but I'd like to leave this answer to help other people who might have missed this in the doc...

Upvotes: 2

Related Questions