Skip to content

Commit 50560ce

Browse files
committed
Merge tag 'kbuild-gnu11-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild update for C11 language base from Masahiro Yamada: "Kbuild -std=gnu11 updates for v5.18 Linus pointed out the benefits of C99 some years ago, especially variable declarations in loops [1]. At that time, we were not ready for the migration due to old compilers. Recently, Jakob Koschel reported a bug in list_for_each_entry(), which leaks the invalid pointer out of the loop [2]. In the discussion, we agreed that the time had come. Now that GCC 5.1 is the minimum compiler version, there is nothing to prevent us from going to -std=gnu99, or even straight to -std=gnu11. Discussions for a better list iterator implementation are ongoing, but this patch set must land first" [1] https://lore.kernel.org/all/CAHk-=wgr12JkKmRd21qh-se-_Gs69kbPgR9x4C+Es-yJV2GLkA@mail.gmail.com/ [2] https://lore.kernel.org/lkml/[email protected]/ * tag 'kbuild-gnu11-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: Kbuild: use -std=gnu11 for KBUILD_USERCFLAGS Kbuild: move to -std=gnu11 Kbuild: use -Wdeclaration-after-statement Kbuild: add -Wno-shift-negative-value where -Wextra is used
2 parents 29c8c18 + 1e24078 commit 50560ce

File tree

11 files changed

+21
-15
lines changed

11 files changed

+21
-15
lines changed

Documentation/process/programming-language.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Programming Language
55

66
The kernel is written in the C programming language [c-language]_.
77
More precisely, the kernel is typically compiled with ``gcc`` [gcc]_
8-
under ``-std=gnu89`` [gcc-c-dialect-options]_: the GNU dialect of ISO C90
9-
(including some C99 features). ``clang`` [clang]_ is also supported, see
10-
docs on :ref:`Building Linux with Clang/LLVM <kbuild_llvm>`.
8+
under ``-std=gnu11`` [gcc-c-dialect-options]_: the GNU dialect of ISO C11.
9+
``clang`` [clang]_ is also supported, see docs on
10+
:ref:`Building Linux with Clang/LLVM <kbuild_llvm>`.
1111

1212
This dialect contains many extensions to the language [gnu-extensions]_,
1313
and many of them are used within the kernel as a matter of course.

Documentation/translations/it_IT/process/programming-language.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Linguaggio di programmazione
1010

