0036-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From c62140c7e116fabe7bccf9b55848c74e5beefccd Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Tue, 21 Feb 2023 12:46:10 -0800
  4. Subject: [PATCH] compiler-rt: Undef _TIME_BITS along with _FILE_OFFSET_BITS in
  5. sanitizers
  6. On 32bit systems using 64bit time_t build fails because
  7. _FILE_OFFSET_BITS is undefined here but _TIME_BITS is still set to 64
  8. Fixes
  9. In file included from compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp:17:
  10. In file included from compiler-rt/lib/sanitizer_common/sanitizer_platform.h:25:
  11. In file included from /usr/include/features.h:393:
  12. /usr/include/features-time64.h:26:5: error: "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
  13. ^
  14. 1 error generated.
  15. Upstream-Status: Submitted [https://reviews.llvm.org/D144514]
  16. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  17. ---
  18. compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 9 +++++++++
  19. 1 file changed, 9 insertions(+)
  20. diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
  21. index 764996e57355..df3d165ecdb6 100644
  22. --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
  23. +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
  24. @@ -22,6 +22,15 @@
  25. // function declarations into a .S file which doesn't compile.
  26. // https://crbug.com/1162741
  27. #if __has_include(<features.h>) && !defined(__ANDROID__)
  28. +// Some sources undefine _FILE_OFFSET_BITS deliberately e.g.
  29. +// sanitizer_procmaps_solaris.cpp. This is problematic on glibc systems with
  30. +// 32-bit architectures using 64-bit time_t and users passing _TIME_BITS=64
  31. +// from build environment, therefore both _FILE_OFFSET_BITS and _TIME_BITS
  32. +// need to be undefined together since features.h will check for both being 64
  33. +// if one is set to 64
  34. +# if !defined(_FILE_OFFSET_BITS)
  35. +# undef _TIME_BITS
  36. +# endif
  37. # include <features.h>
  38. #endif