Re: Build failure with GCC 15 (-std=gnu23)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 19, 2024 at 1:47 PM Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>
> On Tue, Nov 19, 2024 at 04:24:41AM +0000, Sam James wrote:
> > 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.
>
> Sure. Masahiro, do you have any thoughts here? You can see the beginning
> of the thread at [1].
>
> I think the diff below would be a good first patch in a series that adds
> it to every other place that needs it. As you noticed, it probably makes
> sense to add it to most places that have CLANG_FLAGS, as that is a good
> indicator that KBUILD_CFLAGS is not being used properly in those spots.

I do not think this would solve the issue.

The attached diff will be useful when we bump -std=gnu* next time;
we would only need to change the single line.
However, this kind of change does not occur quite often.
Anyway, we would do "git grep std=gnu11" to make sure there is no left-over.

It is not helpful to detect the reported issue in
drivers/firmware/efi/libstub/Makefile.

Some Makefile overriding KBUILD_CFLAGS would forget to add
$(CSTD_FLAG), for the same reason as they would forget to add
-std=gnu11.









> > As a hack, I've injected it into CLANG_FLAGS locally for now as it
> > happens to appear in all the right places ;)
>
> :) exactly why I am quite familiar with this issue...
>
> [1]: https://lore.kernel.org/4OAhbllK7x4QJGpZjkYjtBYNLd_2whHx9oFiuZcGwtVR4hIzvduultkgfAIRZI3vQpZylu7Gl929HaYFRGeMEalWCpeMzCIIhLxxRhq4U-Y=@protonmail.com/
>
> Cheers,
> Nathan
>
> diff --git a/Makefile b/Makefile
> index 68a8faff2543..33cc6bcf39b5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -416,6 +416,8 @@ export KCONFIG_CONFIG
>  # SHELL used by kbuild
>  CONFIG_SHELL := sh
>
> +CSTD_FLAG := -std=gnu11
> +
>  HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
>  HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
>  HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
> @@ -437,7 +439,7 @@ HOSTRUSTC = rustc
>  HOSTPKG_CONFIG = pkg-config
>
>  KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
> -                        -O2 -fomit-frame-pointer -std=gnu11
> +                        -O2 -fomit-frame-pointer $(CSTD_FLAG)
>  KBUILD_USERCFLAGS  := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
>  KBUILD_USERLDFLAGS := $(USERLDFLAGS)
>
> @@ -545,7 +547,7 @@ LINUXINCLUDE    := \
>  KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
>
>  KBUILD_CFLAGS :=
> -KBUILD_CFLAGS += -std=gnu11
> +KBUILD_CFLAGS += $(CSTD_FLAG)
>  KBUILD_CFLAGS += -fshort-wchar
>  KBUILD_CFLAGS += -funsigned-char
>  KBUILD_CFLAGS += -fno-common
> @@ -589,7 +591,7 @@ export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AW
>  export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
>  export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
>  export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
> -export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
> +export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS CSTD_FLAG
>
>  export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
>  export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 25a2cb6317f3..5f9d5c38ed9e 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -65,7 +65,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>                 -fno-strict-aliasing -fno-common \
>                 -Werror-implicit-function-declaration \
>                 -Wno-format-security \
> -               -std=gnu11
> +               $(CSTD_FLAG)
>  VDSO_CFLAGS  += -O2
>  # Some useful compiler-dependent flags from top-level Makefile
>  VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign)
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 5b773b34768d..d5c851dd0653 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -47,7 +47,7 @@ endif
>
>  # How to compile the 16-bit code.  Note we always compile for -march=i386;
>  # that way we can complain to the user if the CPU is insufficient.
> -REALMODE_CFLAGS        := -std=gnu11 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
> +REALMODE_CFLAGS        := $(CSTD_FLAG) -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
>                    -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
>                    -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
>                    -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)



--
Best Regards
Masahiro Yamada





[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux