From: Sam James <sam@gentoo.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Kostadin Shishmanov <kostadinshishmanov@protonmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
arnd@arndb.de, linux-kbuild@vger.kernel.org
Subject: Re: Build failure with GCC 15 (-std=gnu23)
Date: Tue, 19 Nov 2024 04:24:41 +0000 [thread overview]
Message-ID: <87r077j1fa.fsf@gentoo.org> (raw)
In-Reply-To: <20241119041550.GA573925@thelio-3990X> (Nathan Chancellor's message of "Mon, 18 Nov 2024 21:15:50 -0700")
Nathan Chancellor <nathan@kernel.org> writes:
> On Tue, Nov 19, 2024 at 02:57:28AM +0000, Sam James wrote:
>> Nathan Chancellor <nathan@kernel.org> writes:
>>
>> > 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.
>>
>> FWIW, scripts/get_maintainers.pl for stddef.h and types.h doesn't
>> include kbuild -- maybe we should add that in.
>
> Yeah, it would be good to have someone own these files. Not sure it
> makes sense for Kbuild to be it though, I merely suggested that since
> the actual root cause of the error is more in Kbuild's realm.
Yeah, I couldn't figure out who a better person would be either :|
>
>> I can reproduce it with `make defconfig` at
>> 158f238aa69d91ad74e535c73f552bd4b025109c in Linus' tree with just `make
>> V=1 -j$(nproc) -l$(nproc)` (i.e. no CFLAGS manipulation at all).
>>
>> ```
>> # CC drivers/firmware/efi/libstub/x86-5lvl.o
>> gcc -Wp,-MMD,drivers/firmware/efi/libstub/.x86-5lvl.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/genera
>> ted/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__
>> -fmacro-prefix-map=./= -mcmodel=small -m64 -D__KERNEL__ -fPIC -fno-strict-aliasing -mno-red-zone -mno-mmx -mno-sse -fshort-wchar -Wno-pointer-sign -Wno-address-of-packed-member -fno-asy
>> nchronous-unwind-tables -Os -DDISABLE_BRANCH_PROFILING -include ./include/linux/hidden.h -D__NO_FORTIFY -ffreestanding -fno-stack-protector -D__DISABLE_EXPORTS -DKBUILD_MODFILE='"driv
>> ers/firmware/efi/libstub/x86-5lvl"' -DKBUILD_BASENAME='"x86_5lvl"' -DKBUILD_MODNAME='"x86_5lvl"' -D__KBUILD_MODNAME=kmod_x86_5lvl -c -o drivers/firmware/efi/libstub/x86-5lvl.o drivers/fi
>> rmware/efi/libstub/x86-5lvl.c
>> 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/linux/kasan-checks.h:5,
>> from ./include/asm-generic/rwonce.h:26,
>> from ./arch/x86/include/generated/asm/rwonce.h:1,
>> from ./include/linux/compiler.h:317,
>> from ./include/linux/build_bug.h:5,
>> from ./include/linux/init.h:5,
>> from ./include/linux/efi.h:15,
>> from drivers/firmware/efi/libstub/file.c:10:
>> ./include/linux/stddef.h:11:9: error: expected identifier before ‘false’
>> 11 | false = 0,
>> | ^~~~~
>> ```
>>
>> -std=gnu11 certainly isn't there.
>
> Ugh, this is because drivers/firmware/efi/libstub does not use
> KBUILD_CFLAGS from the rest of the kernel when targeting x86:
>
> $ sed -n '9,21p' drivers/firmware/efi/libstub/Makefile
> # non-x86 reuses KBUILD_CFLAGS, x86 does not
> cflags-y := $(KBUILD_CFLAGS)
>
> cflags-$(CONFIG_X86_32) := -march=i386
> cflags-$(CONFIG_X86_64) := -mcmodel=small
> cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \
> -fPIC -fno-strict-aliasing -mno-red-zone \
> -mno-mmx -mno-sse -fshort-wchar \
> -Wno-pointer-sign \
> $(call cc-disable-warning, address-of-packed-member) \
> $(call cc-disable-warning, gnu) \
> -fno-asynchronous-unwind-tables \
> $(CLANG_FLAGS)
>
> This isn't the first time this peculiarity has bitten us :/ sticking
> '-std=gnu11' in there should resolve that issue.
>
> arch/x86/boot/compressed/Makefile might need the same treatment. It
> might make sense to introduce something like 'CSTD_FLAG := -std=gnu11'
> then use that in the various places within the kernel that need it so it
> can be consistently updated in the future whenever needed. I see that
> flag in Makefile, arch/arm64/kernel/vdso32/Makefile, and
> arch/x86/Makefile.
This is the conclusion I just reached, although I'm struggling to figure
out a nice place to put it without sprinkling it all over the place. I'm
inclined to wait until kbuild folks weigh in so I don't do a lot of
(trivial, but tedious) work that needs changing.
As a hack, I've injected it into CLANG_FLAGS locally for now as it
happens to appear in all the right places ;)
>
> Cheers,
> Nathan
thanks,
sam
next prev parent reply other threads:[~2024-11-19 4:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 14:26 Build failure with GCC 15 (-std=gnu23) Kostadin Shishmanov
2024-11-18 20:56 ` Nathan Chancellor
2024-11-19 2:57 ` Sam James
2024-11-19 4:15 ` Nathan Chancellor
2024-11-19 4:24 ` Sam James [this message]
2024-11-19 4:47 ` Nathan Chancellor
2024-11-19 18:28 ` Masahiro Yamada
2025-01-21 0:16 ` Kees Cook
2025-01-21 21:53 ` Nathan Chancellor
2025-01-21 22:11 ` Sam James
2025-01-21 22:51 ` Nathan Chancellor
2024-11-19 6:53 ` Arnd Bergmann
2024-11-19 14:18 ` Nathan Chancellor
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=87r077j1fa.fsf@gentoo.org \
--to=sam@gentoo.org \
--cc=arnd@arndb.de \
--cc=kostadinshishmanov@protonmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.