1

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
4

2 回答 2

5

我遇到了同样的问题并通过重新阅读教程解决了这个问题:

首先,配置和构建 LLVM。这需要直接在 LLVM 源代码树内完成,而不是在单独的对象目录中完成。

这意味着您不应该按照 LLVM 入门中的建议创建“构建”文件夹。假设您在 中下载了 llvm 源代码$LLVM,下面是我让它工作的列表:

  • 在 $LLVM/lib/Transforms/ 中创建一个新文件夹,比如 MyHello,并在教程中创建一个 pass 所需的文件。

  • $cd $LLVM

  • $./配置

  • $make

  • $cd 库/转换/MyHello

  • $make

于 2013-03-10T01:25:27.323 回答
2

所以事实证明,当帮助文件显示“lib/Transforms/Hello”时,它的意思是“somestuff/llvm/lib/Transforms/Hello”而不是“/somestuff/build/lib/Transforms/Hello”。事后看来,这并不像它可能的那样不透明,但我想留下这个答案来帮助其他可能在文档中错过这个的人......

于 2012-07-30T18:09:56.770 回答