Discrepancies between bin/llvm-config --libs and LLVM_LINK_COMPONENTS in CMake.

Hello. When i run

llvm-config --libs jit bitreader bitwriter ipo linker engine

i get:

-lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMX86Info -lLLVMLinker -lLLVMArchive -lLLVMipo -lLLVMBitWriter -lLLVMBitReader -lLLVMJIT -lLLVMExecutionEngine -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport

Now i use in CMakeLists.txt following line:

set(LLVM_LINK_COMPONENTS jit bitreader bitwriter ipo linker engine)

After running CMake, target’s link.txt contains following:

/usr/bin/c++ <…> -lLLVMBitWriter -lLLVMipo -lLLVMLinker -lLLVMJIT -lLLVMArchive -lLLVMCodeGen -lLLVMExecutionEngine -lLLVMBitReader -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMMC -lLLVMSupport

As you can see, this differs from output of llvm-config tool. This causes linking to fail due to unresolved externals.

arrowdodger <6yearold@gmail.com> writes:

llvm-config --libs jit bitreader bitwriter ipo linker engine

[snip]

Now i use in CMakeLists.txt following line:

set(LLVM_LINK_COMPONENTS jit bitreader bitwriter ipo linker engine)

[snip]

As you can see, this differs from output of llvm-config tool. This causes
linking to fail due to unresolved externals.

See if r127333 fixes the problem for you.