91121b7bacb74400f304a31101fc2ed2a491d2a3
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 005-v5.17-03-Kbuild-use-std-gnu11-for-KBUILD_USERCFLAGS.patch
1 From 40337d6f3d677aee7ad3052ae662d3f53dd4d5cb Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Tue, 8 Mar 2022 22:56:15 +0100
4 Subject: [PATCH 3/3] Kbuild: use -std=gnu11 for KBUILD_USERCFLAGS
5
6 As we change the C language standard for the kernel from gnu89 to
7 gnu11, it makes sense to also update the version for user space
8 compilation.
9
10 Some users have older native compilers than what they use for
11 kernel builds, so I considered using gnu99 as the default version
12 for wider compatibility with gcc-4.6 and earlier.
13
14 However, testing with older compilers showed that we already require
15 HOSTCC version 5.1 as well because a lot of host tools include
16 linux/compiler.h that uses __has_attribute():
17
18 CC tools/objtool/exec-cmd.o
19 In file included from tools/include/linux/compiler_types.h:36:0,
20 from tools/include/linux/compiler.h:5,
21 from exec-cmd.c:2:
22 tools/include/linux/compiler-gcc.h:19:5: error: "__has_attribute" is not defined [-Werror=undef]
23
24 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
25 Reviewed-by: Nathan Chancellor <nathan@kernel.org>
26 Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
27 Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
28 Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
29 ---
30 Makefile | 2 +-
31 1 file changed, 1 insertion(+), 1 deletion(-)
32
33 --- a/Makefile
34 +++ b/Makefile
35 @@ -433,7 +433,7 @@ endif
36 HOSTPKG_CONFIG = pkg-config
37
38 export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
39 - -O2 -fomit-frame-pointer -std=gnu89 \
40 + -O2 -fomit-frame-pointer -std=gnu11 \
41 -Wdeclaration-after-statement
42 export KBUILD_USERLDFLAGS :=
43