3

I need an additional library given as linker input, since the linker cannot find a symbol.

llvm_map_components_to_libnames(llvm_libs support core bitreader)

target_link_libraries(SkeletonPass ${llvm_libs})

The missing library must be missing from the components.

How do I specify all components as input?

Shuzheng
  • 11,288
  • 20
  • 88
  • 186
  • You don't post any error, so we are not able to see which component you're missing. You can check http://stackoverflow.com/questions/30867712/add-llvm-to-project-using-cmake and related links inside that SO post. – fedepad Jan 29 '17 at 18:53
  • Thanks, my question in general is this: where can I see a mapping between components and LLVM libs? Also, suppose I find that I need to resolve some symbol and I learn it is defined in some header file. How do I see which library contains this header? – Shuzheng Jan 29 '17 at 19:27

2 Answers2

6

First of all, although it's outdated, I suggest you read the following http://releases.llvm.org/2.7/docs/UsingLibraries.html
it's a nice read. In that is suggested too look up llvm-config.

LLVM comes with a tool, llvm-config which can help you in your case.
Second, I warmly suggest you have a look at the following SO post
How do I link when building with llvm libraries?
which also mention this tool.
Looking at the documentation I linked, this is the synopsis:

llvm-config option [components...] 

where if components is not specified, its default value is all which according to the doc:

Includes all LLVM libraries. The default if no components are specified.

I will explicitly add all which can be omitted in your case.

llvm-config --components all:

Print all valid component names.

while llvm-config --libs all:

Print all the libraries needed to link against the specified LLVM components, including any dependencies.

Please check llvm-config --help for more options and info.

So to answer your question, you could print all the components with the command mentioned above and put them inside your llvm_map_components_to_libnames().

Community
  • 1
  • 1
fedepad
  • 4,509
  • 1
  • 13
  • 27
  • 1
    Thanks! I try to generate a project for Visual Studio, so I cannot just compile with clang and llvm-config on the command line. What is the canonical way to generate a project with all dependencies resolved? Is it just to include all components? – Shuzheng Jan 30 '17 at 06:32
3

To list all the components try running this command:

llvm-config --components

For me the output was

aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo a
mdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwr
iter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker
engine executionengine frontendopenmp fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader jitlink lanai lan
aiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430
 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcerror orcjit passes powerpc powerpcasmpars
er powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvutils runtimedyld scalaropts selectiondag sparc sparcas
mparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize weba
ssembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86utils xcore xcorecodegen xcored
esc xcoredisassembler xcoreinfo xray
lxr196
  • 108
  • 2
  • 7