1111
Il kernel è scritto nel linguaggio di programmazione C [it-c-language]_.
1212
Più precisamente, il kernel viene compilato con ``gcc`` [it-gcc]_ usando
13-
l'opzione ``-std=gnu89`` [it-gcc-c-dialect-options]_: il dialetto GNU
14-
dello standard ISO C90 (con l'aggiunta di alcune funzionalità da C99).
13+
l'opzione ``-std=gnu11`` [it-gcc-c-dialect-options]_: il dialetto GNU
14+
dello standard ISO C11.
1515
Linux supporta anche ``clang`` [it-clang]_, leggete la documentazione
1616
:ref:`Building Linux with Clang/LLVM <kbuild_llvm>`.
1717

Documentation/translations/zh_CN/process/programming-language.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
============
1010

1111
内核是用C语言 :ref:`c-language <cn_c-language>` 编写的。更准确地说,内核通常是用 :ref:`gcc <cn_gcc>`
12-
在 ``-std=gnu89`` :ref:`gcc-c-dialect-options <cn_gcc-c-dialect-options>` 下编译的:ISO C90的 GNU 方言(
13-
包括一些C99特性)
12+
在 ``-std=gnu11`` :ref:`gcc-c-dialect-options <cn_gcc-c-dialect-options>` 下编译的:ISO C11的 GNU 方言
1413

1514
这种方言包含对语言 :ref:`gnu-extensions <cn_gnu-extensions>` 的许多扩展,当然,它们许多都在内核中使用。
1615

Documentation/translations/zh_TW/process/programming-language.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
============
1313

1414
內核是用C語言 :ref:`c-language <tw_c-language>` 編寫的。更準確地說,內核通常是用 :ref:`gcc <tw_gcc>`
15-
在 ``-std=gnu89`` :ref:`gcc-c-dialect-options <tw_gcc-c-dialect-options>` 下編譯的:ISO C90的 GNU 方言(
16-
包括一些C99特性)
15+
在 ``-std=gnu11`` :ref:`gcc-c-dialect-options <tw_gcc-c-dialect-options>` 下編譯的:ISO C11的 GNU 方言
1716

1817
這種方言包含對語言 :ref:`gnu-extensions <tw_gnu-extensions>` 的許多擴展,當然,它們許多都在內核中使用。
1918

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ HOSTCXX = g++
432432
endif
433433

434434
export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
435-
-O2 -fomit-frame-pointer -std=gnu89
435+
-O2 -fomit-frame-pointer -std=gnu11 \
436+
-Wdeclaration-after-statement
436437
export KBUILD_USERLDFLAGS :=
437438

438439
KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
@@ -515,7 +516,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
515516
-fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
516517
-Werror=implicit-function-declaration -Werror=implicit-int \
517518
-Werror=return-type -Wno-format-security \
518-
-std=gnu89
519+
-std=gnu11
519520
KBUILD_CPPFLAGS := -D__KERNEL__
520521
KBUILD_AFLAGS_KERNEL :=
521522
KBUILD_CFLAGS_KERNEL :=
@@ -782,7 +783,7 @@ KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
782783

783784
ifdef CONFIG_CC_IS_CLANG
784785
KBUILD_CPPFLAGS += -Qunused-arguments
785-
# The kernel builds with '-std=gnu89' so use of GNU extensions is acceptable.
786+
# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
786787
KBUILD_CFLAGS += -Wno-gnu
787788
# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
788789
# source of a reference will be _MergedGlobals and not on of the whitelisted names.

arch/arm64/kernel/vdso32/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
6868
-fno-strict-aliasing -fno-common \
6969
-Werror-implicit-function-declaration \
7070
-Wno-format-security \
71-
-std=gnu89
71+
-Wdeclaration-after-statement \
72+
-std=gnu11
7273
VDSO_CFLAGS += -O2
7374
# Some useful compiler-dependent flags from top-level Makefile
7475
VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,)

drivers/gpu/drm/i915/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ subdir-ccflags-y += -Wno-unused-parameter
1818
subdir-ccflags-y += -Wno-type-limits
1919
subdir-ccflags-y += -Wno-missing-field-initializers
2020
subdir-ccflags-y += -Wno-sign-compare
21+
subdir-ccflags-y += -Wno-shift-negative-value
2122
subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
2223
subdir-ccflags-y += $(call cc-disable-warning, frame-address)
2324
subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror

drivers/staging/greybus/tools/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ CFLAGS += -std=gnu99 -Wall -Wextra -g \
1212
-Wredundant-decls \
1313
-Wcast-align \
1414
-Wsign-compare \
15-
-Wno-missing-field-initializers
15+
-Wno-missing-field-initializers \
16+
-Wno-shift-negative-value
1617

1718
CC := $(CROSS_COMPILE)gcc
1819

fs/btrfs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ subdir-ccflags-y += $(condflags)
1717
subdir-ccflags-y += -Wno-missing-field-initializers
1818
subdir-ccflags-y += -Wno-sign-compare
1919
subdir-ccflags-y += -Wno-type-limits
20+
subdir-ccflags-y += -Wno-shift-negative-value
2021

2122
obj-$(CONFIG_BTRFS_FS) := btrfs.o
2223

scripts/Makefile.extrawarn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
3636
KBUILD_CFLAGS += -Wno-missing-field-initializers
3737
KBUILD_CFLAGS += -Wno-sign-compare
3838
KBUILD_CFLAGS += -Wno-type-limits
39+
KBUILD_CFLAGS += -Wno-shift-negative-value
3940

4041
KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
4142

0 commit comments

Comments
 (0)