diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-06-24 12:04:25 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-19 17:55:40 +0000 |
commit | 05612223ba9bfb08e47b374fc4a81b1e65e5f35e (patch) | |
tree | b4ce3805312d05bae8f7326ec0dae7731542fb1b /Makefile.toolchain | |
parent | fd972cd0bcf2695949f3f6818f249e532e280695 (diff) | |
download | chrome-ec-05612223ba9bfb08e47b374fc4a81b1e65e5f35e.tar.gz |
Makefile: Add option to compile with the C standard library
Add the USE_BUILTIN_STDLIB variable, which defaults to 1 and will use
the EC standard library implementation (the "builtin" directory). When
USE_BUILTIN_STDLIB is set to 0, the toolchain's C standard library will
be used instead.
BRANCH=none
BUG=b:234181908
TEST=./util/compare_build.sh -b all -j 120
=> MATCH
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I63285569205b9c560655dfead6a260c270a92494
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3712035
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Diffstat (limited to 'Makefile.toolchain')
-rw-r--r-- | Makefile.toolchain | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain index 2ce8f2ba5f..fcb2dd4b00 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -23,6 +23,12 @@ ifneq ($(TEST_FUZZ)$(TEST_ASAN)$(TEST_MSAN)$(TEST_UBSAN),) CC=clang endif +# When set to 1, use the subset of the C standard library implemented in EC +# (the "builtin" directory). +# When set to 0, link against the toolchain's implementation of the C standard +# library. +USE_BUILTIN_STDLIB:=1 + # Extract cc-name cc-name:=$(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) @@ -124,8 +130,11 @@ HOST_CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \ $(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(CFLAGS_HOSTTEST) $(LATE_CFLAGS_DEFINE) \ -DSECTION_IS_$(BLD)=$(EMPTY) -DSECTION=$(BLD) $(CPPFLAGS_$(BLD)) ifneq ($(BOARD),host) -CPPFLAGS+=-ffreestanding -fno-builtin -nostdinc -nostdlib -fno-PIC +CPPFLAGS+=-fno-PIC +ifeq ($(USE_BUILTIN_STDLIB), 1) +CPPFLAGS+=-ffreestanding -fno-builtin -nostdinc -nostdlib CPPFLAGS+=-Ibuiltin/ +endif else CPPFLAGS+=-Og endif @@ -139,6 +148,9 @@ CFLAGS+= -ffat-lto-objects CFLAGS+= -fconserve-stack endif CXXFLAGS+=-DPROTOBUF_INLINE_NOT_IN_HEADERS=0 +ifeq ($(USE_BUILTIN_STDLIB), 1) +CPPFLAGS+=-DUSE_BUILTIN_STDLIB +endif ifeq ($(LIBFTDI_NAME),) FTDIVERSION:=$(shell $(PKG_CONFIG) --modversion libftdi1 2>/dev/null) @@ -173,8 +185,13 @@ HOST_CXXFLAGS=$(HOST_CFLAGS) ifneq (${SYSROOT},) LDFLAGS_EXTRA+=--sysroot=${SYSROOT} endif -LDFLAGS=-nostdlib -g -no-pie -Wl,-X -Wl,--gc-sections -Wl,--build-id=none \ +LDFLAGS=-g -no-pie -Wl,-X -Wl,--gc-sections -Wl,--build-id=none \ $(LDFLAGS_EXTRA) $(CFLAGS_CPU) +ifeq ($(USE_BUILTIN_STDLIB), 1) +LDFLAGS+=-nostdlib +else +LDFLAGS+=-lnosys +endif MEMSIZE_FLAGS= ifeq ($(cc-name),gcc) MEMSIZE_FLAGS+=-Wl,--print-memory-usage |