Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM: Optimization loading failing on OSX

Tags:

macos

llvm

clang

I am trying to run this LLVM instrumentation project, but I am only able to load the instrumentation optimization under Linux.

I have compiled and installed LLVM 3.2 and Clang 3.2 on OSX, and have the same version in Linux.

When I try to run in 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

Same command, in 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
like image 978
aperez Avatar asked Nov 12 '22 09:11

aperez


1 Answers

I don't know exactly how to fix this, but the problem is that you're linking several of the core LLVM libraries statically into the instrumentation dylib in a way that is incompatible with it being 'dlopen'ed by the opt driver. Thus, when you open it, you get duplicate globals for various commandline arguments. This likely has little to do with LLVM and more to do with the specific build process used on OS X have different defaults for visibility of symbols and/or shared vs. static linking.

like image 157
Chandler Carruth Avatar answered Nov 15 '22 11:11

Chandler Carruth