[LLVMdev] Problem in LLVM CMake modules

Óscar Fuentes ofv at wanadoo.es
Sat Jul 7 16:23:30 PDT 2012


Óscar Fuentes <ofv at wanadoo.es> writes:

> Yep, llvm_map_components_to_libraries gets confused by the existence of
> both gtest and gtest_main and enters an infinite loop. A workaround is
> to not pass "all" to llvm_map_components_to_libraries but a list of
> required components.

This patch *seems* to fix the problem (cmake regexps are not thoroughly
documented):

--- a/cmake/modules/LLVM-Config.cmake
+++ b/cmake/modules/LLVM-Config.cmake
@@ -160,7 +160,7 @@ function(explicit_map_components_to_libraries out_libs)
     list(REVERSE expanded_components)
     list(APPEND processed ${lib})
     # Find the maximum index that doesn't have to be re-processed:
-    while(NOT "${expanded_components}" MATCHES "^${processed}.*" )
+    while(NOT "${expanded_components}" MATCHES "^${processed}(;)|(.*)")
       list(REMOVE_AT processed -1)
     endwhile()
     list(LENGTH processed cursor)


However, using "all" as the component to be linked is still broken, as
it passes to the linker -lLTO_static and -lprofile_rt-static, which are
non-existant libraries on a static build.

On the case of LTO_static the fix probably is

diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt
index 9112976..60fc902 100644
--- a/tools/lto/CMakeLists.txt
+++ b/tools/lto/CMakeLists.txt
@@ -23,5 +23,4 @@ endif()
 
 if( NOT BUILD_SHARED_LIBS )
   add_llvm_library(${LTO_STATIC_TARGET_NAME} ${SOURCES})
-  set_property(TARGET ${LTO_STATIC_TARGET_NAME} PROPERTY OUTPUT_NAME "LTO")
 endif()



In the case of profile_rt-static, the fix probably is:

diff --git a/runtime/libprofile/CMakeLists.txt b/runtime/libprofile/CMakeLists.txt
index 414ad00..2794c4d 100644
--- a/runtime/libprofile/CMakeLists.txt
+++ b/runtime/libprofile/CMakeLists.txt
@@ -9,9 +9,6 @@ set(SOURCES
   )
 
 add_llvm_library( profile_rt-static ${SOURCES} )
-set_target_properties( profile_rt-static
-  PROPERTIES
-  OUTPUT_NAME "profile_rt" )
 
 add_llvm_loadable_module( profile_rt-shared ${SOURCES} )
 set_target_properties( profile_rt-shared



And do we really want gtest, gtest_main and maybe other internal
libraries to be listed when the user requires "all" LLVM components?




More information about the llvm-dev mailing list