Skip to content

Commit 51b97e3

Browse files
kiryltorvalds
authored andcommitted
kernel: use the gnu89 standard explicitly
Sasha Levin reports: "gcc5 changes the default standard to c11, which makes kernel build unhappy Explicitly define the kernel standard to be gnu89 which should keep everything working exactly like it was before gcc5" There are multiple small issues with the new default, but the biggest issue seems to be that the old - and very useful - GNU extension to allow a cast in front of an initializer has gone away. Patch updated by Kirill: "I'm pretty sure all gcc versions you can build kernel with supports -std=gnu89. cc-option is redunrant. We also need to adjust HOSTCFLAGS otherwise allmodconfig fails for me" Note by Andrew Pinski: "Yes it was reported and both problems relating to this extension has been added to gnu99 and gnu11. Though there are other issues with the kernel dealing with extern inline have different semantics between gnu89 and gnu99/11" End result: we may be able to move up to a newer stdc model eventually, but right now the newer models have some annoying deficiencies, so the traditional "gnu89" model ends up being the preferred one. Signed-off-by: Sasha Levin <[email protected]> Singed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1afcb6e commit 51b97e3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
297297

298298
HOSTCC = gcc
299299
HOSTCXX = g++
300-
HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
300+
HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
301301
HOSTCXXFLAGS = -O2
302302

303303
ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
@@ -401,7 +401,8 @@ KBUILD_CPPFLAGS := -D__KERNEL__
401401
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
402402
-fno-strict-aliasing -fno-common \
403403
-Werror-implicit-function-declaration \
404-
-Wno-format-security
404+
-Wno-format-security \
405+
-std=gnu89
405406

406407
KBUILD_AFLAGS_KERNEL :=
407408
KBUILD_CFLAGS_KERNEL :=

0 commit comments

Comments
 (0)