Skip to content

Commit 637775d

Browse files
committed
[compiler-rt] Hardcode uptr/sptr typedefs on Linux Arm
After llvm#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.
1 parent 5537ae8 commit 637775d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,14 @@
139139
namespace __sanitizer {
140140

141141
#if defined(__UINTPTR_TYPE__)
142+
#if defined(__arm__) && defined(__linux__)
143+
// Linux Arm headers redefine __UINTPTR_TYPE__ and disagree with clang/gcc.
144+
typedef unsigned int uptr;
145+
typedef int sptr;
146+
#else
142147
typedef __UINTPTR_TYPE__ uptr;
143148
typedef __INTPTR_TYPE__ sptr;
149+
#endif
144150
#elif defined(_WIN64)
145151
// 64-bit Windows uses LLP64 data model.
146152
typedef unsigned long long uptr;

0 commit comments

Comments
 (0)