LLVM Discussion Forums

Opt: Option registered more than once!

When I run my pass, it comes with CommandLine Error

/home/happy/Source/build_llvm/bin/opt -load=libFiber.so --scp test.ll -S -o test_modified.ll
opt: CommandLine Error: Option 'debug' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

seems it because I link the libs to my pass in cmake file, because if I don’t link libs and don’t use JIT like LLVMInitializeNativeTarget(), the pass works without error.


#target_link_libraries(LLVMInterpreter LLVMExecutionEngine)
llvm_map_components_to_libnames(llvm_libs all)
target_link_libraries(Fiber ${llvm_libs})

But if I don’t use target_link_libraries, I cann’t use JIT Engine in my pass which says

llvm undefined symbol: LLVMLinkInInterpreter

I wonder how to link LLVMInterpreter LLVMExecutionEngine to my pass without conflict.
BTW, I wonder whether it’s suitable to use JIT in LLVM pass.

some reference links

When I fix the LLVMLinkInInterpreter, It prompt with CommandLine ERROR.

Any possible CmakeLists.txt to compile interpreter successfully for JIT out-of-tree usage?Thanks

Does your code register a debug option explicitly? If so you may have to rename it.
Alternatively it may be that your code links with a library that registers a debug option and this library is already linked in opt. A solution to this might be to explicitly name the components needed here:
llvm_map_components_to_libnames(llvm_libs componentA, componentB, etc... ). Also cmake private linkage seems to have worked in this case