如何在 LLVm 中创建自己的通行证?

use*_*668 0 compiler-construction llvm

我是 LLVM 的新手,我正在尝试构建自己的通行证。通读有关编写 LLVM 通行证的文档后。我试图通过在 Transforms 目录中添加一个目录来创建自己的通行证。但是,当我尝试制作我的源时,它给出了一个错误“制作:*没有制作目标的规则”。

如果我想进行新的传递,是否必须重建 LLVM?如果是这样,那将非常耗时,因为我在 Debian VM 上运行它并且构建它大约需要半小时。

让我知道是否有办法解决这个问题。任何建议表示赞赏。谢谢。

编辑:是的,我有 makefile。我正在按照文档中提到的步骤进行操作。

# 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
Run Code Online (Sandbox Code Playgroud)

我正在尝试制作一个名为 Trial 的简单函数传递。

vPr*_*tor 5

如果你有一个工作安装llvm在$PATH随后的而不是把这些文件中变换目录的文件中提到,你可以做以下

<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
Run Code Online (Sandbox Code Playgroud)

如果您创建一个Makefile来执行上述步骤,您就拥有了一个不错的构建系统。