diff options
Diffstat (limited to 'debian/patches/bugfix/all/kbuild-use-nostdinc-in-compile-tests.patch')
-rw-r--r-- | debian/patches/bugfix/all/kbuild-use-nostdinc-in-compile-tests.patch | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/debian/patches/bugfix/all/kbuild-use-nostdinc-in-compile-tests.patch b/debian/patches/bugfix/all/kbuild-use-nostdinc-in-compile-tests.patch new file mode 100644 index 000000000..61a4628a4 --- /dev/null +++ b/debian/patches/bugfix/all/kbuild-use-nostdinc-in-compile-tests.patch @@ -0,0 +1,91 @@ +From: Ben Hutchings <ben@decadent.org.uk> +Date: Sat, 19 Oct 2013 19:43:35 +0100 +Subject: kbuild: Use -nostdinc in compile tests +Bug-Debian: https://bugs.debian.org/726861 +Bug-Debian: https://bugs.debian.org/717557 +Forwarded: https://marc.info/?l=linux-kbuild&m=141523555023625 + +gcc 4.8 and later include <stdc-predef.h> by default. In some +versions of eglibc that includes <bits/predefs.h>, but that may be +missing when building with a biarch compiler. Also <stdc-predef.h> +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 <ben@decadent.org.uk> +--- +--- a/scripts/Kbuild.include ++++ b/scripts/Kbuild.include +@@ -121,7 +121,7 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PL + # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) + + cc-option = $(call __cc-option, $(CC),\ +- $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) ++ $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) + + # hostcc-option + # Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586) +@@ -131,23 +131,24 @@ hostcc-option = $(call __cc-option, $(HO + # cc-option-yn + # Usage: flag := $(call cc-option-yn,-march=winchip-c6) + cc-option-yn = $(call try-run,\ +- $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) ++ $(CC) -Werror $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + + # cc-disable-warning + # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) + cc-disable-warning = $(call try-run,\ +- $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) ++ $(CC) -Werror $(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-ifversion = $(shell [ $(cc-version) $ + # cc-ldoption + # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) + cc-ldoption = $(call try-run,\ +- $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) ++ $(CC) $(1) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) + + # ld-option + # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) +--- a/Makefile ++++ b/Makefile +@@ -661,6 +661,8 @@ else + KBUILD_CFLAGS += -O2 + endif + ++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) + KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races) +@@ -781,7 +783,7 @@ LDFLAGS_vmlinux += --gc-sections + 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) + + # warn about C99 declaration after statement + KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) |