Blame SOURCES/llvm-D25865-cmakeshlib.patch

a43873
From 417001588d232151050db2d32df443e2d073ebbf Mon Sep 17 00:00:00 2001
a43873
From: Valentin Churavy <v.churavy@gmail.com>
a43873
Date: Fri, 21 Oct 2016 17:25:04 +0900
a43873
Subject: [PATCH] Fix llvm-shlib cmake build
a43873
a43873
Summary:
a43873
This fixes a few things that used to work with a Makefile build, but were broken in cmake.
a43873
a43873
1. Treat MINGW like a Linux system.
a43873
2. The shlib should never contain other shared libraries.
a43873
a43873
Subscribers: beanz, mgorny
a43873
a43873
Differential Revision: https://reviews.llvm.org/D25865
a43873
---
a43873
 tools/llvm-shlib/CMakeLists.txt | 42 ++++++++++++++++++++---------------------
a43873
 1 file changed, 20 insertions(+), 22 deletions(-)
a43873
a43873
diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt
a43873
index 3fe672d..edadb82 100644
a43873
--- a/tools/llvm-shlib/CMakeLists.txt
a43873
+++ b/tools/llvm-shlib/CMakeLists.txt
a43873
@@ -8,29 +8,27 @@ set(SOURCES
a43873
 
a43873
 llvm_map_components_to_libnames(LIB_NAMES ${LLVM_DYLIB_COMPONENTS})
a43873
 
a43873
-if(LLVM_LINK_LLVM_DYLIB)
a43873
-  if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE)
a43873
-    message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.")
a43873
-  endif()
a43873
-
a43873
-  # libLLVM.so should not have any dependencies on any other LLVM
a43873
-  # shared libraries. When using the "all" pseudo-component,
a43873
-  # LLVM_AVAILABLE_LIBS is added to the dependencies, which may
a43873
-  # contain shared libraries (e.g. libLTO).
a43873
-  #
a43873
-  # Also exclude libLLVMTableGen for the following reasons:
a43873
-  #  - it is only used by internal *-tblgen utilities;
a43873
-  #  - it pollutes the global options space.
a43873
-  foreach(lib ${LIB_NAMES})
a43873
-    get_target_property(t ${lib} TYPE)
a43873
-    if("${lib}" STREQUAL "LLVMTableGen")
a43873
-    elseif("x${t}" STREQUAL "xSTATIC_LIBRARY")
a43873
-      list(APPEND FILTERED_LIB_NAMES ${lib})
a43873
-    endif()
a43873
-  endforeach()
a43873
-  set(LIB_NAMES ${FILTERED_LIB_NAMES})
a43873
+if(LLVM_LINK_LLVM_DYLIB AND LLVM_DYLIB_EXPORTED_SYMBOL_FILE)
a43873
+  message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.")
a43873
 endif()
a43873
 
a43873
+# libLLVM.so should not have any dependencies on any other LLVM
a43873
+# shared libraries. When using the "all" pseudo-component,
a43873
+# LLVM_AVAILABLE_LIBS is added to the dependencies, which may
a43873
+# contain shared libraries (e.g. libLTO).
a43873
+#
a43873
+# Also exclude libLLVMTableGen for the following reasons:
a43873
+#  - it is only used by internal *-tblgen utilities;
a43873
+#  - it pollutes the global options space.
a43873
+foreach(lib ${LIB_NAMES})
a43873
+  get_target_property(t ${lib} TYPE)
a43873
+  if("${lib}" STREQUAL "LLVMTableGen")
a43873
+  elseif("x${t}" STREQUAL "xSTATIC_LIBRARY")
a43873
+    list(APPEND FILTERED_LIB_NAMES ${lib})
a43873
+  endif()
a43873
+endforeach()
a43873
+set(LIB_NAMES ${FILTERED_LIB_NAMES})
a43873
+
a43873
 if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE)
a43873
   set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_DYLIB_EXPORTED_SYMBOL_FILE})
a43873
   add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE})
a43873
@@ -39,7 +37,7 @@ endif()
a43873
 add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
a43873
 
a43873
 list(REMOVE_DUPLICATES LIB_NAMES)
a43873
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf"
a43873
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR MINGW) # FIXME: It should be "GNU ld for elf"
a43873
   # GNU ld doesn't resolve symbols in the version script.
a43873
   set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
a43873
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
a43873
-- 
a43873
2.10.1
a43873