summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--core/cortex-m/build.mk13
-rw-r--r--core/cortex-m/toolchain.mk15
-rw-r--r--core/cortex-m0/build.mk12
-rw-r--r--core/cortex-m0/toolchain.mk15
-rw-r--r--core/minute-ia/build.mk4
-rw-r--r--core/minute-ia/toolchain.mk7
-rw-r--r--core/nds32/build.mk6
-rw-r--r--core/nds32/toolchain.mk9
-rw-r--r--core/riscv-rv32i/build.mk4
-rw-r--r--core/riscv-rv32i/toolchain.mk7
11 files changed, 61 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index 3a36b91125..0602fd4abf 100644
--- a/Makefile
+++ b/Makefile
@@ -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.
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-)