summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-devtools/clang/clang/0038-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch61
-rw-r--r--meta/recipes-devtools/clang/common.inc1
2 files changed, 62 insertions, 0 deletions
diff --git a/meta/recipes-devtools/clang/clang/0038-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch b/meta/recipes-devtools/clang/clang/0038-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch
new file mode 100644
index 0000000000..4639a73fe6
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0038-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch
@@ -0,0 +1,61 @@
1From 5a0daa2dcc2bb39d87c4fcae7036cd8ab7ee6f6d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 10 May 2025 14:03:12 -0700
4Subject: [PATCH] compiler-rt: Exclude sync_fetch_and_* for any pre-ARMv6 targets
5
6Sometimes builds may happen where ABI is not indidated by host_triple
7e.g. on Yocto the compiler used is called arm-poky-linux-gnueabi-clang
8for all arm32 cross compilers, it passed the ABI flags on cmdline in
9addition. e.g.
10
11-march=armv5te -mfloat-abi=soft
12or
13-march=armv7-a -mfloat-abi=hard
14
15compiler-rt's makery tries to add arm to COMPILER_RT_SUPPORTED_ARCH
16deducing it from triple name.
17
18which ends up choosing `arm` as one of compiler-rt arch to build for.
19This arch is however using armv7+ defaults and then tried to build sync
20builtins using
21
22arm-poky-linux-gnueabi-clang -march=armv5te -mfloat-abi=soft ...
23
24Which does not compile correctly, in such cases it should simply
25remove the sync builtins from list of things to build similar to what
26is done when we use armv4t or armv5t
27
28set(armv4t_SOURCES ${arm_min_SOURCES})
29set(armv5te_SOURCES ${arm_min_SOURCES})
30
31This lets compiler-rt build for arm architectures without depending
32upong compiler triple, but instead of poking the compiler for what
33it is building for
34
35Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/139411]
36Signed-off-by: Khem Raj <raj.khem@gmail.com>
37---
38 compiler-rt/lib/builtins/CMakeLists.txt | 12 ++++++++++++
39 1 file changed, 12 insertions(+)
40
41--- a/compiler-rt/lib/builtins/CMakeLists.txt
42+++ b/compiler-rt/lib/builtins/CMakeLists.txt
43@@ -864,6 +864,18 @@ else ()
44 list(JOIN BUILTIN_CFLAGS " " CMAKE_REQUIRED_FLAGS)
45 set(CMAKE_REQUIRED_FLAGS "${TARGET_${arch}_CFLAGS} ${BUILTIN_CFLAGS_${arch}}")
46 message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}")
47+ # For ARM archs, exclude any sync builtins if dmb or mcr p15, #0, r0, c7, c10, #5
48+ # is not supported
49+ if (${arch} MATCHES "^(arm|armhf)$")
50+ try_compile_only(COMPILER_RT_HAS_${arch}_SYNC
51+ SOURCE "#if __ARM_ARCH < 6
52+ #error DMB is only supported on ARMv6+ !
53+ #endif
54+ int main(void) { return 0; }")
55+ if(NOT COMPILER_RT_HAS_${arch}_SYNC)
56+ list(REMOVE_ITEM ${arch}_SOURCES ${arm_sync_SOURCES})
57+ endif()
58+ endif()
59 # For ARM archs, exclude any VFP builtins if VFP is not supported
60 if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$")
61 string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")
diff --git a/meta/recipes-devtools/clang/common.inc b/meta/recipes-devtools/clang/common.inc
index 07315f17e4..f661a6283e 100644
--- a/meta/recipes-devtools/clang/common.inc
+++ b/meta/recipes-devtools/clang/common.inc
@@ -57,6 +57,7 @@ SRC_URI = "\
57 file://0034-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \ 57 file://0034-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch \
58 file://0035-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch \ 58 file://0035-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch \
59 file://0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch \ 59 file://0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch \
60 file://0038-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch \
60" 61"
61# Fallback to no-PIE if not set 62# Fallback to no-PIE if not set
62GCCPIE ??= "" 63GCCPIE ??= ""