diff options
author | Olliver Schinagl <oliver@schinagl.nl> | 2022-09-04 22:08:47 +0200 |
---|---|---|
committer | Christian Marangi <ansuelsmth@gmail.com> | 2022-10-13 16:03:35 +0200 |
commit | 41a1a652fbd407a40d55a07bccdbc92770a4c2be (patch) | |
tree | 785e3241cb775121ad98ab8bd39125976287efd0 /target/linux/generic/backport-5.15/005-v5.17-02-Kbuild-move-to-std-gnu11.patch | |
parent | 2f8ac8bcea879542b2bc414a108c3aff166d5ef5 (diff) | |
download | upstream-41a1a652fbd407a40d55a07bccdbc92770a4c2be.tar.gz upstream-41a1a652fbd407a40d55a07bccdbc92770a4c2be.tar.bz2 upstream-41a1a652fbd407a40d55a07bccdbc92770a4c2be.zip |
kernel: backport gnu11 upgrade
Upstream has switched to gnu11 not too long ago. One advantage of
backporting this to these older kernels is, that we can encourage and
write better upstreamable kernels. E.g. the kernel devs prefer loop
declarations. Shrinking the master/local gap will be useful in these
cases.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Acked-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'target/linux/generic/backport-5.15/005-v5.17-02-Kbuild-move-to-std-gnu11.patch')
-rw-r--r-- | target/linux/generic/backport-5.15/005-v5.17-02-Kbuild-move-to-std-gnu11.patch | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.15/005-v5.17-02-Kbuild-move-to-std-gnu11.patch b/target/linux/generic/backport-5.15/005-v5.17-02-Kbuild-move-to-std-gnu11.patch new file mode 100644 index 0000000000..79bda0cd7e --- /dev/null +++ b/target/linux/generic/backport-5.15/005-v5.17-02-Kbuild-move-to-std-gnu11.patch @@ -0,0 +1,64 @@ +From b810c8e719ea082e47c7a8f7cf878bc84fa2455d Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann <arnd@arndb.de> +Date: Tue, 8 Mar 2022 22:56:14 +0100 +Subject: [PATCH 2/3] Kbuild: move to -std=gnu11 + +During a patch discussion, Linus brought up the option of changing +the C standard version from gnu89 to gnu99, which allows using variable +declaration inside of a for() loop. While the C99, C11 and later standards +introduce many other features, most of these are already available in +gnu89 as GNU extensions as well. + +An earlier attempt to do this when gcc-5 started defaulting to +-std=gnu11 failed because at the time that caused warnings about +designated initializers with older compilers. Now that gcc-5.1 is +the minimum compiler version used for building kernels, that is no +longer a concern. Similarly, the behavior of 'inline' functions changes +between gnu89 using gnu_inline behavior and gnu11 using standard c99+ +behavior, but this was taken care of by defining 'inline' to include +__attribute__((gnu_inline)) in order to allow building with clang a +while ago. + +Nathan Chancellor reported a new -Wdeclaration-after-statement +warning that appears in a system header on arm, this still needs a +workaround. + +The differences between gnu99, gnu11, gnu1x and gnu17 are fairly +minimal and mainly impact warnings at the -Wpedantic level that the +kernel never enables. Between these, gnu11 is the newest version +that is supported by all supported compiler versions, though it is +only the default on gcc-5, while all other supported versions of +gcc or clang default to gnu1x/gnu17. + +Link: https://lore.kernel.org/lkml/CAHk-=wiyCH7xeHcmiFJ-YgXUy2Jaj7pnkdKpcovt8fYbVFW3TA@mail.gmail.com/ +Link: https://github.com/ClangBuiltLinux/linux/issues/1603 +Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> +Acked-by: Marco Elver <elver@google.com> +Acked-by: Jani Nikula <jani.nikula@intel.com> +Acked-by: David Sterba <dsterba@suse.com> +Tested-by: Sedat Dilek <sedat.dilek@gmail.com> +Reviewed-by: Alex Shi <alexs@kernel.org> +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> +Reviewed-by: Miguel Ojeda <ojeda@kernel.org> +Signed-off-by: Arnd Bergmann <arnd@arndb.de> +Reviewed-by: Nathan Chancellor <nathan@kernel.org> +Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index cfe400032f96..fe86758acaaa 100644 +--- a/Makefile ++++ b/Makefile +@@ -498,7 +498,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ + -Werror=implicit-function-declaration -Werror=implicit-int \ + -Werror=return-type -Wno-format-security \ +- -std=gnu89 ++ -std=gnu11 + KBUILD_CPPFLAGS := -D__KERNEL__ + KBUILD_AFLAGS_KERNEL := + KBUILD_CFLAGS_KERNEL := +-- +2.37.2 |