tstellar updated this revision to Diff 239764.
tstellar added a comment.

Rewrite patch to use cmake features available with cmake >= 3.4.  The previous
version used a 3.6 feature: list(FILTER ...)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68520/new/

https://reviews.llvm.org/D68520

Files:
  clang/tools/clang-shlib/CMakeLists.txt


Index: clang/tools/clang-shlib/CMakeLists.txt
===================================================================
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -14,7 +14,23 @@
     list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)
   endif()
   list(APPEND _DEPS $<TARGET_PROPERTY:${lib},INTERFACE_LINK_LIBRARIES>)
-  list(APPEND _DEPS $<TARGET_PROPERTY:${lib},LINK_LIBRARIES>)
+
+  # clang libraries are redundant since we are linking all the individual
+  # object files into libclang-cpp.so, so filter them out from _DEPS.
+  # This avoids problems with LLVM global data when building with
+  # BUILD_SHARED_LIBS=ON
+  # FIXME: We could use list(FILTER) with cmake >= 3.6
+  # FIXME: With cmake >= 3.15 we could use the generator expression
+  # $<FILTER:list,INCLUDE|EXCLUDE,regex>
+  get_target_property(interface ${lib} LINK_LIBRARIES)
+  if (interface)
+    foreach(lib ${interface})
+      string(REGEX MATCH "^clang" is_clang_lib ${lib})
+      if (NOT is_clang_lib)
+        list(APPEND _DEPS ${lib})
+      endif()
+    endforeach()
+  endif()
 endforeach ()
 
 if (CLANG_LINK_CLANG_DYLIB)


Index: clang/tools/clang-shlib/CMakeLists.txt
===================================================================
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -14,7 +14,23 @@
     list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)
   endif()
   list(APPEND _DEPS $<TARGET_PROPERTY:${lib},INTERFACE_LINK_LIBRARIES>)
-  list(APPEND _DEPS $<TARGET_PROPERTY:${lib},LINK_LIBRARIES>)
+
+  # clang libraries are redundant since we are linking all the individual
+  # object files into libclang-cpp.so, so filter them out from _DEPS.
+  # This avoids problems with LLVM global data when building with
+  # BUILD_SHARED_LIBS=ON
+  # FIXME: We could use list(FILTER) with cmake >= 3.6
+  # FIXME: With cmake >= 3.15 we could use the generator expression
+  # $<FILTER:list,INCLUDE|EXCLUDE,regex>
+  get_target_property(interface ${lib} LINK_LIBRARIES)
+  if (interface)
+    foreach(lib ${interface})
+      string(REGEX MATCH "^clang" is_clang_lib ${lib})
+      if (NOT is_clang_lib)
+        list(APPEND _DEPS ${lib})
+      endif()
+    endforeach()
+  endif()
 endforeach ()
 
 if (CLANG_LINK_CLANG_DYLIB)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to