summaryrefslogtreecommitdiff
path: root/Makefile.toolchain
diff options
context:
space:
mode:
authorStefan Reinauer <stefan.reinauer@coreboot.org>2016-01-20 18:36:20 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-02-03 15:00:50 -0800
commitbc404c94b4ab1e6a62e607fd7ef034aa31d6388e (patch)
tree559e85fa8eca3ee7156f9f5333707755c43905c6 /Makefile.toolchain
parentfc9ed52397f232bfc9f9d2b448e8bc253c87379f (diff)
downloadchrome-ec-bc404c94b4ab1e6a62e607fd7ef034aa31d6388e.tar.gz
Enforce compilation without system headers
This patch introduces HOST_CPPFLAGS to be used for all objects being compiled with HOSTCC rather then the target compiler. Since glibc is not linked into the EC, no glibc include files should be included in the EC code base. Hence, create local definitions for clock_t and wchar_t that match what the glibc include would have done, and remove some unneeded includes. Due to very eager optimization, we have to give gcc a little notch to not kick out memset. Signed-off-by: Stefan Reinauer <reinauer@chromium.org> BUG=chrome-os-partner:43025 BUG=chrome-os-partner:49517 BRANCH=none TEST=compile tested Change-Id: Idf3a2881fa8352756b0927b09c6a97473358f239 Reviewed-on: https://chromium-review.googlesource.com/322435 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Diffstat (limited to 'Makefile.toolchain')
-rw-r--r--Makefile.toolchain14
1 files changed, 12 insertions, 2 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain
index a204df9e25..c4531ded3f 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -44,6 +44,16 @@ CFLAGS_DEFINE=-DOUTDIR=$(out)/$(BLD) -DCHIP=$(CHIP) -DBOARD_TASKFILE=$(_tsk_lst_
CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \
$(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(LATE_CFLAGS_DEFINE) \
-DSECTION_IS_$(BLD) -DSECTION=$(BLD)
+BUILD_CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \
+ $(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(LATE_CFLAGS_DEFINE) \
+ -DSECTION_IS_$(BLD) -DSECTION=$(BLD)
+HOST_CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \
+ $(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(LATE_CFLAGS_DEFINE) \
+ -DSECTION_IS_$(BLD) -DSECTION=$(BLD)
+ifneq ($(BOARD),host)
+CPPFLAGS+=-ffreestanding -fno-builtin -nostdinc -nostdlib
+CPPFLAGS+=-Ibuiltin/
+endif
CFLAGS=$(CPPFLAGS) $(CFLAGS_CPU) $(CFLAGS_DEBUG) $(CFLAGS_WARN) $(CFLAGS_y)
CFLAGS+= -ffunction-sections -fshort-wchar
CFLAGS+= -fno-delete-null-pointer-checks -fconserve-stack
@@ -58,8 +68,8 @@ endif
LIBFTDI_CFLAGS=$(shell $(PKG_CONFIG) --cflags lib${LIBFTDI_NAME})
LIBFTDI_LDLIBS=$(shell $(PKG_CONFIG) --libs lib${LIBFTDI_NAME})
-BUILD_CFLAGS= $(LIBFTDI_CFLAGS) $(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN)
-HOST_CFLAGS=$(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) -DHOST_TOOLS_BUILD
+BUILD_CFLAGS= $(LIBFTDI_CFLAGS) $(BUILD_CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN)
+HOST_CFLAGS=$(HOST_CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) -DHOST_TOOLS_BUILD
LDFLAGS=-nostdlib -Wl,-X -Wl,--gc-sections -Wl,--build-id=none $(LDFLAGS_EXTRA)
BUILD_LDFLAGS=$(LIBFTDI_LDLIBS)
HOST_TEST_LDFLAGS=-T core/host/host_exe.lds -lrt -pthread -rdynamic -lm\