summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorJoy H.J. Lee <rkr0k0r@gmail.com>2026-07-02 05:06:35 +0900
committerAndrew Morton <akpm@linux-foundation.org>2026-08-03 21:10:08 -0700
commit8700a4761beb219873956666cf91776a2c61e698 (patch)
tree7a77a1ba9cd3a570c03162db586aa46537dace6d /tools/include
parent997b3de37c268f75d75d7d1f2c31ab9cf2626dea (diff)
tools/compiler: match glibc 2.42 definition of __attribute_const__
glibc 2.42 added __attribute_const__ to sys/cdefs.h: # define __attribute_const__ __attribute__ ((__const__)) GCC 15 warns when a macro is redefined to a different replacement list (-Wbuiltin-macro-redefined). Since host tool Makefiles (resolve_btfids, objtool) pass -Werror, this conflict becomes fatal. The warning is suppressed on standard native builds because GCC treats /usr/include as a system header path (-isystem), and macro-redefinition warnings from system headers are silently suppressed by GCC. It fires when glibc headers are on a regular include path (-I) instead, which is the case in cross-compilation setups such as NixOS, where the sysroot's glibc is passed explicitly via -I rather than -isystem. Per (C11 6.10.3), identical replacement lists are accepted silently. Match the glibc definition exactly, including the space before "((", so the redefinition is accepted without warning regardless of whether glibc headers are treated as system or non-system includes. Link: https://lore.kernel.org/20260701200635.3992767-1-rkr0k0r@gmail.com Signed-off-by: Joy H.J. Lee <rkr0k0r@gmail.com> Cc: Nathan Chancellor <nathan@kernel.org> Cc: David Laight <david.laight.linux@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/linux/compiler.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index f40bd2b04c29..f2f54b038168 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -119,7 +119,7 @@
#define __read_mostly
#ifndef __attribute_const__
-# define __attribute_const__
+# define __attribute_const__ __attribute__ ((__const__))
#endif
#ifndef __maybe_unused