From: Nathan Chancellor <nathan@kernel.org>
To: Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH] Disable -Wattribute-alias for clang-23 and newer
Date: Sat, 16 May 2026 04:40:01 +0900 [thread overview]
Message-ID: <20260515194001.GA3434682@ax162> (raw)
In-Reply-To: <20260515-syscall-disable-attribute-alias-for-clang-v1-1-9a9d95d41df6@kernel.org>
On Fri, May 15, 2026 at 07:35:18PM +0900, Nathan Chancellor wrote:
> Clang recently added support for -Wattribute-alias [1], which results in
> the same warnings that necessitated commit bee20031772a ("disable
> -Wattribute-alias warning for SYSCALL_DEFINEx()") for GCC.
>
> kernel/time/itimer.c:325:1: error: alias and aliasee have different types 'long (unsigned int)' and 'long (typeof (__builtin_choose_expr((__builtin_types_compatible_p(typeof ((unsigned int)0), typeof (0LL)) || __builtin_types_compatible_p(typeof ((unsigned int)0), typeof (0ULL))), 0LL, 0L)))' (aka 'long (long)') [-Werror,-Wattribute-alias]
> 325 | SYSCALL_DEFINE1(alarm, unsigned int, seconds)
> | ^
> include/linux/syscalls.h:225:36: note: expanded from macro 'SYSCALL_DEFINE1'
> 225 | #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
> | ^
> include/linux/syscalls.h:236:2: note: expanded from macro 'SYSCALL_DEFINEx'
> 236 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
> | ^
> include/linux/syscalls.h:251:18: note: expanded from macro '__SYSCALL_DEFINEx'
> 251 | __attribute__((alias(__stringify(__se_sys##name)))); \
> | ^
> kernel/time/itimer.c:325:1: note: aliasee is declared here
> include/linux/syscalls.h:225:36: note: expanded from macro 'SYSCALL_DEFINE1'
> 225 | #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
> | ^
> include/linux/syscalls.h:236:2: note: expanded from macro 'SYSCALL_DEFINEx'
> 236 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
> | ^
> include/linux/syscalls.h:255:18: note: expanded from macro '__SYSCALL_DEFINEx'
> 255 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
> | ^
> <scratch space>:16:1: note: expanded from here
> 16 | __se_sys_alarm
> | ^
>
> Disable the warnings in the same way for clang-23 and newer.
>
> Cc: stable@vger.kernel.org
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2163
> Link: https://github.com/llvm/llvm-project/commit/40da6920a0d71d49dfa2392b09153600b0759f5e [1]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> I plan to take this via my clang-fixes tree for 7.1.
> ---
> arch/riscv/include/asm/syscall_wrapper.h | 2 ++
> include/linux/compat.h | 2 ++
> include/linux/compiler-clang.h | 6 ++++++
> include/linux/syscalls.h | 2 ++
> 4 files changed, 12 insertions(+)
>
> diff --git a/arch/riscv/include/asm/syscall_wrapper.h b/arch/riscv/include/asm/syscall_wrapper.h
> index ac80216549ff..366a5354caa5 100644
> --- a/arch/riscv/include/asm/syscall_wrapper.h
> +++ b/arch/riscv/include/asm/syscall_wrapper.h
> @@ -32,6 +32,8 @@ asmlinkage long __riscv_sys_ni_syscall(const struct pt_regs *);
> __diag_push(); \
> __diag_ignore(GCC, 8, "-Wattribute-alias", \
> "Type aliasing is used to sanitize syscall arguments"); \
> + __diag_ignore(clang, 23, "-Wattribute-alias", \
> + "Type aliasing is used to sanitize syscall arguments"); \
> static long __se_##prefix##name(ulong, ulong, ulong, ulong, ulong, ulong, \
> ulong) \
> __attribute__((alias(__stringify(___se_##prefix##name)))); \
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index 56cebaff0c91..a1ce6d559db9 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -72,6 +72,8 @@
> __diag_push(); \
> __diag_ignore(GCC, 8, "-Wattribute-alias", \
> "Type aliasing is used to sanitize syscall arguments");\
> + __diag_ignore(clang, 23, "-Wattribute-alias", \
> + "Type aliasing is used to sanitize syscall arguments");\
> asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
> __attribute__((alias(__stringify(__se_compat_sys##name)))); \
> ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO); \
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index e1123dd28486..527e4e136020 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -131,6 +131,12 @@
> #define __diag_str(s) __diag_str1(s)
> #define __diag(s) _Pragma(__diag_str(clang diagnostic s))
>
> +#if CONFIG_CLANG_VERSION >= 230000
> +#define __diag_clang_23(s) __diag(s)
> +#else
> +#define __diag_clang_23(s)
> +#endif
> +
> #define __diag_clang_13(s) __diag(s)
>
> #define __diag_ignore_all(option, comment) \
> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> index f5639d5ac331..97e3411b49d2 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -247,6 +247,8 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
> __diag_push(); \
> __diag_ignore(GCC, 8, "-Wattribute-alias", \
> "Type aliasing is used to sanitize syscall arguments");\
> + __diag_ignore(clang, 23, "-Wattribute-alias", \
> + "Type aliasing is used to sanitize syscall arguments");\
> asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
> __attribute__((alias(__stringify(__se_sys##name)))); \
> ALLOW_ERROR_INJECTION(sys##name, ERRNO); \
The kbuild test robot pointed out that I need
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index e8fd77593b68..369966598a2c 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -711,6 +711,10 @@ struct ftrace_likely_data {
#define __diag_GCC(version, severity, string)
#endif
+#ifndef __diag_clang
+#define __diag_clang(version, severity, string)
+#endif
+
#define __diag_push() __diag(push)
#define __diag_pop() __diag(pop)
--
for this to build properly with GCC, which I will fold in.
--
Cheers,
Nathan
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
prev parent reply other threads:[~2026-05-15 19:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 10:35 [PATCH] Disable -Wattribute-alias for clang-23 and newer Nathan Chancellor
2026-05-15 19:40 ` Nathan Chancellor [this message]
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=20260515194001.GA3434682@ax162 \
--to=nathan@kernel.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=stable@vger.kernel.org \
/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