linux-kernelorg-stable/include
Nathan Chancellor 17b41ca55c compiler-clang.h: define __SANITIZE_*__ macros only when undefined
commit 3fac212fe4 upstream.

Clang 22 recently added support for defining __SANITIZE__ macros similar
to GCC [1], which causes warnings (or errors with CONFIG_WERROR=y or W=e)
with the existing defines that the kernel creates to emulate this behavior
with existing clang versions.

  In file included from <built-in>:3:
  In file included from include/linux/compiler_types.h:171:
  include/linux/compiler-clang.h:37:9: error: '__SANITIZE_THREAD__' macro redefined [-Werror,-Wmacro-redefined]
     37 | #define __SANITIZE_THREAD__
        |         ^
  <built-in>:352:9: note: previous definition is here
    352 | #define __SANITIZE_THREAD__ 1
        |         ^

Refactor compiler-clang.h to only define the sanitizer macros when they
are undefined and adjust the rest of the code to use these macros for
checking if the sanitizers are enabled, clearing up the warnings and
allowing the kernel to easily drop these defines when the minimum
supported version of LLVM for building the kernel becomes 22.0.0 or newer.

Link: https://lkml.kernel.org/r/20250902-clang-update-sanitize-defines-v1-1-cf3702ca3d92@kernel.org
Link: 568c23bbd3 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-19 16:29:56 +02:00
..
acpi
asm-generic
clocksource
crypto
drm
dt-bindings
keys
kunit
kvm
linux compiler-clang.h: define __SANITIZE_*__ macros only when undefined 2025-09-19 16:29:56 +02:00
math-emu
media
memory
misc
net net: Fix null-ptr-deref by sock_lock_init_class_and_name() and rmmod. 2025-09-19 16:29:55 +02:00
pcmcia
ras
rdma
rv
scsi
soc
sound ASoC: soc-dai.h: merge DAI call back functions into ops 2025-08-28 16:26:03 +02:00
target
trace
uapi bonding: Add independent control state machine 2025-08-28 16:26:18 +02:00
ufs
vdso
video
xen