[PATCH RFC next 08/18] scripts/Makefile.extrawarn: sync with 6.1
Tom Rini
trini at konsulko.com
Tue May 5 16:29:15 CEST 2026
On Tue, May 05, 2026 at 12:46:16PM +0200, Quentin Schulz wrote:
> Hi Simon,
>
> On 5/4/26 10:34 PM, Simon Glass wrote:
> > Hi Quentin,
> >
> > On 2026-05-04T13:20:27, Quentin Schulz <foss+uboot at 0leil.net> wrote:
> > > scripts/Makefile.extrawarn: sync with 6.1
> > >
> > > Sync scripts/Makefile.extrawarn with Linux kernel 6.1's.
> > >
> > > Since it adds a new option for KBUILD_EXTRA_WARN with e, document it as
> > > done in kernel commit c77d06e70d59 ("kbuild: support W=e to make build
> > > abort in case of warning").
> > >
> > > s/gcc/build/ in Makefile as done in kernel commit e27128db6283 ("kbuild:
> > > rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN"), part of
> > > v5.4. The rest of this commit was backported with commit bd3f9ee679b4
> > > ("kbuild: Bump the build system to 6.1").
> > >
> > > Our scripts/Makefile.extrawarn before this commit is Linux kernel's from
> > > v5.1 with the following diff:
> > >
> > > # diff --git a/proc/self/fd/11 b/proc/self/fd/13
> > > # --- a/proc/self/fd/11
> > > # +++ b/proc/self/fd/13
> > > # @@ -13,17 +13,8 @@
> > > [...]
> > >
> > > Makefile | 3 +-
> > > scripts/Makefile.extrawarn | 154 +++++++++++++++++++++++++++------------------
> > > 2 files changed, 95 insertions(+), 62 deletions(-)
> >
> > > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> > > @@ -22,64 +17,101 @@ endif
> > > ifdef CONFIG_CC_IS_CLANG
> > > -KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides)
> > > -KBUILD_CFLAGS += $(call cc-disable-warning, unused-value)
> > > -KBUILD_CFLAGS += $(call cc-disable-warning, format)
> > > -KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
> > > -KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
> > > -KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
> > > +KBUILD_CFLAGS += -Wno-initializer-overrides
> > > +# Clang before clang-16 would warn on default argument promotions.
> > > +ifneq ($(call clang-min-version, 160000),y)
> >
> > clang-min-version() is not defined anywhere that I can find. So I
> > believe $(call clang-min-version, 160000) always expands to empty, the
> > ifneq is always true and the inner ifeq always false.
> >
>
> Thanks for catching this. It seems scripts/Makefile.compiler is also not
> sync'ed with 6.1. We're missing kernel commit 88b61e3bff93
> ("Makefile.compiler: replace cc-ifversion with compiler-specific macros").
> I'll add that to the v2.
>
> > > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> > > @@ -22,64 +17,101 @@ endif
> > > -warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
> > > -warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
> > > -warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
> > > -
> > > -ifeq ("$(strip $(warning))","")
> > > - $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
> > > -endif
> >
> > Dropping this silently accepts make W=q as a no-op. That matches v6.1
> > so I'm fine with it, but please note the behaviour change in the
> > commit message so anyone bisecting a "my W=foo did nothing" report
> > finds it.
> >
>
> ACK. This was told in kernel commit 64a91907c896 ("kbuild: refactor
> scripts/Makefile.extrawarn"):
>
> This commit slightly changes the behavior, I think all of which are OK.
>
> [1] Currently, cc-option calls are needlessly evaluated. For example,
> warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
> needs evaluating only when W=3, but it is actually evaluated for
> W=1, W=2 as well. With this commit, only relevant cc-option calls
> will be evaluated. This is a slight optimization.
>
> [2] Currently, unsupported level like W=4 is checked by:
> $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
> This will no longer be checked, but I do not think it is a big
> deal.
>
> [3] Currently, 4 Clang warnings (Winitializer-overrides, Wformat,
> Wsign-compare, Wformat-zero-length) are shown by any of W=1, W=2,
> and W=3. With this commit, they will be warned only by W=1. I
> think this is a more correct behavior since each warning belongs
> to only one group.
>
> > > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> > > @@ -22,64 +17,101 @@ endif
> > > -warning-1 += $(call cc-disable-warning, missing-field-initializers)
> > > -warning-1 += $(call cc-disable-warning, sign-compare)
> > > +KBUILD_CFLAGS += -Wmissing-prototypes
> > > +KBUILD_CFLAGS += -Wold-style-definition
> > > +KBUILD_CFLAGS += -Wmissing-include-dirs
> >
> > ...
> > > +KBUILD_CFLAGS += -Wno-missing-field-initializers
> > > +KBUILD_CFLAGS += -Wno-sign-compare
> > > +KBUILD_CFLAGS += -Wno-type-limits
> > > +KBUILD_CFLAGS += -Wno-shift-negative-value
> >
> > Several flags previously wrapped in cc-option / cc-disable-warning are
> > now passed unconditionally (-Wmissing-prototypes,
> > -Wold-style-definition, -Wmissing-include-dirs, -Wno-type-limits,
> > -Wno-shift-negative-value). That's the v6.1 behaviour, fair enough.
> > What's the oldest gcc we support?
> >
>
> Pfew... That I don't know. We have an explicit check for GCC10 on ARM since
> commit bb1c2b463265 ("update GCC version check after Kbuild bump"). We have
> GCC4 min for PPC in arch/powerpc/config.mk with checkgcc4 target.
>
> mbedtls specifies they test against GCC 5.4, c.f.
> https://github.com/Mbed-TLS/mbedtls#tool-versions. Some parts in
> lib/mbedtls/external/mbedtls/library/aesce.c and
> lib/mbedtls/external/mbedtls/library/sha256.c require GCC6.
> lib/mbedtls/external/mbedtls/library/sha512.c requires GCC8.
>
> lwip's CI tests on ubuntu-latest GitHub runner, c.f. https://github.com/lwip-tcpip/lwip/blob/master/.github/workflows/ci-linux.yml#L9-L17.
> I don't know which version we've been using but it was merged for 2025.01
> and at that time ubuntu-latest GitHub worker was Ubuntu 22.04. I believe
> GCC10 was the version by default, though 9 to 12 are available in the
> Universe package feed.
>
> microMIPS requires GCC>=4.9, c.f. check in arch/mips/include/asm/compiler.h.
>
> include/linux/compiler-gcc.h requires GCC>=4.6.
>
> For the rest, I don't know. Maybe Tom does?
Absolute minimums are driven by other failures (for example, the bug we
hit that pushed arm to gcc 10). GCC 10 is over 5 years old, so saying
that's a global minimum is fine with me. And I've said before I'd be
open to a global check.
> The Linux kernel states in Documentation/process/changes.rst that the
> minimum GCC is 5.1 though "The gcc version requirements may vary depending
> on the type of CPU in your computer." (and I'm assuming "in your computer"
> applies to the target device, not the host machine).
I do wonder, idly, what platforms in the current kernel can build a
functional kernel with 5.1 :)
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260505/34872086/attachment.sig>
More information about the U-Boot
mailing list