From 85839a2c40377397bc5d23d12bc3b86bb9d5e137 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 30 Sep 2021 23:19:40 +0000 Subject: 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 Change-Id: Ia787845ffdeff26134162007a621b902bbc0d051 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3199737 Reviewed-by: Daisuke Nojiri --- core/cortex-m/build.mk | 4 +++- core/cortex-m0/build.mk | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'core') 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 -- cgit v1.2.1