diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-06-14 09:50:26 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-21 18:47:36 +0000 |
commit | fcb67abf10d9505939a9d858d20f3024775fe9f9 (patch) | |
tree | cbe7f2946f1d42198d0bfba6df73c077875e90c3 /Makefile | |
parent | 74047bd2d19977c1cd0579dd60449f92bd21e78d (diff) | |
download | chrome-ec-fcb67abf10d9505939a9d858d20f3024775fe9f9.tar.gz |
Makefile: Make sure CROSS_COMPILE is set correctly
When testing a change to set the default compiler to clang for
dartmonkey, I encountered an error when building with
"make proj-bloonchipper":
ccache: error: execv of /opt/coreboot-sdk/bin/arm-eabi-clang failed: No
such file or directory
In this case the CC variable (defined in Makefile.toolchain as
"CC=$(CCACHE) $(CROSS_COMPILE)$(cc-name))" had CROSS_COMPILE set to
"/opt/coreboot-sdk/bin/arm-eabi-" (gcc toolchain) and cc-name set to
"clang", which is not correct.
The problem was that the Makefile has simply expanded variables
(https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors)
that reference CC before the core/$(CORE)/build.mk is included (e.g.,
"_tsk_lst_ro" that uses CPP, which is defined as "CPP=$(CC) -E").
This change pulls the toolchain configuration out of
core/$(CORE)/build.mk into a separate core/$(CORE)/toolchain.mk file
that is included earlier in the top-level Makefile, which ensures that
CC is defined before it is used by the simply expanded variables.
BRANCH=none
BUG=b:172020503, b:234181908
TEST=make proj-bloonchipper -j
TEST=./util/compare_build.sh -b all -j 120
=> MATCH
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Ia41d2de61ee786df044d484c146d6970de183562
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3706036
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -115,6 +115,14 @@ CFLAGS_BASEBOARD= endif include chip/$(CHIP)/build.mk +# The toolchain must be set before referencing any toolchain-related variables +# (CC, CPP, CXX, etc.) so that the correct toolchain is used. The CORE variable +# is set in the CHIP build file, so this include must come after including the +# CHIP build file. +ifneq ($(BOARD), host) +include core/$(CORE)/toolchain.mk +endif + # Create uppercase config variants, to avoid mixed case constants. # Also translate '-' to '_', so 'cortex-m' turns into 'CORTEX_M'. This must # be done before evaluating config.h. |