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 /core | |
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 'core')
-rw-r--r-- | core/cortex-m/build.mk | 13 | ||||
-rw-r--r-- | core/cortex-m/toolchain.mk | 15 | ||||
-rw-r--r-- | core/cortex-m0/build.mk | 12 | ||||
-rw-r--r-- | core/cortex-m0/toolchain.mk | 15 | ||||
-rw-r--r-- | core/minute-ia/build.mk | 4 | ||||
-rw-r--r-- | core/minute-ia/toolchain.mk | 7 | ||||
-rw-r--r-- | core/nds32/build.mk | 6 | ||||
-rw-r--r-- | core/nds32/toolchain.mk | 9 | ||||
-rw-r--r-- | core/riscv-rv32i/build.mk | 4 | ||||
-rw-r--r-- | core/riscv-rv32i/toolchain.mk | 7 |
10 files changed, 53 insertions, 39 deletions
diff --git a/core/cortex-m/build.mk b/core/cortex-m/build.mk index bcffe16e8d..04f8e45479 100644 --- a/core/cortex-m/build.mk +++ b/core/cortex-m/build.mk @@ -6,19 +6,6 @@ # Cortex-M4 core OS files build # - -ifeq ($(cc-name),gcc) -# coreboot sdk -CROSS_COMPILE_ARM_DEFAULT:=/opt/coreboot-sdk/bin/arm-eabi- -else -# llvm sdk -CROSS_COMPILE_ARM_DEFAULT:=armv7m-cros-eabi- -endif - -$(call set-option,CROSS_COMPILE,\ - $(CROSS_COMPILE_arm),\ - $(CROSS_COMPILE_ARM_DEFAULT)) - # FPU compilation flags CFLAGS_FPU-$(CONFIG_FPU)=-mfloat-abi=hard ifeq ($(cc-name),gcc) diff --git a/core/cortex-m/toolchain.mk b/core/cortex-m/toolchain.mk new file mode 100644 index 0000000000..736d4c7562 --- /dev/null +++ b/core/cortex-m/toolchain.mk @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +ifeq ($(cc-name),gcc) +# coreboot sdk +CROSS_COMPILE_ARM_DEFAULT:=/opt/coreboot-sdk/bin/arm-eabi- +else +# llvm sdk +CROSS_COMPILE_ARM_DEFAULT:=armv7m-cros-eabi- +endif + +$(call set-option,CROSS_COMPILE,\ + $(CROSS_COMPILE_arm),\ + $(CROSS_COMPILE_ARM_DEFAULT)) diff --git a/core/cortex-m0/build.mk b/core/cortex-m0/build.mk index eab2a1eb1c..37ff34873b 100644 --- a/core/cortex-m0/build.mk +++ b/core/cortex-m0/build.mk @@ -6,18 +6,6 @@ # Cortex-M0 core OS files build # -ifeq ($(cc-name),gcc) -# coreboot sdk -CROSS_COMPILE_ARM_DEFAULT:=/opt/coreboot-sdk/bin/arm-eabi- -else -# llvm sdk -CROSS_COMPILE_ARM_DEFAULT:=arm-none-eabi- -endif - -$(call set-option,CROSS_COMPILE,\ - $(CROSS_COMPILE_arm),\ - $(CROSS_COMPILE_ARM_DEFAULT)) - # CPU specific compilation flags CFLAGS_CPU+=-mthumb ifeq ($(cc-name),clang) diff --git a/core/cortex-m0/toolchain.mk b/core/cortex-m0/toolchain.mk new file mode 100644 index 0000000000..390dd6a7f2 --- /dev/null +++ b/core/cortex-m0/toolchain.mk @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +ifeq ($(cc-name),gcc) +# coreboot sdk +CROSS_COMPILE_ARM_DEFAULT:=/opt/coreboot-sdk/bin/arm-eabi- +else +# llvm sdk +CROSS_COMPILE_ARM_DEFAULT:=arm-none-eabi- +endif + +$(call set-option,CROSS_COMPILE,\ + $(CROSS_COMPILE_arm),\ + $(CROSS_COMPILE_ARM_DEFAULT)) diff --git a/core/minute-ia/build.mk b/core/minute-ia/build.mk index b51512c16e..b32f8164ea 100644 --- a/core/minute-ia/build.mk +++ b/core/minute-ia/build.mk @@ -6,10 +6,6 @@ # Minute-IA core build # -# Select Minute-IA bare-metal toolchain -$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_i386),\ - /opt/coreboot-sdk/bin/i386-elf-) - # FPU compilation flags CFLAGS_FPU-$(CONFIG_FPU)= diff --git a/core/minute-ia/toolchain.mk b/core/minute-ia/toolchain.mk new file mode 100644 index 0000000000..8fcfc28c78 --- /dev/null +++ b/core/minute-ia/toolchain.mk @@ -0,0 +1,7 @@ +# Copyright 2022 The ChromiumOS Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Select Minute-IA bare-metal toolchain +$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_i386),\ + /opt/coreboot-sdk/bin/i386-elf-) diff --git a/core/nds32/build.mk b/core/nds32/build.mk index ddd65c680b..e500846c44 100644 --- a/core/nds32/build.mk +++ b/core/nds32/build.mk @@ -6,12 +6,6 @@ # Andestar v3m architecture core OS files build # -# Set coreboot-sdk as the default toolchain for nds32 -NDS32_DEFAULT_COMPILE=/opt/coreboot-sdk/bin/nds32le-elf- - -# Select Andes bare-metal toolchain -$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_nds32),$(NDS32_DEFAULT_COMPILE)) - # CPU specific compilation flags CFLAGS_CPU+=-march=v3m -Os LDFLAGS_EXTRA+=-mrelax diff --git a/core/nds32/toolchain.mk b/core/nds32/toolchain.mk new file mode 100644 index 0000000000..3d685ef2b6 --- /dev/null +++ b/core/nds32/toolchain.mk @@ -0,0 +1,9 @@ +# Copyright 2022 The ChromiumOS Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Set coreboot-sdk as the default toolchain for nds32 +NDS32_DEFAULT_COMPILE=/opt/coreboot-sdk/bin/nds32le-elf- + +# Select Andes bare-metal toolchain +$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_nds32),$(NDS32_DEFAULT_COMPILE)) diff --git a/core/riscv-rv32i/build.mk b/core/riscv-rv32i/build.mk index 7e5ce0e8a7..f558a91669 100644 --- a/core/riscv-rv32i/build.mk +++ b/core/riscv-rv32i/build.mk @@ -6,10 +6,6 @@ # RISC-V core OS files build # -# Select RISC-V bare-metal toolchain -$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_riscv),\ - /opt/coreboot-sdk/bin/riscv64-elf-) - # Enable FPU extension if config option of FPU is enabled. _FPU_EXTENSION=$(if $(CONFIG_FPU),f,) # Enable the 'M' extension if config option of RISCV_EXTENSION_M is enabled. diff --git a/core/riscv-rv32i/toolchain.mk b/core/riscv-rv32i/toolchain.mk new file mode 100644 index 0000000000..dd45daf120 --- /dev/null +++ b/core/riscv-rv32i/toolchain.mk @@ -0,0 +1,7 @@ +# Copyright 2022 The ChromiumOS Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Select RISC-V bare-metal toolchain +$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_riscv),\ + /opt/coreboot-sdk/bin/riscv64-elf-) |