[polly] r301020 - [CMake] Link unittests only against libLLVM.so, if available.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 12:03:52 PDT 2017


Author: meinersbur
Date: Fri Apr 21 14:03:51 2017
New Revision: 301020

URL: http://llvm.org/viewvc/llvm-project?rev=301020&view=rev
Log:
[CMake] Link unittests only against libLLVM.so, if available.

We can only link against libLLVM.so or the individual libLLVM*.so
components, but not both of them. Doing so results in these components
exist twice in the programs address space, since it is already contained
in libLLVM.so. The observable effect of this is that command line
switches are registered multiple times (once for each instance),
which is an error.

This fixes llvm.org/PR32735.

Reported-by: Singapuram Sanjay Srivallabh <singapuram.sanjay at gmail.com>

Modified:
    polly/trunk/unittests/CMakeLists.txt

Modified: polly/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/unittests/CMakeLists.txt?rev=301020&r1=301019&r2=301020&view=diff
==============================================================================
--- polly/trunk/unittests/CMakeLists.txt (original)
+++ polly/trunk/unittests/CMakeLists.txt Fri Apr 21 14:03:51 2017
@@ -16,7 +16,18 @@ function(add_polly_unittest test_name)
 
     set_property(TARGET ${test_name} PROPERTY FOLDER "Polly")
   endif()
-  target_link_libraries(${test_name} Polly LLVMCore LLVMSupport LLVMDemangle LLVMipo)
+  target_link_libraries(${test_name} Polly)
+
+  # The Polly target does not depend on its required libraries, except:
+  # - BUILD_SHARED_LIBS=ON
+  #     in which case calling target_link_libraries again is redundant.
+  # - LLVM_LINK_LLVM_DYLIB=ON
+  #     in which case it depends on libLLVM.so, so no additional libs needed.
+  #     We are also not allowed to link against the plain LLVM* libraries,
+  #     which would result in multiple instances of these to be loaded.
+  if (NOT LLVM_LINK_LLVM_DYLIB)
+    target_link_libraries(${test_name} LLVMCore LLVMSupport LLVMDemangle LLVMipo)
+  endif ()
 endfunction()
 
 add_subdirectory(Isl)




More information about the llvm-commits mailing list