summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-devtools/clang/clang/0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch28
-rw-r--r--recipes-devtools/clang/clang/0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch320
-rw-r--r--recipes-devtools/clang/clang/0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch27
-rw-r--r--recipes-devtools/clang/common.inc3
4 files changed, 378 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch b/recipes-devtools/clang/clang/0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch
new file mode 100644
index 0000000..e95b418
--- /dev/null
+++ b/recipes-devtools/clang/clang/0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch
@@ -0,0 +1,28 @@
1From 08c592b1850c9b0c17a9f4163e93682a9f83d7f7 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 19 May 2021 21:49:18 -0700
4Subject: [PATCH] compiler-rt: Link scudo with SANITIZER_CXX_ABI_LIBRARIES
5
6If SANITIZER_CXX_ABI_LIBRARIES is set then link scudo with it, this
7fixes build time errors like
8
9projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.armhf.dir/sanitizer_posix_libcdep.cpp.o: in function `__sanitizer::UnsetAlternateSignalStack()':
10| sanitizer_posix_libcdep.cpp:(.text+0x3d2): undefined reference to `__cxa_guard_acquire'
11
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 compiler-rt/lib/scudo/CMakeLists.txt | 1 +
15 1 file changed, 1 insertion(+)
16
17diff --git a/compiler-rt/lib/scudo/CMakeLists.txt b/compiler-rt/lib/scudo/CMakeLists.txt
18index c50ea0233fae..ddc1128b8ed8 100644
19--- a/compiler-rt/lib/scudo/CMakeLists.txt
20+++ b/compiler-rt/lib/scudo/CMakeLists.txt
21@@ -12,6 +12,7 @@ append_list_if(COMPILER_RT_HAS_LIBDL dl SCUDO_MINIMAL_DYNAMIC_LIBS)
22 append_list_if(COMPILER_RT_HAS_LIBRT rt SCUDO_MINIMAL_DYNAMIC_LIBS)
23 append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SCUDO_MINIMAL_DYNAMIC_LIBS)
24 append_list_if(COMPILER_RT_HAS_LIBLOG log SCUDO_MINIMAL_DYNAMIC_LIBS)
25+append_list_if(SANITIZER_CXX_ABI_LIBRARIES ${SANITIZER_CXX_ABI_LIBRARIES} SCUDO_MINIMAL_DYNAMIC_LIBS)
26 append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer
27 SCUDO_CFLAGS)
28
diff --git a/recipes-devtools/clang/clang/0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch b/recipes-devtools/clang/clang/0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch
new file mode 100644
index 0000000..cefbf02
--- /dev/null
+++ b/recipes-devtools/clang/clang/0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch
@@ -0,0 +1,320 @@
1From 9583baa3f6787236a2452937bbf962a2418f6423 Mon Sep 17 00:00:00 2001
2From: Jack Andersen <jackoalan@gmail.com>
3Date: Sun, 5 Dec 2021 14:45:33 -0500
4Subject: [PATCH] [CMake] Installable find modules for terminfo and libffi
5
6Improves cross-distro portability of LLVM cmake package by resolving paths for
7terminfo and libffi via import targets.
8
9When LLVMExports.cmake is generated for installation, it contains absolute
10library paths which are likely to be a common cause of portability issues. To
11mitigate this, the discovery logic for these dependencies is refactored into
12find modules which get installed alongside LLVMConfig.cmake. The result is
13cleaner, cmake-friendly management of these dependencies that respect the
14environment of the LLVM package importer.
15
16Reviewed By: JDevlieghere
17
18Differential Revision: https://reviews.llvm.org/D114327
19---
20 llvm/cmake/config-ix.cmake | 50 +++---------
21 llvm/cmake/modules/FindFFI.cmake | 81 +++++++++++++++++++
22 llvm/cmake/modules/FindTerminfo.cmake | 43 ++++++++++
23 llvm/cmake/modules/LLVMConfig.cmake.in | 11 +++
24 .../Interpreter/CMakeLists.txt | 10 +--
25 llvm/lib/Support/CMakeLists.txt | 7 +-
26 6 files changed, 154 insertions(+), 48 deletions(-)
27 create mode 100644 llvm/cmake/modules/FindFFI.cmake
28 create mode 100644 llvm/cmake/modules/FindTerminfo.cmake
29
30diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
31index 2f8ad6652334..ea0cd107a783 100644
32--- a/llvm/cmake/config-ix.cmake
33+++ b/llvm/cmake/config-ix.cmake
34@@ -169,18 +169,13 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
35 else()
36 set(HAVE_LIBEDIT 0)
37 endif()
38- if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
39- set(MAYBE_REQUIRED REQUIRED)
40- else()
41- set(MAYBE_REQUIRED)
42- endif()
43 if(LLVM_ENABLE_TERMINFO)
44- set(TERMINFO_LIB tinfo curses ncurses ncursesw)
45- endif()
46- if(TERMINFO_LIB)
47- set(LLVM_ENABLE_TERMINFO 1)
48- else()
49- set(LLVM_ENABLE_TERMINFO 0)
50+ if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
51+ find_package(Terminfo REQUIRED)
52+ else()
53+ find_package(Terminfo)
54+ endif()
55+ set(LLVM_ENABLE_TERMINFO "${Terminfo_FOUND}")
56 endif()
57 else()
58 set(LLVM_ENABLE_TERMINFO 0)
59@@ -318,38 +313,19 @@ if (LLVM_ENABLE_DOXYGEN)
60 llvm_find_program(dot)
61 endif ()
62
63-if( LLVM_ENABLE_FFI )
64- find_path(FFI_INCLUDE_PATH ffi.h PATHS ${FFI_INCLUDE_DIR})
65- if( EXISTS "${FFI_INCLUDE_PATH}/ffi.h" )
66- set(FFI_HEADER ffi.h CACHE INTERNAL "")
67- set(HAVE_FFI_H 1 CACHE INTERNAL "")
68+if(LLVM_ENABLE_FFI)
69+ set(FFI_REQUIRE_INCLUDE On)
70+ if(LLVM_ENABLE_FFI STREQUAL FORCE_ON)
71+ find_package(FFI REQUIRED)
72 else()
73- find_path(FFI_INCLUDE_PATH ffi/ffi.h PATHS ${FFI_INCLUDE_DIR})
74- if( EXISTS "${FFI_INCLUDE_PATH}/ffi/ffi.h" )
75- set(FFI_HEADER ffi/ffi.h CACHE INTERNAL "")
76- set(HAVE_FFI_FFI_H 1 CACHE INTERNAL "")
77- endif()
78+ find_package(FFI)
79 endif()
80-
81- if( NOT FFI_HEADER )
82- message(FATAL_ERROR "libffi includes are not found.")
83- endif()
84-
85- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR})
86- if( NOT FFI_LIBRARY_PATH )
87- message(FATAL_ERROR "libffi is not found.")
88- endif()
89-
90- list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
91- list(APPEND CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
92- check_symbol_exists(ffi_call ${FFI_HEADER} HAVE_FFI_CALL)
93- list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
94- list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
95+ set(LLVM_ENABLE_FFI "${FFI_FOUND}")
96 else()
97 unset(HAVE_FFI_FFI_H CACHE)
98 unset(HAVE_FFI_H CACHE)
99 unset(HAVE_FFI_CALL CACHE)
100-endif( LLVM_ENABLE_FFI )
101+endif()
102
103 # Whether we can use std::is_trivially_copyable to verify llvm::is_trivially_copyable.
104 CHECK_CXX_SOURCE_COMPILES("
105diff --git a/llvm/cmake/modules/FindFFI.cmake b/llvm/cmake/modules/FindFFI.cmake
106new file mode 100644
107index 000000000000..b0d859af8959
108--- /dev/null
109+++ b/llvm/cmake/modules/FindFFI.cmake
110@@ -0,0 +1,81 @@
111+# Attempts to discover ffi library with a linkable ffi_call function.
112+#
113+# Example usage:
114+#
115+# find_package(FFI)
116+#
117+# FFI_REQUIRE_INCLUDE may be set to consider ffi found if the includes
118+# are present in addition to the library. This is useful to keep off
119+# for the imported package on platforms that install the library but
120+# not the headers.
121+#
122+# FFI_LIBRARY_DIR may be set to define search paths for the ffi library.
123+#
124+# If successful, the following variables will be defined:
125+# FFI_FOUND
126+# FFI_INCLUDE_DIRS
127+# FFI_LIBRARIES
128+# HAVE_FFI_CALL
129+#
130+# HAVE_FFI_H or HAVE_FFI_FFI_H is defined depending on the ffi.h include path.
131+#
132+# Additionally, the following import target will be defined:
133+# FFI::ffi
134+
135+find_path(FFI_INCLUDE_DIRS ffi.h PATHS ${FFI_INCLUDE_DIR})
136+if( EXISTS "${FFI_INCLUDE_DIRS}/ffi.h" )
137+ set(FFI_HEADER ffi.h CACHE INTERNAL "")
138+ set(HAVE_FFI_H 1 CACHE INTERNAL "")
139+else()
140+ find_path(FFI_INCLUDE_DIRS ffi/ffi.h PATHS ${FFI_INCLUDE_DIR})
141+ if( EXISTS "${FFI_INCLUDE_DIRS}/ffi/ffi.h" )
142+ set(FFI_HEADER ffi/ffi.h CACHE INTERNAL "")
143+ set(HAVE_FFI_FFI_H 1 CACHE INTERNAL "")
144+ endif()
145+endif()
146+
147+find_library(FFI_LIBRARIES ffi PATHS ${FFI_LIBRARY_DIR})
148+
149+if(FFI_LIBRARIES)
150+ include(CMakePushCheckState)
151+ include(CheckCSourceCompiles)
152+ cmake_push_check_state()
153+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARIES})
154+ check_c_source_compiles("
155+ struct ffi_cif;
156+ typedef struct ffi_cif ffi_cif;
157+ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue);
158+ int main() { ffi_call(0, 0, 0, 0); }"
159+ HAVE_FFI_CALL)
160+ cmake_pop_check_state()
161+endif()
162+
163+unset(required_includes)
164+if(FFI_REQUIRE_INCLUDE)
165+ set(required_includes FFI_INCLUDE_DIRS)
166+endif()
167+
168+include(FindPackageHandleStandardArgs)
169+find_package_handle_standard_args(FFI
170+ FOUND_VAR
171+ FFI_FOUND
172+ REQUIRED_VARS
173+ FFI_LIBRARIES
174+ ${required_includes}
175+ HAVE_FFI_CALL)
176+mark_as_advanced(FFI_LIBRARIES
177+ FFI_INCLUDE_DIRS
178+ HAVE_FFI_CALL
179+ FFI_HEADER
180+ HAVE_FFI_H
181+ HAVE_FFI_FFI_H)
182+
183+if(FFI_FOUND)
184+ if(NOT TARGET FFI::ffi)
185+ add_library(FFI::ffi UNKNOWN IMPORTED)
186+ set_target_properties(FFI::ffi PROPERTIES IMPORTED_LOCATION "${FFI_LIBRARIES}")
187+ if(FFI_INCLUDE_DIRS)
188+ set_target_properties(FFI::ffi PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFI_INCLUDE_DIRS}")
189+ endif()
190+ endif()
191+endif()
192diff --git a/llvm/cmake/modules/FindTerminfo.cmake b/llvm/cmake/modules/FindTerminfo.cmake
193new file mode 100644
194index 000000000000..65edb80fa69a
195--- /dev/null
196+++ b/llvm/cmake/modules/FindTerminfo.cmake
197@@ -0,0 +1,43 @@
198+# Attempts to discover terminfo library with a linkable setupterm function.
199+#
200+# Example usage:
201+#
202+# find_package(Terminfo)
203+#
204+# If successful, the following variables will be defined:
205+# Terminfo_FOUND
206+# Terminfo_LIBRARIES
207+#
208+# Additionally, the following import target will be defined:
209+# Terminfo::terminfo
210+
211+find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw)
212+
213+if(Terminfo_LIBRARIES)
214+ include(CMakePushCheckState)
215+ include(CheckCSourceCompiles)
216+ cmake_push_check_state()
217+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${Terminfo_LIBRARIES})
218+ check_c_source_compiles("
219+ int setupterm(char *term, int filedes, int *errret);
220+ int main() { return setupterm(0, 0, 0); }"
221+ Terminfo_LINKABLE)
222+ cmake_pop_check_state()
223+endif()
224+
225+include(FindPackageHandleStandardArgs)
226+find_package_handle_standard_args(Terminfo
227+ FOUND_VAR
228+ Terminfo_FOUND
229+ REQUIRED_VARS
230+ Terminfo_LIBRARIES
231+ Terminfo_LINKABLE)
232+mark_as_advanced(Terminfo_LIBRARIES
233+ Terminfo_LINKABLE)
234+
235+if(Terminfo_FOUND)
236+ if(NOT TARGET Terminfo::terminfo)
237+ add_library(Terminfo::terminfo UNKNOWN IMPORTED)
238+ set_target_properties(Terminfo::terminfo PROPERTIES IMPORTED_LOCATION "${Terminfo_LIBRARIES}")
239+ endif()
240+endif()
241diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in
242index ac053141b008..42c1ea819717 100644
243--- a/llvm/cmake/modules/LLVMConfig.cmake.in
244+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
245@@ -2,6 +2,9 @@
246
247 @LLVM_CONFIG_CODE@
248
249+# For finding self-installed Find*.cmake packages.
250+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
251+
252 set(LLVM_VERSION_MAJOR @LLVM_VERSION_MAJOR@)
253 set(LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@)
254 set(LLVM_VERSION_PATCH @LLVM_VERSION_PATCH@)
255@@ -46,9 +49,17 @@ set(LLVM_ENABLE_ASSERTIONS @LLVM_ENABLE_ASSERTIONS@)
256
257 set(LLVM_ENABLE_EH @LLVM_ENABLE_EH@)
258
259+set(LLVM_ENABLE_FFI @LLVM_ENABLE_FFI@)
260+if(LLVM_ENABLE_FFI)
261+ find_package(FFI)
262+endif()
263+
264 set(LLVM_ENABLE_RTTI @LLVM_ENABLE_RTTI@)
265
266 set(LLVM_ENABLE_TERMINFO @LLVM_ENABLE_TERMINFO@)
267+if(LLVM_ENABLE_TERMINFO)
268+ find_package(Terminfo)
269+endif()
270
271 set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
272
273diff --git a/llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt b/llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt
274index 9930e01559e9..14522ba2a1bf 100644
275--- a/llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt
276+++ b/llvm/lib/ExecutionEngine/Interpreter/CMakeLists.txt
277@@ -1,11 +1,3 @@
278-# Make sure that the path to libffi headers is on the command
279-# line. That path can be a compiler's non-default path even when
280-# FFI_INCLUDE_DIR was not used, because cmake has its own paths for
281-# searching for headers (CMAKE_SYSTEM_INCLUDE_PATH, for instance):
282-if( FFI_INCLUDE_PATH )
283- include_directories( ${FFI_INCLUDE_PATH} )
284-endif()
285-
286 add_llvm_component_library(LLVMInterpreter
287 Execution.cpp
288 ExternalFunctions.cpp
289@@ -22,5 +14,5 @@ add_llvm_component_library(LLVMInterpreter
290 )
291
292 if( LLVM_ENABLE_FFI )
293- target_link_libraries( LLVMInterpreter PRIVATE ffi )
294+ target_link_libraries( LLVMInterpreter PRIVATE FFI::ffi )
295 endif()
296diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
297index cdee11412eb5..5909eeef056a 100644
298--- a/llvm/lib/Support/CMakeLists.txt
299+++ b/llvm/lib/Support/CMakeLists.txt
300@@ -24,7 +24,7 @@ elseif( CMAKE_HOST_UNIX )
301 set(system_libs ${system_libs} ${Backtrace_LIBFILE})
302 endif()
303 if( LLVM_ENABLE_TERMINFO )
304- set(imported_libs ${imported_libs} "${TERMINFO_LIB}")
305+ set(imported_libs ${imported_libs} Terminfo::terminfo)
306 endif()
307 if( LLVM_ENABLE_THREADS AND (HAVE_LIBATOMIC OR HAVE_CXX_LIBATOMICS64) )
308 set(system_libs ${system_libs} atomic)
309@@ -249,7 +249,10 @@ if(LLVM_ENABLE_ZLIB)
310 endif()
311
312 if(LLVM_ENABLE_TERMINFO)
313- get_library_name(${TERMINFO_LIB} terminfo_library)
314+ if(NOT terminfo_library)
315+ get_property(terminfo_library TARGET Terminfo::terminfo PROPERTY LOCATION)
316+ endif()
317+ get_library_name(${terminfo_library} terminfo_library)
318 set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}")
319 endif()
320
diff --git a/recipes-devtools/clang/clang/0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch b/recipes-devtools/clang/clang/0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch
new file mode 100644
index 0000000..0bd32d1
--- /dev/null
+++ b/recipes-devtools/clang/clang/0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch
@@ -0,0 +1,27 @@
1From 78560720a00c1a9b9e8ab416c4cae0eb1f2d1352 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 27 Sep 2022 12:03:15 -0700
4Subject: [PATCH] llvm: Do not use standard search paths in find_library for
5 ncurses
6
7This helps it find it in yocto sysroots
8
9Upstream-Status: Pending
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 llvm/cmake/modules/FindTerminfo.cmake | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/llvm/cmake/modules/FindTerminfo.cmake b/llvm/cmake/modules/FindTerminfo.cmake
16index 65edb80fa69a..a58180be8926 100644
17--- a/llvm/cmake/modules/FindTerminfo.cmake
18+++ b/llvm/cmake/modules/FindTerminfo.cmake
19@@ -11,7 +11,7 @@
20 # Additionally, the following import target will be defined:
21 # Terminfo::terminfo
22
23-find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw)
24+find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
25
26 if(Terminfo_LIBRARIES)
27 include(CMakePushCheckState)
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc
index e211258..94619bd 100644
--- a/recipes-devtools/clang/common.inc
+++ b/recipes-devtools/clang/common.inc
@@ -41,6 +41,9 @@ SRC_URI = "\
41 file://0030-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \ 41 file://0030-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \
42 file://0031-compiler-rt-Use-mcr-based-barrier-on-armv6.patch \ 42 file://0031-compiler-rt-Use-mcr-based-barrier-on-armv6.patch \
43 file://0032-clang-Switch-defaults-to-dwarf-5-debug-info-on-Linux.patch \ 43 file://0032-clang-Switch-defaults-to-dwarf-5-debug-info-on-Linux.patch \
44 file://0033-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \
45 file://0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch \
46 file://0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch \
44" 47"
45# Fallback to no-PIE if not set 48# Fallback to no-PIE if not set
46GCCPIE ??= "" 49GCCPIE ??= ""