[compiler-rt] [compiler-rt] Hardcode uptr/sptr typedefs on Linux Arm (PR #108105)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 15:28:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Arthur Eubanks (aeubanks)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/108105.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h (+6)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/108105
More information about the llvm-commits
mailing list