Disable -Wattribute-alias for clang-23 and newer
Subsystems (4)
Nathan Chancellor
maintainerPATCH 1/1 Disable -Wattribute-alias for clang-23 and newer
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.
---
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(+)
arch/riscv/include/asm/syscall_wrapper.h +2 -0
@@ -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)))); \
include/linux/compat.h +2 -0
@@ -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); \
include/linux/compiler-clang.h +6 -0
@@ -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) \
include/linux/syscalls.h +2 -0
@@ -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); \
---
base-commit: 5d6919055dec134de3c40167a490f33c74c12581
change-id: 20260514-syscall-disable-attribute-alias-for-clang-51145bb90086
Best regards,
Signature · 2 lines
Cheers, Nathan
Nathan Chancellor
maintainerQuoted 93 lines · Nathan Chancellor
Clang recently added support for -Wattribute-alias [1], which results in the same warnings that necessitated commit
bee20031772a("disable -Wattribute-alias warning forSYSCALL_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.
Signed-off-by Nathan Chancellor <[email protected]>---
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(+)arch/riscv/include/asm/syscall_wrapper.h +2
-0@@ -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)))); \include/linux/compat.h +2
-0@@ -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); \include/linux/compiler-clang.h +6
-0@@ -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) \include/linux/syscalls.h +0
-0
include/linux/syscalls.h static inline int is_syscall_trace_event(struct trace_event_call *tp_event) · line 254
Quoted 8 lines
include/linux/syscalls.h +2
-0@@ -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
include/linux/compiler_types.h +4 -0
@@ -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.
Signature · 2 lines
Cheers, Nathan
This patch was applied to riscv/linux.git (fixes) by Nathan Chancellor <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (fixes)
by Nathan Chancellor <[email protected]>:
Quoted 30 lines · On Fri, 15 May 2026 19:35:18 +0900 you wrote:
Clang recently added support for -Wattribute-alias [1], which results in the same warnings that necessitated commit
bee20031772a("disable -Wattribute-alias warning forSYSCALL_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 | ^
Quoted 1 line
[...]
Here is the summary with links:
- Disable -Wattribute-alias for clang-23 and newer
https://git.kernel.org/riscv/c/175db11786bd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html