如何在Mac OS X 10.9中编写llvm pass

Bar*_*tar 5 macos llvm

我在Linux上建立了传递,它在那里正常工作.现在,当我在Mac Airbook上将我的代码引入Mac OS X 10.9时,它已经不再适用了.我在下面描述了构建llvm传递所采取的步骤.

我的源代码树是llvm-3.4和llv-3.4/tools/clang-3.4

我跑了./configure --prefix=/some-path --enable-targets=host哪个成功了.

然后我运行make && make install完成没有任何错误.

我导出了bin路径export PATH=/some-path/bin:$path并检查了which clang which opt,他们指向我的安装.

现在,当我尝试加载hello pass时,opt -load /some-path/lib/LLVMHello.dylib -hello <fac.bc >/dev/null我收到以下错误

Error opening '/some-path/lib/LLVMHello.dylib': dlopen(/some-path/lib/LLVMHello.dylib, 9): Symbol not found: __ZN4llvm12FunctionPass17assignPassManagerERNS_7PMStackENS_15PassManagerTypeE Referenced from: /some-path/lib/LLVMHello.dylib Expected in: flat namespace in /some-path/lib/LLVMHello.dylib -load request ignored. opt: Unknown command line argument '-hello'. Try: '/some-path/bin/opt -help' opt: Did you mean '-help'?

有人可以帮我解决这个问题,或者至少指出正确的方向.

小智 1

就我而言,缺少动态加载过程所需的动态 LLVM 库。我通过使用 --enable-shared 配置 LLVM 解决了这个问题。我还设置了 --enable-keep-symbols ,但我认为这是没有必要的。我使用的完整配置命令:

./configure --enable-shared --enable-keep-symbols
Run Code Online (Sandbox Code Playgroud)

我知道我的答案有点晚了,但我最近遇到了同样的问题。由于我花了相当长的时间来解决这个问题,所以我想传达我的发现。希望能帮助到你。

干杯,马库斯