diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt --- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt @@ -202,9 +202,6 @@ set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -# Too many existing bugs, needs cleanup. -append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format SANITIZER_CFLAGS) - append_rtti_flag(OFF SANITIZER_CFLAGS) append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -230,19 +230,27 @@ // Please only use the ALIGNED macro before the type. // Using ALIGNED after the variable declaration is not portable! # define ALIGNED(x) __attribute__((aligned(x))) -# define FORMAT(f, a) __attribute__((format(printf, f, a))) -# define NOINLINE __attribute__((noinline)) -# define NORETURN __attribute__((noreturn)) -# define THREADLOCAL __thread -# define LIKELY(x) __builtin_expect(!!(x), 1) -# define UNLIKELY(x) __builtin_expect(!!(x), 0) -# if defined(__i386__) || defined(__x86_64__) +// Check format strings on 64-bits only because we use %zx to print uptr type, +// but %zx expects size_t and on 32-bits size_t is defined as 'unsigned int' +// while we define uptr as 'unsigned long' which causes lots of -Wformat +// warnings. This can be fixed by defining uptr as 'unsigned int' on 32-bits. +# if __LP64__ +# define FORMAT(f, a) __attribute__((format(printf, f, a))) +# else +# define FORMAT(f, a) +# endif +# define NOINLINE __attribute__((noinline)) +# define NORETURN __attribute__((noreturn)) +# define THREADLOCAL __thread +# define LIKELY(x) __builtin_expect(!!(x), 1) +# define UNLIKELY(x) __builtin_expect(!!(x), 0) +# if defined(__i386__) || defined(__x86_64__) // __builtin_prefetch(x) generates prefetchnt0 on x86 -# define PREFETCH(x) __asm__("prefetchnta (%0)" : : "r" (x)) -# else -# define PREFETCH(x) __builtin_prefetch(x) -# endif -# define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +# define PREFETCH(x) __asm__("prefetchnta (%0)" : : "r"(x)) +# else +# define PREFETCH(x) __builtin_prefetch(x) +# endif +# define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #endif // _MSC_VER #if !defined(_MSC_VER) || defined(__clang__)