2013-10-19 21:37:09 +00:00
|
|
|
From: Ben Hutchings <ben@decadent.org.uk>
|
|
|
|
Date: Sat, 19 Oct 2013 19:43:35 +0100
|
|
|
|
Subject: kbuild: Use -nostdinc in compile tests
|
2014-03-15 15:45:47 +00:00
|
|
|
Bug-Debian: https://bugs.debian.org/726861
|
|
|
|
Bug-Debian: https://bugs.debian.org/717557
|
2014-11-06 03:56:25 +00:00
|
|
|
Forwarded: http://mid.gmane.org/1415235534.3398.35.camel@decadent.org.uk
|
2013-10-19 21:37:09 +00:00
|
|
|
|
|
|
|
Debian's gcc 4.8 pre-includes <stdc-predef.h> by default, which in
|
|
|
|
turn includes <bits/predefs.h>. This fails when building a 64-bit
|
|
|
|
kernel and only 32-bit C library headers installed.
|
|
|
|
|
|
|
|
The -nostdinc option disables this, though it isn't explicitly
|
|
|
|
documented. This option is already used when actually building
|
|
|
|
the kernel.
|
|
|
|
|
|
|
|
--- a/scripts/Kbuild.include
|
|
|
|
+++ b/scripts/Kbuild.include
|
2014-09-13 06:23:27 +00:00
|
|
|
@@ -111,12 +111,12 @@ as-instr = $(call try-run,\
|
2013-10-19 21:37:09 +00:00
|
|
|
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
|
|
|
|
|
|
|
|
cc-option = $(call try-run,\
|
|
|
|
- $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
|
|
|
|
+ $(CC) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(KBUILD_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) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
|
|
|
|
+ $(CC) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
|
|
|
|
|
|
|
|
# cc-option-align
|
|
|
|
# Prefix align with either -falign or -malign
|
2014-09-13 06:23:27 +00:00
|
|
|
@@ -126,16 +126,17 @@ cc-option-align = $(subst -functions=0,,
|
2013-10-19 21:37:09 +00:00
|
|
|
# cc-disable-warning
|
|
|
|
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
|
|
|
|
cc-disable-warning = $(call try-run,\
|
|
|
|
- $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
|
|
|
|
+ $(CC) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
|
|
|
|
|
|
|
|
# cc-version
|
|
|
|
# Usage gcc-ver := $(call 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
|
|
|
|
# Usage gcc-ver := $(call 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)
|
2014-09-13 06:23:27 +00:00
|
|
|
@@ -149,7 +150,7 @@ cc-ldoption = $(call try-run,\
|
2013-10-19 21:37:09 +00:00
|
|
|
# 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)
|
|
|
|
--- a/Makefile
|
|
|
|
+++ b/Makefile
|
2014-09-13 06:23:27 +00:00
|
|
|
@@ -624,6 +624,8 @@ else
|
2013-10-19 21:37:09 +00:00
|
|
|
KBUILD_CFLAGS += -O2
|
|
|
|
endif
|
|
|
|
|
|
|
|
+NOSTDINC_FLAGS += -nostdinc
|
|
|
|
+
|
2014-09-13 06:23:27 +00:00
|
|
|
# Tell gcc to never replace conditional load with a non-conditional one
|
|
|
|
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
|
|
|
|
|
|
|
|
@@ -750,7 +752,7 @@ KBUILD_CFLAGS += $(call cc-option, -fno-
|
2013-10-19 21:37:09 +00:00
|
|
|
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
|