]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Disable -Wattribute-alias for clang-23 and newer
authorNathan Chancellor <nathan@kernel.org>
Fri, 15 May 2026 19:34:14 +0000 (04:34 +0900)
committerNathan Chancellor <nathan@kernel.org>
Thu, 28 May 2026 13:51:30 +0000 (06:51 -0700)
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. Disable the
warning about unknown warning options to avoid breaking the build for
versions of clang-23 that do not have -Wattribute-alias, such as ones
deployed by vendors like Android or CI systems or when bisecting LLVM
between llvmorg-23-init and release/23.x.

Cc: stable@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/2163
Link: https://github.com/llvm/llvm-project/commit/40da6920a0d71d49dfa2392b09153600b0759f5e
Link: https://patch.msgid.link/20260515-syscall-disable-attribute-alias-for-clang-v1-1-9a9d95d41df6@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
arch/riscv/include/asm/syscall_wrapper.h
include/linux/compat.h
include/linux/compiler-clang.h
include/linux/compiler_types.h
include/linux/syscalls.h

index ac80216549ffa6fce76ffe1759ad4e0da4609f9f..226289c3b5c894241ffea553deb9460964bd4fc6 100644 (file)
@@ -32,6 +32,10 @@ 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, "-Wunknown-warning-option",                            \
+                     "Avoid breaking versions without -Wattribute-alias");             \
+       __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))));      \
index 56cebaff0c910fda853a0e2b3d6d0517e55f8b38..8da0a15c95f4e0f335a3220b0c8f6debf5ac593c 100644 (file)
        __diag_push();                                                          \
        __diag_ignore(GCC, 8, "-Wattribute-alias",                              \
                      "Type aliasing is used to sanitize syscall arguments");\
+       __diag_ignore(clang, 23, "-Wunknown-warning-option",                    \
+                     "Avoid breaking versions without -Wattribute-alias");     \
+       __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);                         \
index e1123dd284862beaaa5aad91ca9d98319d1ad85c..527e4e13602057664f8c988162ffde162810fe1f 100644 (file)
 #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) \
index e8fd77593b68d337faebf66f4b57a596ab3f4fba..369966598a2c0f4a76966bdd49eb237b8958c5ff 100644 (file)
@@ -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)
 
index f5639d5ac33164ab4870a7e9a4a14d3dc243f614..4fb7291f54b62b1d9662a73434eca4b2a647c5ac 100644 (file)
@@ -247,6 +247,10 @@ 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, "-Wunknown-warning-option",            \
+                     "Avoid breaking versions without -Wattribute-alias");\
+       __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);                        \