summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-09-28 00:12:34 +0000
committerCommit Bot <commit-bot@chromium.org>2021-11-03 22:59:52 +0000
commitd6271635b6a8cdc875626433cef4faed4d068fcc (patch)
tree8a36472490525ce3b92a9bbc02f3e1a1f6294482
parent37493c0d4726d658902f41dbd521f30323b025ba (diff)
downloadchrome-ec-d6271635b6a8cdc875626433cef4faed4d068fcc.tar.gz
core/cortex-m0: Use builtins from compiler-rt when using clang
When compiling with clang, use the builtins from compiler-rt rather than our own hand-rolled versions. When trying to compile with our versions, clang fails to link: ld.lld: error: core/cortex-m0/div.S:52:(.text.__aeabi_idiv+0x10): unrecognized relocation R_ARM_THM_JUMP8 ld.lld: error: core/cortex-m0/div.S:97:(.text.__aeabi_idivmod+0x24): unrecognized relocation R_ARM_THM_JUMP8 BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=servo_v4 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I33db397c13bcdcb63bd931d0d8425f9f02a76327 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3188640 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--core/cortex-m0/build.mk15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/cortex-m0/build.mk b/core/cortex-m0/build.mk
index 40764f53c6..8d2002bad5 100644
--- a/core/cortex-m0/build.mk
+++ b/core/cortex-m0/build.mk
@@ -15,6 +15,8 @@ $(call set-option,CROSS_COMPILE,\
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
@@ -26,8 +28,17 @@ CFLAGS_CPU+=-flto
LDFLAGS_EXTRA+=-flto
endif
-core-y=cpu.o debug.o init.o thumb_case.o div.o lmul.o ldivmod.o mula.o uldivmod.o
-core-y+=vecttable.o __builtin.o
+core-y=cpu.o debug.o init.o thumb_case.o mula.o
+# When using clang, we get these as builtins from compiler-rt.
+ifneq ($(cc-name),clang)
+core-y+=div.o lmul.o ldivmod.o uldivmod.o
+endif
+
+core-y+=vecttable.o
+# When using clang, we get these as builtins from compiler-rt.
+ifneq ($(cc-name),clang)
+core-y+=__builtin.o
+endif
core-$(CONFIG_COMMON_PANIC_OUTPUT)+=panic.o
core-$(CONFIG_COMMON_RUNTIME)+=switch.o task.o