[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250620111406.3365763-1-arnd@kernel.org>
Date: Fri, 20 Jun 2025 13:13:43 +0200
From: Arnd Bergmann <arnd@...nel.org>
To: Nathan Chancellor <nathan@...nel.org>,
Tony Ambardar <tony.ambardar@...il.com>,
Daniel Borkmann <daniel@...earbox.net>
Cc: Arnd Bergmann <arnd@...db.de>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>,
Kees Cook <kees@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev
Subject: [PATCH] kbuild: change __retain macro for gcc-11
From: Arnd Bergmann <arnd@...db.de>
Building kernels with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION using gcc-11
causes compiler warnings:
kernel/cgroup/rstat.c:65:1: error: 'retain' attribute ignored [-Werror=attributes]
It appears that this version reports __has_attribute(__retain__) as true
but doesn't actually support the feature.
Fixes: 0a5d3258d7c9 ("compiler_types.h: Define __retain for __attribute__((__retain__))")
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
include/linux/compiler_types.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 4684277bdd3b..c295b376a305 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -153,12 +153,15 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
* being optimized out, but operates at the compiler/IR-level and may still
* allow unintended removal of objects during linking.
*
- * Optional: only supported since gcc >= 11, clang >= 13
+ * Optional: only supported since gcc >= 12, clang >= 13
+ *
+ * On gcc-11 the feature is reported to be present but causes build warnings.
*
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-retain-function-attribute
* clang: https://clang.llvm.org/docs/AttributeReference.html#retain
*/
#if __has_attribute(__retain__) && \
+ (__GNUC__ != 11) && \
(defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || \
defined(CONFIG_LTO_CLANG))
# define __retain __attribute__((__retain__))
--
2.39.5
Powered by blists - more mailing lists