[PATCH] LoongArch: Fix build failure with GCC 15 (-std=gnu23)

Tiezhu Yang posted 1 patch 1 year, 2 months ago
arch/loongarch/vdso/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] LoongArch: Fix build failure with GCC 15 (-std=gnu23)
Posted by Tiezhu Yang 1 year, 2 months ago
Whenever I try to build the kernel with upcoming GCC 15 which defaults
to -std=gnu23 I get a build failure:

  CC      arch/loongarch/vdso/vgetcpu.o
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/loongarch/include/generated/asm/rwonce.h:1,
                 from ./include/linux/compiler.h:317,
                 from ./include/asm-generic/bug.h:5,
                 from ./arch/loongarch/include/asm/bug.h:60,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/mmdebug.h:5,
                 from ./include/linux/mm.h:6,
                 from ./arch/loongarch/include/asm/vdso.h:10,
                 from arch/loongarch/vdso/vgetcpu.c:6:
./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;
      | ^~~~~~~

The kernel builds explicitly with -std=gnu11 in top Makefile, but
arch/loongarch/vdso does not use KBUILD_CFLAGS from the rest of the
kernel, just add -std=gnu11 flag to arch/loongarch/vdso/Makefile.

By the way, commit e8c07082a810 ("Kbuild: move to -std=gnu11") did a
similar change for arch/arm64/kernel/vdso32/Makefile.

Fixes: c6b99bed6b8f ("LoongArch: Add VDSO and VSYSCALL support")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/loongarch/vdso/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index 40c1175823d6..fdde1bcd4e26 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -19,7 +19,7 @@ ccflags-vdso := \
 cflags-vdso := $(ccflags-vdso) \
 	-isystem $(shell $(CC) -print-file-name=include) \
 	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
-	-O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
+	-std=gnu11 -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
 	-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
 	$(call cc-option, -fno-asynchronous-unwind-tables) \
 	$(call cc-option, -fno-stack-protector)
-- 
2.42.0
Re: [PATCH] LoongArch: Fix build failure with GCC 15 (-std=gnu23)
Posted by Huacai Chen 1 year, 2 months ago
Applied, thanks.

Huacai

On Tue, Nov 19, 2024 at 2:51 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> Whenever I try to build the kernel with upcoming GCC 15 which defaults
> to -std=gnu23 I get a build failure:
>
>   CC      arch/loongarch/vdso/vgetcpu.o
> 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/loongarch/include/generated/asm/rwonce.h:1,
>                  from ./include/linux/compiler.h:317,
>                  from ./include/asm-generic/bug.h:5,
>                  from ./arch/loongarch/include/asm/bug.h:60,
>                  from ./include/linux/bug.h:5,
>                  from ./include/linux/mmdebug.h:5,
>                  from ./include/linux/mm.h:6,
>                  from ./arch/loongarch/include/asm/vdso.h:10,
>                  from arch/loongarch/vdso/vgetcpu.c:6:
> ./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;
>       | ^~~~~~~
>
> The kernel builds explicitly with -std=gnu11 in top Makefile, but
> arch/loongarch/vdso does not use KBUILD_CFLAGS from the rest of the
> kernel, just add -std=gnu11 flag to arch/loongarch/vdso/Makefile.
>
> By the way, commit e8c07082a810 ("Kbuild: move to -std=gnu11") did a
> similar change for arch/arm64/kernel/vdso32/Makefile.
>
> Fixes: c6b99bed6b8f ("LoongArch: Add VDSO and VSYSCALL support")
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/loongarch/vdso/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
> index 40c1175823d6..fdde1bcd4e26 100644
> --- a/arch/loongarch/vdso/Makefile
> +++ b/arch/loongarch/vdso/Makefile
> @@ -19,7 +19,7 @@ ccflags-vdso := \
>  cflags-vdso := $(ccflags-vdso) \
>         -isystem $(shell $(CC) -print-file-name=include) \
>         $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
> -       -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
> +       -std=gnu11 -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
>         -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
>         $(call cc-option, -fno-asynchronous-unwind-tables) \
>         $(call cc-option, -fno-stack-protector)
> --
> 2.42.0
>