[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241118205629.GA15698@thelio-3990X>
Date: Mon, 18 Nov 2024 13:56:29 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Kostadin Shishmanov <kostadinshishmanov@...tonmail.com>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"sam@...too.org" <sam@...too.org>, arnd@...db.de,
linux-kbuild@...r.kernel.org
Subject: Re: Build failure with GCC 15 (-std=gnu23)
Hi Kostadin,
Just a quick FYI off the bat, you only directed this to LKML, which is
basically like sending it into the void because very few people actually
read every message on LKML. I only caught it because I have a filter set
up for mentions of Clang and LLVM. I'd suggest adding at least the
Kbuild mailing list, which I have done now. I have also added Arnd
because I seem to recall him looking into how hard it would be to build
the kernel with C23.
On Mon, Nov 18, 2024 at 02:26:49PM +0000, Kostadin Shishmanov wrote:
> 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"
The kernel builds explicitly with '-std=gnu11' (see Makefile), so I
would not expect the default switch on the GCC side to matter. That
signals to me that we are not actually using that flag everywhere then?
Building with V=1, I can see '-std=gnu11' in the compiler command for
scripts/mod/devicetable-offsets.s, which is generated from
scripts/mod/devicetable-offsets.c, so it seems like something else is
going on here?
> With Clang 18 and KCFLAGS="-std=c23" it's an even bigger mess:
I think the error below occurs because you used 'c23' instead of
'gnu23'. GCC's documentation states:
"The asm keyword is a GNU extension. When writing code that can be
compiled with -ansi and the various -std options, use __asm__ instead of
asm (see Alternate Keywords)."
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
Cheers,
Nathan
> ```
> 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
>
Powered by blists - more mailing lists