From: Ben Hutchings Date: Sat, 19 Oct 2013 18:43:35 +0000 (+0100) Subject: kbuild: Use -nostdinc in compile tests X-Git-Tag: archive/raspbian/4.9.82-1+deb9u3+rpi1_jessie~8^2~61 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fd96745614eaa402ffd286e10818b90f12c020d4;p=linux-4.9.git kbuild: Use -nostdinc in compile tests gcc 4.8 and later include by default. In some versions of eglibc that includes , but that may be missing when building with a biarch compiler. Also itself could be missing as we are only trying to build a kernel, not userland. The -nostdinc option disables this, though it isn't explicitly documented. This option is already used when actually building the kernel, but not by cc-option and other tests. This can result in silently miscompiling the kernel. References: https://bugs.debian.org/717557 References: https://bugs.debian.org/726861 Signed-off-by: Ben Hutchings Gbp-Pq: Topic bugfix/all Gbp-Pq: Name kbuild-use-nostdinc-in-compile-tests.patch --- diff --git a/Makefile b/Makefile index a8834475a0d6..8c8cbe2a2af2 100644 --- a/Makefile +++ b/Makefile @@ -655,6 +655,8 @@ endif KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ $(call cc-disable-warning,maybe-uninitialized,)) +NOSTDINC_FLAGS += -nostdinc + # Tell gcc to never replace conditional load with a non-conditional one KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) @@ -779,7 +781,7 @@ KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) endif # arch Makefile may override CC so keep this after arch Makefile is included -NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +NOSTDINC_FLAGS += -isystem $(shell $(CC) -print-file-name=include) CHECKFLAGS += $(NOSTDINC_FLAGS) # warn about C99 declaration after statement diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 179219845dfc..e9c8ecea1b5a 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -116,12 +116,12 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) cc-option = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) + $(CC) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + $(CC) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) # cc-option-align # Prefix align with either -falign or -malign @@ -131,18 +131,19 @@ cc-option-align = $(subst -functions=0,,\ # cc-disable-warning # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) cc-disable-warning = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) + $(CC) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) # cc-name # Expands to either gcc or clang cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) # cc-version -cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) +cc-version = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/gcc-version.sh $(CC) $(NOSTDINC_FLAGS)) # cc-fullversion cc-fullversion = $(shell $(CONFIG_SHELL) \ - $(srctree)/scripts/gcc-version.sh -p $(CC)) + $(srctree)/scripts/gcc-version.sh -p $(CC) $(NOSTDINC_FLAGS)) # cc-ifversion # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) @@ -156,7 +157,7 @@ cc-ldoption = $(call try-run,\ # ld-option # Usage: LDFLAGS += $(call ld-option, -X) ld-option = $(call try-run,\ - $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) + $(CC) $(NOSTDINC_FLAGS) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) # ar-option # Usage: KBUILD_ARFLAGS := $(call ar-option,D)