[polly] r228914 - Link LLVM libraries into libLLVMPolly if BUILD_SHARED_LIBS=ON is set

Brad King brad.king at kitware.com
Thu Feb 12 06:02:50 PST 2015


On 2/12/2015 3:36 AM, Tobias Grosser wrote:
>> URL: http://llvm.org/viewvc/llvm-project?rev=228914&view=rev
>> Log:
>> Link LLVM libraries into libLLVMPolly if BUILD_SHARED_LIBS=ON is set
>>
> I just "fixed" an issue I have with my cmake files, but I am afraid this 
> is not the optimal solution. Could you possibly cross-check what I did.

For reference, here are the key parts of the CMakeLists.txt file:

 add_polly_library(Polly ...)
 if (BUILD_SHARED_LIBS)
   target_link_libraries(Polly LLVMSupport ...)
 endif()
 add_polly_loadable_module(LLVMPolly ...)
 target_link_libraries(LLVMPolly Polly)

I didn't dive deep into the rest of the Polly code, but from the
description of your change I surmise the following.

The "target_link_libraries(Polly ...)" call says "link Polly and
any of its dependents to these LLVM libraries".  If Polly is a
shared library even when the LLVM libraries are static, then this
will put a copy of them into Polly.  Then the later rule to link
LLVMPolly to Polly causes the link dependencies to be followed
transitively so LLVMPolly may get a copy of the static libs too,
leading to the duplicate symbols.

If "LLVMPolly" does not use any LLVM APIs directly and is just a
loadable module wrapper around the "Polly" shared library, then
it of course does not need to link to the LLVM libraries.  If all
this is correct then you should just need to add LINK_PRIVATE
to the first tll call and then it can be unconditional:

 target_link_libraries(Polly LINK_PRIVATE LLVMSupport ...)

This says "the implementation of Polly depends on these libraries,
but dependents of Polly do not".  This is typical when the headers
of a library do not expose its implementation dependencies.

-Brad



More information about the llvm-commits mailing list