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

Compiler construction 如何在LLVm中创建自己的通行证?,compiler-construction,llvm,Compiler Construction,Llvm,我是LLVM的新手,我正在尝试建立自己的通行证。在阅读了有关编写LLVM过程的文档之后。我试图通过在Transforms目录中添加一个目录来创建自己的过程。但是,当我尝试生成源代码时,它会给出一个错误“make:*无规则生成目标” 如果要进行新的传递,是否必须重建LLVM?如果是这样的话,这将是非常耗时的,因为我在Debian VM上运行它,构建它大约需要半个小时 如果有办法,请告诉我。任何建议都将不胜感激。谢谢 编辑: 是的,我有makefile。我正在遵循文档中提到的步骤 # Makefil

我是LLVM的新手,我正在尝试建立自己的通行证。在阅读了有关编写LLVM过程的文档之后。我试图通过在Transforms目录中添加一个目录来创建自己的过程。但是,当我尝试生成源代码时,它会给出一个错误“make:*无规则生成目标”

如果要进行新的传递,是否必须重建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

我正在尝试使一个名为试用的简单函数通过。

如果您在
$PATH
中安装了
llvm
,那么您可以执行以下操作,而不是像文档中提到的那样将文件放在Transforms目录中

<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

$clang++-c basic_block_pass.cpp`llvm config--cxflags`
$clang++-shared-o pass.so basic_block_pass.o`llvm config--ldflags`
$opt-load./pass.so-myPass/dev/null

如果您创建了一个
Makefile
来执行上述步骤,那么您就有了一个很好的构建系统。

如果您在
$PATH
中安装了
llvm
,那么您可以执行以下操作,而不是像文档中提到的那样将文件放在Transforms目录中

<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

$clang++-c basic_block_pass.cpp`llvm config--cxflags`
$clang++-shared-o pass.so basic_block_pass.o`llvm config--ldflags`
$opt-load./pass.so-myPass/dev/null

如果您创建一个
Makefile
来执行上述步骤,那么您就有了一个很好的构建系统。

您有Makefile吗?您最好在LLVM irc频道或他们的邮件列表中问这个问题。您有Makefile吗?您最好在LLVM irc频道或他们的邮件列表中问这个问题。