[compiler-rt] [compiler-rt] Hardcode uptr/sptr typedefs on Linux Arm (PR #108105)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 15:27:40 PDT 2024


https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/108105

After #106155, Android arm32 asan builds stopped working with missing definition linker errors. This is due to inconsistent definitions of `uptr` of either `unsigned long` or `unsigned int` even between TUs in compiler-rt. This is caused by Linux arm32 headers redefining __UINTPTR_TYPE__ (see arch/arm/include/uapi/asm/types.h in the Linux kernel repo), meaning include order/whether or not the Linux header is included changes compiler-rt symbol mangling.

As a workaround, this hardcodes `uptr`/`sptr` in compiler-rt to `unsigned int`/`int` on Linux arm32, matching clang/gcc.

>From 637775d297364b2cdf0e67253d4d11b65b49f1cf Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Tue, 10 Sep 2024 22:14:21 +0000
Subject: [PATCH] [compiler-rt] Hardcode uptr/sptr typedefs on Linux Arm

After #106155, Android arm32 asan builds stopped working with missing definition linker errors. This is due to inconsistent definitions of `uptr` of either `unsigned long` or `unsigned int` even between TUs in compiler-rt. This is caused by Linux arm32 headers redefining __UINTPTR_TYPE__ (see arch/arm/include/uapi/asm/types.h in the Linux kernel repo), meaning include order/whether or not the Linux header is included changes compiler-rt symbol mangling.

As a workaround, this hardcodes `uptr`/`sptr` in compiler-rt to `unsigned int`/`int` on Linux arm32, matching clang/gcc.
---
 compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
index f8f03454ea169a..bf15d6704b4bd8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -139,8 +139,14 @@
 namespace __sanitizer {
 
 #if defined(__UINTPTR_TYPE__)
+#if defined(__arm__) && defined(__linux__)
+// Linux Arm headers redefine __UINTPTR_TYPE__ and disagree with clang/gcc.
+typedef unsigned int uptr;
+typedef int sptr;
+#else
 typedef __UINTPTR_TYPE__ uptr;
 typedef __INTPTR_TYPE__ sptr;
+#endif
 #elif defined(_WIN64)
 // 64-bit Windows uses LLP64 data model.
 typedef unsigned long long uptr;



More information about the llvm-commits mailing list