|
| 1 | +From 417001588d232151050db2d32df443e2d073ebbf Mon Sep 17 00:00:00 2001 |
| 2 | +From: Valentin Churavy < [email protected]> |
| 3 | +Date: Fri, 21 Oct 2016 17:25:04 +0900 |
| 4 | +Subject: [PATCH] Fix llvm-shlib cmake build |
| 5 | + |
| 6 | +Summary: |
| 7 | +This fixes a few things that used to work with a Makefile build, but were broken in cmake. |
| 8 | + |
| 9 | +1. Treat MINGW like a Linux system. |
| 10 | +2. The shlib should never contain other shared libraries. |
| 11 | + |
| 12 | +Subscribers: beanz, mgorny |
| 13 | + |
| 14 | +Differential Revision: https://reviews.llvm.org/D25865 |
| 15 | +--- |
| 16 | + tools/llvm-shlib/CMakeLists.txt | 42 ++++++++++++++++++++--------------------- |
| 17 | + 1 file changed, 20 insertions(+), 22 deletions(-) |
| 18 | + |
| 19 | +diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt |
| 20 | +index 3fe672d..edadb82 100644 |
| 21 | +--- a/tools/llvm-shlib/CMakeLists.txt |
| 22 | ++++ b/tools/llvm-shlib/CMakeLists.txt |
| 23 | +@@ -8,29 +8,27 @@ set(SOURCES |
| 24 | + |
| 25 | + llvm_map_components_to_libnames(LIB_NAMES ${LLVM_DYLIB_COMPONENTS}) |
| 26 | + |
| 27 | +-if(LLVM_LINK_LLVM_DYLIB) |
| 28 | +- if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE) |
| 29 | +- message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.") |
| 30 | +- endif() |
| 31 | +- |
| 32 | +- # libLLVM.so should not have any dependencies on any other LLVM |
| 33 | +- # shared libraries. When using the "all" pseudo-component, |
| 34 | +- # LLVM_AVAILABLE_LIBS is added to the dependencies, which may |
| 35 | +- # contain shared libraries (e.g. libLTO). |
| 36 | +- # |
| 37 | +- # Also exclude libLLVMTableGen for the following reasons: |
| 38 | +- # - it is only used by internal *-tblgen utilities; |
| 39 | +- # - it pollutes the global options space. |
| 40 | +- foreach(lib ${LIB_NAMES}) |
| 41 | +- get_target_property(t ${lib} TYPE) |
| 42 | +- if("${lib}" STREQUAL "LLVMTableGen") |
| 43 | +- elseif("x${t}" STREQUAL "xSTATIC_LIBRARY") |
| 44 | +- list(APPEND FILTERED_LIB_NAMES ${lib}) |
| 45 | +- endif() |
| 46 | +- endforeach() |
| 47 | +- set(LIB_NAMES ${FILTERED_LIB_NAMES}) |
| 48 | ++if(LLVM_LINK_LLVM_DYLIB AND LLVM_DYLIB_EXPORTED_SYMBOL_FILE) |
| 49 | ++ message(WARNING "Using LLVM_LINK_LLVM_DYLIB with LLVM_DYLIB_EXPORTED_SYMBOL_FILE may not work. Use at your own risk.") |
| 50 | + endif() |
| 51 | + |
| 52 | ++# libLLVM.so should not have any dependencies on any other LLVM |
| 53 | ++# shared libraries. When using the "all" pseudo-component, |
| 54 | ++# LLVM_AVAILABLE_LIBS is added to the dependencies, which may |
| 55 | ++# contain shared libraries (e.g. libLTO). |
| 56 | ++# |
| 57 | ++# Also exclude libLLVMTableGen for the following reasons: |
| 58 | ++# - it is only used by internal *-tblgen utilities; |
| 59 | ++# - it pollutes the global options space. |
| 60 | ++foreach(lib ${LIB_NAMES}) |
| 61 | ++ get_target_property(t ${lib} TYPE) |
| 62 | ++ if("${lib}" STREQUAL "LLVMTableGen") |
| 63 | ++ elseif("x${t}" STREQUAL "xSTATIC_LIBRARY") |
| 64 | ++ list(APPEND FILTERED_LIB_NAMES ${lib}) |
| 65 | ++ endif() |
| 66 | ++endforeach() |
| 67 | ++set(LIB_NAMES ${FILTERED_LIB_NAMES}) |
| 68 | ++ |
| 69 | + if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE) |
| 70 | + set(LLVM_EXPORTED_SYMBOL_FILE ${LLVM_DYLIB_EXPORTED_SYMBOL_FILE}) |
| 71 | + add_custom_target(libLLVMExports DEPENDS ${LLVM_EXPORTED_SYMBOL_FILE}) |
| 72 | +@@ -39,7 +37,7 @@ endif() |
| 73 | + add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES}) |
| 74 | + |
| 75 | + list(REMOVE_DUPLICATES LIB_NAMES) |
| 76 | +-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # FIXME: It should be "GNU ld for elf" |
| 77 | ++if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR MINGW) # FIXME: It should be "GNU ld for elf" |
| 78 | + # GNU ld doesn't resolve symbols in the version script. |
| 79 | + set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) |
| 80 | + elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") |
| 81 | +-- |
| 82 | +2.10.1 |
| 83 | + |
0 commit comments