[compiler-rt] [compiler-rt] Simplify definition of uptr (PR #106155)

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


aeubanks wrote:

> Oh that is rather nasty - it sounds like Clang has the wrong **UINTPTR_TYPE** for Android arm32? And I guess changing that could have surprising effects?
IIUC clang agrees with gcc, so clang isn't wrong, it's just that the kernel wants a different type as `__UINTPTR_TYPE__` for some reason I don't understand.
> 
> I am surprised you did not get a compiler error, the compiler-rt/lib/interception/interception_type_test.cpp file should have failed to compile (unless it happens that in that file asm/types.h is included first and redefines **UINTPTR_TYPE**.
I'm not sure of the details, but yes either include order, or whether or not the Linux header is included at all changes behavior
> 
> I wonder if the workaround would be something like the following
> 
> ```
> #if defined(__arm) && defined(__linux__)
> #include <asm/types.h>
> #endif
> ```
> 
> Or alternatively just adding
> 
> ```
> #if defined(__arm) && defined(__linux__)
> // Clang and the Linux Arm headers disagree on uintptr_t
> typedef unsigned long uptr;
> typedef unsigned long sptr;
> #endif
> ```

I'll send out a PR that hardcodes `uptr` on Linux Arm


https://github.com/llvm/llvm-project/pull/106155


More information about the llvm-commits mailing list