Skip to content

Commit 9844192

Browse files
authored
Merge pull request #20976 from JuliaLang/vc/bp05_cmake_shlib
[release-0.5] Backport of cmake shlib fixes
2 parents 009bf99 + 4d41845 commit 9844192

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

deps/llvm-ver.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ifeq ($(LLVM_VER_PATCH),)
1111
LLVM_VER_PATCH := 0
1212
endif
1313

14-
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7 3.8))
14+
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7))
1515
LLVM_USE_CMAKE := 0
1616
else
1717
LLVM_USE_CMAKE := 1

deps/llvm.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ $(eval $(call LLVM_PATCH,llvm-3.7.1_3)) # Remove for 3.9
448448
$(eval $(call LLVM_PATCH,llvm-D14260))
449449
$(eval $(call LLVM_PATCH,llvm-3.8.0_bindir)) # Remove for 3.9
450450
$(eval $(call LLVM_PATCH,llvm-3.8.0_winshlib)) # Remove for 3.9
451+
$(eval $(call LLVM_PATCH,llvm-D25865-cmakeshlib))
451452
$(eval $(call LLVM_PATCH,llvm-nodllalias)) # Remove for 3.9
452453
# Cygwin and openSUSE still use win32-threads mingw, https://llvm.org/bugs/show_bug.cgi?id=26365
453454
$(eval $(call LLVM_PATCH,llvm-3.8.0_threads))
@@ -467,6 +468,7 @@ $(eval $(call LLVM_PATCH,llvm-rL279933-ppc-atomicrmw-lowering)) # Remove for 4.0
467468
$(eval $(call LLVM_PATCH,llvm-r282182)) # Remove for 4.0
468469
endif
469470
$(eval $(call LLVM_PATCH,llvm-PR22923)) # Remove for 4.0
471+
$(eval $(call LLVM_PATCH,llvm-D25865-cmakeshlib)) # Remove for 4.0
470472
endif # LLVM_VER
471473

472474
ifeq ($(LLVM_VER),3.7.1)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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

Comments
 (0)