Build failure with GCC 15 (-std=gnu23)

From: Kostadin Shishmanov
Date: Mon Nov 18 2024 - 09:27:40 EST


Whenever I try to build the kernel with upcoming GCC 15 which defaults to -std=gnu23 I get a build failure:

```
In file included from ./include/uapi/linux/posix_types.h:5,
from ./include/uapi/linux/types.h:14,
from ./include/linux/types.h:6,
from ./include/uapi/linux/mei_uuid.h:12,
from ./include/uapi/linux/mei.h:10,
from ./include/linux/mod_devicetable.h:12,
from scripts/mod/devicetable-offsets.c:3:
./include/linux/stddef.h:11:9: error: expected identifier before ‘false’
11 | false = 0,
./include/linux/types.h:35:33: error: two or more data types in declaration specifiers
35 | typedef _Bool bool;
./include/linux/types.h:35:1: warning: useless type name in empty declaration
35 | typedef _Bool bool;
```

This can be reproduced on older GCC versions with KCFLAGS="-std=gnu23"


With Clang 18 and KCFLAGS="-std=c23" it's an even bigger mess:

```
In file included from ./arch/x86/include/asm/jump_label.h:7,
from ./include/linux/jump_label.h:112,
from ./arch/x86/include/asm/string_64.h:6,
from ./arch/x86/include/asm/string.h:5,
from ./include/linux/string.h:64,
from ./include/linux/uuid.h:11,
from ./include/linux/mod_devicetable.h:14:
./arch/x86/include/asm/asm.h: In function ‘rip_rel_ptr’:
./arch/x86/include/asm/asm.h:120:9: error: implicit declaration of function ‘asm’ [-Wimplicit-function-declaration]
120 | asm("leaq %c1(%%rip), %0" : "=r"(p) : "i"(p));
./arch/x86/include/asm/asm.h:120:34: error: expected ‘)’ before ‘:’ token
120 | asm("leaq %c1(%%rip), %0" : "=r"(p) : "i"(p));
./arch/x86/include/asm/asm.h: At top level:
./arch/x86/include/asm/asm.h:222:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘asm’
222 | register unsigned long current_stack_pointer asm(_ASM_SP);
./arch/x86/include/asm/jump_label.h: In function ‘arch_static_branch’:
./arch/x86/include/asm/jump_label.h:27:9: error: ‘asm’ undeclared (first use in this function)
27 | asm goto("1:"
./arch/x86/include/asm/jump_label.h:27:9: note: each undeclared identifier is reported only once for each function it appears in
./arch/x86/include/asm/jump_label.h:27:12: error: expected ‘;’ before ‘goto’
27 | asm goto("1:"
;
In file included from ./include/uapi/linux/swab.h:8,
from ./include/linux/swab.h:5,
from ./include/uapi/linux/byteorder/little_endian.h:14,
from ./include/linux/byteorder/little_endian.h:5,
from ./arch/x86/include/uapi/asm/byteorder.h:5,
from ./include/linux/bitfield.h:11,
from ./include/linux/fortify-string.h:5,
from ./include/linux/string.h:390:
./arch/x86/include/uapi/asm/swab.h: In function ‘__arch_swab32’:
./arch/x86/include/uapi/asm/swab.h:10:24: error: expected ‘)’ before ‘:’ token
10 | asm("bswapl %0" : "=r" (val) : "0" (val));
)
./arch/x86/include/uapi/asm/swab.h: In function ‘__arch_swab64’:
./arch/x86/include/uapi/asm/swab.h:31:24: error: expected ‘)’ before ‘:’ token
31 | asm("bswapq %0" : "=r" (val) : "0" (val));
)
In file included from scripts/mod/devicetable-offsets.c:2:
scripts/mod/devicetable-offsets.c: In function ‘main’:
./include/linux/kbuild.h:6:9: error: ‘asm’ undeclared (first use in this function)
6 | asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
scripts/mod/devicetable-offsets.c:5:22: note: in expansion of macro ‘DEFINE’
5 | #define DEVID(devid) DEFINE(SIZE_##devid, sizeof(struct devid))
scripts/mod/devicetable-offsets.c:11:9: note: in expansion of macro ‘DEVID’
11 | DEVID(usb_device_id);
./include/linux/kbuild.h:6:13: error: expected ‘;’ before ‘volatile’
6 | asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
```

There is a lot more output from the compiler that i've cut off because the email would become way too long.

Regards,
Kostadin