LLVM:OSX上的优化加载失败

时间:2013-03-18 11:37:43

标签: macos llvm clang

我正在尝试运行此LLVM instrumentation project,但我只能在Linux下加载检测优化。

我已经在OSX上编译并安装了LLVM 3.2和Clang 3.2,并且在Linux中具有相同的版本。

当我尝试在Linux中运行时:

command opt -load ./obj/llvminstrument/libllvminstrument.so -help |grep instrum
    -insert-edge-profiling                     - Insert instrumentation for edge profiling
    -insert-gcov-profiling                     - Insert instrumentation for GCOV profiling
    -insert-optimal-edge-profiling             - Insert optimal instrumentation for edge profiling
    -insert-path-profiling                     - Insert instrumentation for Ball-Larus path profiling
    -instrument_block                          - Injects block instrumentation instructions
    -instrument_function                       - Injects function instrumentation instructions
    -instrument_prepare                        - Prepares instrumentation instructions

相同的命令,在OSX中:

command opt -load ./obj/llvminstrument/libllvminstrument.dylib -help |grep instrum    │········
opt: CommandLine Error: Argument 'track-memory' defined more than once!                                                  │········
opt: CommandLine Error: Argument 'debug-buffer-size' defined more than once!                                             │········
opt: CommandLine Error: Argument 'print-all-options' defined more than once!                                             │········
opt: CommandLine Error: Argument 'print-options' defined more than once!                                                 │········
opt: CommandLine Error: Argument 'print-after-all' defined more than once!                                               │········
opt: CommandLine Error: Argument 'print-before-all' defined more than once!                                              │········
opt: CommandLine Error: Argument 'track-memory' defined more than once!                                                  │········
opt: CommandLine Error: Argument 'debug-buffer-size' defined more than once!                                             │········
opt: CommandLine Error: Argument 'print-all-options' defined more than once!                                             │········
opt: CommandLine Error: Argument 'print-options' defined more than once!                                                 │········
opt: CommandLine Error: Argument 'print-after-all' defined more than once!                                               │········
opt: CommandLine Error: Argument 'print-before-all' defined more than once!                                              │········
    -insert-edge-profiling                     - Insert instrumentation for edge profiling                               │········
    -insert-gcov-profiling                     - Insert instrumentation for GCOV profiling                               │········
    -insert-optimal-edge-profiling             - Insert optimal instrumentation for edge profiling                       │········
    -insert-path-profiling                     - Insert instrumentation for Ball-Larus path profiling

1 个答案:

答案 0 :(得分:1)

我不确切知道如何解决这个问题,但问题是您将几个核心LLVM库静态链接到检测dylib中,其方式与opt'dlopen'ed不相容驱动程序。因此,当您打开它时,您会获得各种命令行参数的重复全局变量。这可能与LLVM几乎没有关系,更多与OS X上使用的特定构建过程有关的符号和/或共享与静态链接的可见性有不同的默认值。