Skip to content

Commit 6539fd7

Browse files
committed
Patch for 3.7.1 was not working with symlinks
instead, backport a series of llvm commits so the 3.8 version of the bindir patch also works dont try to delete a file in the patch, it should be harmless to leave it
1 parent 8015042 commit 6539fd7

File tree

3 files changed

+216
-50
lines changed

3 files changed

+216
-50
lines changed

deps/llvm-3.7.1_bindir.patch

Lines changed: 0 additions & 49 deletions
This file was deleted.

deps/llvm-3.7.1_symlinks.patch

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
commit f4dd81db3c617f22881446eb0ed6bfdc7d69e81e
2+
Author: Chris Bieneman <[email protected]>
3+
Date: Mon Sep 14 23:09:06 2015 +0000
4+
5+
[CMake] Refactor and cleanup generating and installing symlinks to tools.
6+
7+
Summary: This change generalizes symlink generation and makes symlinks to tools obey LLVM_TOOLCHAIN_TOOLS. It makes it so that if you exclude llvm-ar from LLVM_TOOLCHAIN_TOOLS you don't end up with broken symlinks to llvm-lib and llvm-ranlib in your install.
8+
9+
Reviewers: bogner, chapuni, rafael
10+
11+
Subscribers: llvm-commits
12+
13+
Differential Revision: http://reviews.llvm.org/D12864
14+
15+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247632 91177308-0d34-0410-b5e6-96231b3b80d8
16+
(cherry picked from commit 2ec309f7d116b6f10cf7dc4ca481aa69ddbe1e5b)
17+
18+
Conflicts:
19+
cmake/modules/AddLLVM.cmake
20+
21+
[CMake] Rename target->dest as per feedback from Chapuni on http://reviews.llvm.org/D12864
22+
23+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247658 91177308-0d34-0410-b5e6-96231b3b80d8
24+
(cherry picked from commit 5d1cac1aa28e02fda6be52b5ddf4940085df64d9)
25+
26+
[CMake] More refactoring of symlink creation.
27+
28+
This refactoring is to enable clang to re-use this code.
29+
30+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247850 91177308-0d34-0410-b5e6-96231b3b80d8
31+
(cherry picked from commit 2334ac1e4cc684bf1f68ac47b4486cf5d4dc8528)
32+
33+
[CMake] More cleanup of installing symlinks.
34+
35+
In order to support building clang out-of-tree the install_symlink script needs to be installed, and it needs to be found by searching the CMAKE_MODULE_PATH.
36+
37+
This change renames install_symlink -> LLVMInstallSymlink so it doesn't conflict with naming from other projects, and adds searching behavior in AddLLVM.cmake
38+
39+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248009 91177308-0d34-0410-b5e6-96231b3b80d8
40+
(cherry picked from commit f8d6e92d57aacf9388e8ed87cc43b22bd3367c4f)
41+
42+
[CMake] Adding ALWAYS_GENERATE option to symlink utility functions.
43+
44+
This implements the behavior required for clang symlinks which should be always generated.
45+
46+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248039 91177308-0d34-0410-b5e6-96231b3b80d8
47+
(cherry picked from commit 907451c6d653f5d0f4efa55fb42a84dae67a37cc)
48+
49+
[CMake] Cleaning up and generalizing the LLVMInstallSymlink script so that it can be used for libraries too.
50+
51+
In order to resolve PR25059, we're going to need to be able to generate symlinks to libraries manually, so I need this code to be reusable.
52+
53+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250573 91177308-0d34-0410-b5e6-96231b3b80d8
54+
(cherry picked from commit 26751e15750dbb733946c940e8a3bdfc5c446d8e)
55+
56+
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
57+
index 45f6746..7f711ce 100644
58+
--- a/cmake/modules/AddLLVM.cmake
59+
+++ b/cmake/modules/AddLLVM.cmake
60+
@@ -602,9 +602,10 @@ function(export_executable_symbols target)
61+
endif()
62+
endfunction()
63+
64+
-
65+
set (LLVM_TOOLCHAIN_TOOLS
66+
llvm-ar
67+
+ llvm-ranlib
68+
+ llvm-lib
69+
llvm-objdump
70+
)
71+
72+
@@ -939,3 +940,77 @@ function(add_lit_testsuites project directory)
73+
endforeach()
74+
endif()
75+
endfunction()
76+
+
77+
+function(llvm_install_symlink name dest)
78+
+ cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
79+
+ foreach(path ${CMAKE_MODULE_PATH})
80+
+ if(EXISTS ${path}/LLVMInstallSymlink.cmake)
81+
+ set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
82+
+ break()
83+
+ endif()
84+
+ endforeach()
85+
+
86+
+ if(ARG_ALWAYS_GENERATE)
87+
+ set(component ${dest})
88+
+ else()
89+
+ set(component ${name})
90+
+ endif()
91+
+
92+
+ set(full_name ${name}${CMAKE_EXECUTABLE_SUFFIX})
93+
+ set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
94+
+
95+
+ install(SCRIPT ${INSTALL_SYMLINK}
96+
+ CODE "install_symlink(${full_name} ${full_dest} bin)"
97+
+ COMPONENT ${component})
98+
+
99+
+ if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
100+
+ add_custom_target(install-${name}
101+
+ DEPENDS ${name} ${dest} install-${dest}
102+
+ COMMAND "${CMAKE_COMMAND}"
103+
+ -DCMAKE_INSTALL_COMPONENT=${name}
104+
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
105+
+ endif()
106+
+endfunction()
107+
+
108+
+function(add_llvm_tool_symlink name dest)
109+
+ cmake_parse_arguments(ARG "ALWAYS_GENERATE" "" "" ${ARGN})
110+
+ if(UNIX)
111+
+ set(LLVM_LINK_OR_COPY create_symlink)
112+
+ set(dest_binary "${dest}${CMAKE_EXECUTABLE_SUFFIX}")
113+
+ else()
114+
+ set(LLVM_LINK_OR_COPY copy)
115+
+ set(dest_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/${dest}${CMAKE_EXECUTABLE_SUFFIX}")
116+
+ endif()
117+
+
118+
+ set(output_path "${LLVM_RUNTIME_OUTPUT_INTDIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}")
119+
+
120+
+ if(ARG_ALWAYS_GENERATE)
121+
+ set_property(DIRECTORY APPEND PROPERTY
122+
+ ADDITIONAL_MAKE_CLEAN_FILES ${dest_binary})
123+
+ add_custom_command(TARGET ${dest} POST_BUILD
124+
+ COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}")
125+
+ else()
126+
+ add_custom_command(OUTPUT ${output_path}
127+
+ COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}"
128+
+ DEPENDS ${dest})
129+
+ add_custom_target(${name} ALL DEPENDS ${output_path})
130+
+ set_target_properties(${name} PROPERTIES FOLDER Tools)
131+
+
132+
+ # Make sure the parent tool is a toolchain tool, otherwise exclude this tool
133+
+ list(FIND LLVM_TOOLCHAIN_TOOLS ${dest} LLVM_IS_${dest}_TOOLCHAIN_TOOL)
134+
+ if (NOT LLVM_IS_${dest}_TOOLCHAIN_TOOL GREATER -1)
135+
+ set(LLVM_IS_${name}_TOOLCHAIN_TOOL ${LLVM_IS_${dest}_TOOLCHAIN_TOOL})
136+
+ else()
137+
+ list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
138+
+ endif()
139+
+
140+
+ # LLVM_IS_${name}_TOOLCHAIN_TOOL will only be greater than -1 if both this
141+
+ # tool and its parent tool are in LLVM_TOOLCHAIN_TOOLS
142+
+ if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
143+
+ if( LLVM_BUILD_TOOLS )
144+
+ llvm_install_symlink(${name} ${dest})
145+
+ endif()
146+
+ endif()
147+
+ endif()
148+
+endfunction()
149+
+
150+
diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake
151+
new file mode 100644
152+
index 0000000..482697b
153+
--- /dev/null
154+
+++ b/cmake/modules/LLVMInstallSymlink.cmake
155+
@@ -0,0 +1,21 @@
156+
+# We need to execute this script at installation time because the
157+
+# DESTDIR environment variable may be unset at configuration time.
158+
+# See PR8397.
159+
+
160+
+function(install_symlink name target outdir)
161+
+ if(UNIX)
162+
+ set(LINK_OR_COPY create_symlink)
163+
+ set(DESTDIR $ENV{DESTDIR})
164+
+ else()
165+
+ set(LINK_OR_COPY copy)
166+
+ endif()
167+
+
168+
+ set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
169+
+
170+
+ message("Creating ${name}")
171+
+
172+
+ execute_process(
173+
+ COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}"
174+
+ WORKING_DIRECTORY "${bindir}")
175+
+
176+
+endfunction()
177+
diff --git a/tools/llvm-ar/CMakeLists.txt b/tools/llvm-ar/CMakeLists.txt
178+
index 05ffe36..86233df 100644
179+
--- a/tools/llvm-ar/CMakeLists.txt
180+
+++ b/tools/llvm-ar/CMakeLists.txt
181+
@@ -10,30 +10,5 @@ add_llvm_tool(llvm-ar
182+
llvm-ar.cpp
183+
)
184+
185+
-if(UNIX)
186+
- set(LLVM_LINK_OR_COPY create_symlink)
187+
- set(llvm_ar_binary "llvm-ar${CMAKE_EXECUTABLE_SUFFIX}")
188+
-else()
189+
- set(LLVM_LINK_OR_COPY copy)
190+
- set(llvm_ar_binary "${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar${CMAKE_EXECUTABLE_SUFFIX}")
191+
-endif()
192+
-
193+
-set(llvm_ranlib "${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib${CMAKE_EXECUTABLE_SUFFIX}")
194+
-
195+
-add_custom_command(OUTPUT ${llvm_ranlib}
196+
- COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${llvm_ar_binary}" "${llvm_ranlib}"
197+
- DEPENDS llvm-ar)
198+
-
199+
-add_custom_target(llvm-ranlib ALL DEPENDS ${llvm_ranlib})
200+
-set_target_properties(llvm-ranlib PROPERTIES FOLDER Tools)
201+
-
202+
-set(llvm_lib "${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lib${CMAKE_EXECUTABLE_SUFFIX}")
203+
-
204+
-add_custom_command(OUTPUT ${llvm_lib}
205+
- COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${llvm_ar_binary}" "${llvm_lib}"
206+
- DEPENDS llvm-ar)
207+
-
208+
-add_custom_target(llvm-lib ALL DEPENDS ${llvm_lib})
209+
-set_target_properties(llvm-lib PROPERTIES FOLDER Tools)
210+
-
211+
-install(SCRIPT install_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
212+
+add_llvm_tool_symlink(llvm-ranlib llvm-ar)
213+
+add_llvm_tool_symlink(llvm-lib llvm-ar)

deps/llvm.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ else ifeq ($(LLVM_VER),3.7.1)
407407
$(eval $(call LLVM_PATCH,llvm-3.7.1))
408408
$(eval $(call LLVM_PATCH,llvm-3.7.1_2))
409409
$(eval $(call LLVM_PATCH,llvm-3.7.1_3))
410-
$(eval $(call LLVM_PATCH,llvm-3.7.1_bindir))
410+
$(eval $(call LLVM_PATCH,llvm-3.7.1_symlinks))
411+
$(eval $(call LLVM_PATCH,llvm-3.8.0_bindir))
412+
$(LLVM_SRC_DIR)/llvm-3.8.0_bindir.patch-applied: $(LLVM_SRC_DIR)/llvm-3.7.1_symlinks.patch-applied
411413
$(eval $(call LLVM_PATCH,llvm-D14260))
412414
$(LLVM_SRC_DIR)/llvm-3.7.1_2.patch-applied: $(LLVM_SRC_DIR)/llvm-3.7.1.patch-applied
413415
else ifeq ($(LLVM_VER),3.8.0)

0 commit comments

Comments
 (0)