Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM: How to specify all link libraries as input to llvm_map_components_to_libnames()

Tags:

c++

llvm

cmake

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?

like image 215
Shuzheng Avatar asked Nov 04 '25 10:11

Shuzheng


1 Answers

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().

like image 98
fedepad Avatar answered Nov 07 '25 05:11

fedepad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!