[compiler-rt] 45138f7 - [sanitizer] Define 32bit uptr as uint

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 02:00:48 PDT 2021


On Sat, 14 Aug 2021, Vitaly Buka via llvm-commits wrote:

>
> Author: Vitaly Buka
> Date: 2021-08-14T16:53:46-07:00
> New Revision: 45138f788c9b3c4ac5d9ae4479841c411c15190e
>
> URL: https://github.com/llvm/llvm-project/commit/45138f788c9b3c4ac5d9ae4479841c411c15190e
> DIFF: https://github.com/llvm/llvm-project/commit/45138f788c9b3c4ac5d9ae4479841c411c15190e.diff
>
> LOG: [sanitizer] Define 32bit uptr as uint
>
> This makes it consistent with uintptr_t.
>
> Added:
> 
>
> Modified:
>    compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
>    compiler-rt/lib/sanitizer_common/tests/sanitizer_bitvector_test.cpp
>
> Removed:
> 
>
>
> ################################################################################
> diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
> index f7fdc160eeb1c..07b303e06a098 100644
> --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
> +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
> @@ -139,8 +139,13 @@ namespace __sanitizer {
> typedef unsigned long long uptr;
> typedef signed long long sptr;
> #else
> +#  if (SANITIZER_WORDSIZE == 64)
> typedef unsigned long uptr;
> typedef signed long sptr;
> +#  else
> +typedef unsigned int uptr;
> +typedef signed int sptr;
> +#  endif
> #endif  // defined(_WIN64)

Hi,

This change broke compilation for me for i686 mingw targets, with this 
error:

/build/llvm-mingw/prefix/i686-w64-mingw32/include/basetsd.h:147:39: 
error: typedef redefinition with different types ('ULONG_PTR' (aka 
'unsigned long') vs '__sanitizer::uptr' (aka 'unsigned int'))
   __MINGW_EXTENSION typedef ULONG_PTR SIZE_T,*PSIZE_T;
                                       ^
../lib/interception/interception.h:27:30: note: previous definition is 
here
typedef __sanitizer::uptr    SIZE_T;
                              ^

In both MinGW and MSVC header sets, SIZE_T is typedeffed from ULONG_PTR, 
which is a typedef for unsigned long.

I was about to post a patch like this:

-#  if (SANITIZER_WORDSIZE == 64)
+#  if (SANITIZER_WORDSIZE == 64) || defined(_WIN32)
+// 32 bit Windows has got a 32 bit 'long', and uses that type as base for
+// e.g. SIZE_T and similar.


... but now I see it has been reverted due to breaking Darwin too.

// Martin



More information about the llvm-commits mailing list