summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-09-30 23:19:40 +0000
committerCommit Bot <commit-bot@chromium.org>2021-10-29 22:33:11 +0000
commit85839a2c40377397bc5d23d12bc3b86bb9d5e137 (patch)
treefa6e13157073b84f27ffae1c2f722ad99006e3e7
parent061ce16de9ad7a57cff270ac82d55c3e0137e544 (diff)
downloadchrome-ec-85839a2c40377397bc5d23d12bc3b86bb9d5e137.tar.gz
core/cortex-m[0]: Enable "-Oz" when using clang
"-Oz" is like "-Os" (and thus "-O2"), but reduces code size further. dartmonkey, clang, -Os: RO: 733500 flash remaining RW: 979488 flash remaining dartmonkey, clang, -Oz: RO: 737980 flash remaining RW: 984776 flash remaining BRANCH=none BUG=b:172020503 TEST=make buildall TEST=CC=clang make BOARD=dartmonkey Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ia787845ffdeff26134162007a621b902bbc0d051 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3199737 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--core/cortex-m/build.mk4
-rw-r--r--core/cortex-m0/build.mk7
2 files changed, 8 insertions, 3 deletions
diff --git a/core/cortex-m/build.mk b/core/cortex-m/build.mk
index be41a12b9e..23a197af88 100644
--- a/core/cortex-m/build.mk
+++ b/core/cortex-m/build.mk
@@ -15,11 +15,13 @@ $(call set-option,CROSS_COMPILE,\
CFLAGS_FPU-$(CONFIG_FPU)=-mfpu=fpv4-sp-d16 -mfloat-abi=hard
# CPU specific compilation flags
-CFLAGS_CPU+=-mthumb -Os
+CFLAGS_CPU+=-mthumb
ifeq ($(cc-name),clang)
+CFLAGS_CPU+=-Oz # Like -Os (and thus -O2), but reduces code size further.
# Link compiler-rt when using clang, so clang finds the builtins it provides.
LDFLAGS_EXTRA+=-lclang_rt.builtins-arm
else
+CFLAGS_CPU+=-Os
CFLAGS_CPU+=-mno-sched-prolog
endif
CFLAGS_CPU+=-mno-unaligned-access
diff --git a/core/cortex-m0/build.mk b/core/cortex-m0/build.mk
index 44093b93ff..40764f53c6 100644
--- a/core/cortex-m0/build.mk
+++ b/core/cortex-m0/build.mk
@@ -12,8 +12,11 @@ $(call set-option,CROSS_COMPILE,\
/opt/coreboot-sdk/bin/arm-eabi-)
# CPU specific compilation flags
-CFLAGS_CPU+=-mthumb -Os
-ifneq ($(cc-name),clang)
+CFLAGS_CPU+=-mthumb
+ifeq ($(cc-name),clang)
+CFLAGS_CPU+=-Oz # Like -Os (and thus -O2), but reduces code size further.
+else
+CFLAGS_CPU+=-Os
CFLAGS_CPU+=-mno-sched-prolog
endif
CFLAGS_CPU+=-mno-unaligned-access