Re: [PATCH] tools/compiler: match glibc 2.42 definition of __attribute_const__

David Laight <[email protected]> Tue, 30 Jun 2026 18:41:06 +0100
Newsgroups gmane.linux.kbuild.devel,gmane.linux.kernel
Message-ID <20260630184106.7bb3f22f@pumpkin>
On Tue, 30 Jun 2026 23:58:40 +0900
"Joy H.J. Lee" <[email protected]> wrote:

> 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 when building with
> glibc 2.42 and GCC 15.
> 
> 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.
> 
> Signed-off-by: Joy H.J. Lee <[email protected]>
> ---
>  tools/include/linux/compiler.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
> index f40bd2b04..f2f54b038 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__))

That doesn't look right, you are completely changing the value
when it isn't already defined.

	David

>  #endif
>  
>  #ifndef __maybe_unused