]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
compiler-rt-sanitizers: Fix build on mips
authorKhem Raj <raj.khem@gmail.com>
Fri, 23 May 2025 07:32:07 +0000 (00:32 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 27 May 2025 07:50:19 +0000 (08:50 +0100)
uintptr_t size is not consistent between compiler-rt and clang
for mips

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/clang/clang/0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch [new file with mode: 0644]
meta/recipes-devtools/clang/common.inc

diff --git a/meta/recipes-devtools/clang/clang/0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch b/meta/recipes-devtools/clang/clang/0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch
new file mode 100644 (file)
index 0000000..b54c163
--- /dev/null
@@ -0,0 +1,35 @@
+From 9f88f2e4efa56e53c78f9b67775c71afa711a69c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 22 May 2025 21:50:45 -0700
+Subject: [PATCH] [compiler-rt] Hardcode uptr/sptr typedefs on Mips/Linux
+
+Sanitizer build on Mips/Linux faills to build due to assertion errors
+mismatched definitions. This is due to inconsistent definitions of
+`uptr` of either `unsigned long` or `unsigned int` in compiler-rt. This
+is caused by clang defining
+
+__UINTPTR_TYPE__ long unsigned int where as gcc defines it as
+unsigned int
+
+As a workaround, this hardcodes `uptr`/`sptr` in compiler-rt to
+`unsigned int`/`int` on Linux Mips, matching gcc.
+
+Upstream-Status: Submitted [https://github.com/llvm/llvm-project/pull/141201]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
+index fff60c96f632..511ee8fe49cc 100644
+--- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
++++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
+@@ -139,7 +139,7 @@
+ namespace __sanitizer {
+ #if defined(__UINTPTR_TYPE__)
+-#  if defined(__arm__) && defined(__linux__)
++#  if (defined(__arm__) || _ABIO32 == 1) && defined(__linux__)
+ // Linux Arm headers redefine __UINTPTR_TYPE__ and disagree with clang/gcc.
+ typedef unsigned int uptr;
+ typedef int sptr;
index f661a6283e5378166e2474dc0b443f958fc530bf..24f82f381282778405827ccc94648ecd425f5886 100644 (file)
@@ -58,6 +58,7 @@ SRC_URI = "\
     file://0035-llvm-config-remove-LLVM_LDFLAGS-from-ldflags-output.patch \
     file://0036-openmp-Do-not-emit-date-and-time-into-generate-files.patch \
     file://0038-compiler-rt-Exclude-sync_fetch_and_-for-any-pre-ARMv.patch \
+    file://0038-compiler-rt-Hardcode-uptr-sptr-typedefs-on-Mips-Linu.patch \
 "
 # Fallback to no-PIE if not set
 GCCPIE ??= ""