summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2025-03-22 09:40:36 -0700
committerKhem Raj <raj.khem@gmail.com>2025-03-23 15:28:04 -0700
commitc25d5f955310d77fa41d6a896b6b00ab7f50c72f (patch)
treeda2e2753f2e68c47fe6c3824bb736750d9a53909
parent7a0f84f429c34ddf40f29a6f0669cd312ec1153e (diff)
downloadmeta-clang-c25d5f955310d77fa41d6a896b6b00ab7f50c72f.tar.gz
compiler-rt-sanitizers: Fix build on riscv/musl
Fixes /compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:627:29: error: use of undeclared identifier 'TlsPreTcbSize' 627 | const uptr pre_tcb_size = TlsPreTcbSize(); | ^ 1 error generated. Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--recipes-devtools/clang/clang/0036-Fix-build-on-ppc64-musl.patch97
-rw-r--r--recipes-devtools/clang/common.inc1
2 files changed, 98 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0036-Fix-build-on-ppc64-musl.patch b/recipes-devtools/clang/clang/0036-Fix-build-on-ppc64-musl.patch
new file mode 100644
index 0000000..3abee7e
--- /dev/null
+++ b/recipes-devtools/clang/clang/0036-Fix-build-on-ppc64-musl.patch
@@ -0,0 +1,97 @@
1From a930a513c42524842931ec9dea7d16728f095043 Mon Sep 17 00:00:00 2001
2From: mojyack <mojyack@gmail.com>
3Date: Mon, 16 Dec 2024 13:42:04 +0900
4Subject: [PATCH] Fix build on ppc64+musl
5
6In powerpc64-unknown-linux-musl, signal.h does not include asm/ptrace.h,
7which causes "member access into incomplete type 'struct pt_regs'" errors.
8Include the header explicitly to fix this.
9
10Also in sanitizer_linux_libcdep.cpp, there is a usage of
11TlsPreTcbSize which is not defined in such a platform.
12Guard the branch with macro.
13
14Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/120036]
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 .../lib/sanitizer_common/sanitizer_linux.cpp | 4 ++++
18 .../sanitizer_common/sanitizer_linux_libcdep.cpp | 13 +++++++------
19 .../sanitizer_platform_limits_posix.cpp | 2 +-
20 .../sanitizer_stoptheworld_linux_libcdep.cpp | 3 ++-
21 4 files changed, 14 insertions(+), 8 deletions(-)
22
23diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
24index 7aa48d29d2d5..a4d526b4466c 100644
25--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
26+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
27@@ -86,6 +86,10 @@
28 # include <sys/sysmacros.h>
29 # endif
30
31+# if SANITIZER_LINUX && defined(__powerpc64__)
32+# include <asm/ptrace.h>
33+# endif
34+
35 # if SANITIZER_FREEBSD
36 # include <machine/atomic.h>
37 # include <sys/exec.h>
38diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
39index e11eff13cd32..331e1c7d8d15 100644
40--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
41+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
42@@ -619,21 +619,22 @@ static void GetTls(uptr *addr, uptr *size) {
43 *addr = tp - RoundUpTo(*size, align);
44 *size = tp - *addr + ThreadDescriptorSize();
45 # else
46- if (SANITIZER_GLIBC)
47- *size += 1664;
48- else if (SANITIZER_FREEBSD)
49- *size += 128; // RTLD_STATIC_TLS_EXTRA
50-# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
51+# if SANITIZER_GLIBC
52+ *size += 1664;
53+# elif SANITIZER_FREEBSD
54+ *size += 128; // RTLD_STATIC_TLS_EXTRA
55+# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
56 const uptr pre_tcb_size = TlsPreTcbSize();
57 *addr -= pre_tcb_size;
58 *size += pre_tcb_size;
59-# else
60+# else
61 // arm and aarch64 reserve two words at TP, so this underestimates the range.
62 // However, this is sufficient for the purpose of finding the pointers to
63 // thread-specific data keys.
64 const uptr tcb_size = ThreadDescriptorSize();
65 *addr -= tcb_size;
66 *size += tcb_size;
67+# endif
68 # endif
69 # endif
70 # elif SANITIZER_NETBSD
71diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
72index a5311d266b0c..ec5f2edab6a6 100644
73--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
74+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
75@@ -96,7 +96,7 @@
76 # include <sys/ptrace.h>
77 # if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
78 defined(__hexagon__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
79- defined(__sparc__)
80+ defined(__sparc__) || defined(__powerpc64__)
81 # include <asm/ptrace.h>
82 # ifdef __arm__
83 typedef struct user_fpregs elf_fpregset_t;
84diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
85index 945da99d41f4..58d17d90c343 100644
86--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
87+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
88@@ -31,7 +31,8 @@
89 #include <sys/types.h> // for pid_t
90 #include <sys/uio.h> // for iovec
91 #include <elf.h> // for NT_PRSTATUS
92-#if (defined(__aarch64__) || SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
93+#if (defined(__aarch64__) || defined(__powerpc64__) || \
94+ SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
95 !SANITIZER_ANDROID
96 // GLIBC 2.20+ sys/user does not include asm/ptrace.h
97 # include <asm/ptrace.h>
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc
index a6d9c4a..7b1733e 100644
--- a/recipes-devtools/clang/common.inc
+++ b/recipes-devtools/clang/common.inc
@@ -54,6 +54,7 @@ SRC_URI = "\
54 file://0033-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch \ 54 file://0033-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch \
55 file://0034-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch \ 55 file://0034-scan-build-py-respect-LLVM_LIBDIR_SUFFIX-like-other-.patch \
56 file://0035-compiler-rt-Do-not-pass-target-to-clang-compiler.patch \ 56 file://0035-compiler-rt-Do-not-pass-target-to-clang-compiler.patch \
57 file://0036-Fix-build-on-ppc64-musl.patch \
57" 58"
58# Fallback to no-PIE if not set 59# Fallback to no-PIE if not set
59GCCPIE ??= "" 60GCCPIE ??= ""