The exported libLLVM.dylib cannot be used as is because it creates multiple static initializers for cl::opt<T> values that may interfere with a command line application that links to the library. I suspect that the macOS linker may have liked multiple objects that have the static initializer, leading the the requisite error. Fixes may include allowing duplicate identical initializers to exist without error, or to create libLLVM by first passing through all object files to llvm-link before generating the native binary as this would fix any single instance problems with static initialization. I believe that lld may properly handle these duplicate object files, but will know more after a few tests. Error as reported:
: CommandLine Error: Option 'aarch64-enable-ccmp' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Repo steps:
Create libLLVM by compiling LLVM with LLVM_BUILD_LLVM_DYLIB=ON and then create a binary that links to LLVM using something similar to the following CMake file:
The exported
libLLVM.dylib
cannot be used as is because it creates multiple static initializers forcl::opt<T>
values that may interfere with a command line application that links to the library. I suspect that the macOS linker may have liked multiple objects that have the static initializer, leading the the requisite error. Fixes may include allowing duplicate identical initializers to exist without error, or to createlibLLVM
by first passing through all object files tollvm-link
before generating the native binary as this would fix any single instance problems with static initialization. I believe thatlld
may properly handle these duplicate object files, but will know more after a few tests. Error as reported:Repo steps:
Create
libLLVM
by compiling LLVM withLLVM_BUILD_LLVM_DYLIB=ON
and then create a binary that links to LLVM using something similar to the following CMake file: