mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>,
	Tony Ambardar <tony.ambardar@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Kees Cook <kees@kernel.org>, Miguel Ojeda <ojeda@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH] kbuild: change __retain macro for gcc-11
Date: Fri, 20 Jun 2025 13:13:43 +0200	[thread overview]
Message-ID: <20250620111406.3365763-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.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@arndb.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


             reply	other threads:[~2025-06-20 11:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 11:13 Arnd Bergmann [this message]
2025-06-20 13:00 ` Miguel Ojeda
2025-06-20 13:02   ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250620111406.3365763-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=daniel@iogearbox.net \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=tony.ambardar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®