Allow core code to request its cross compiler

Instead of having to pass in both the board and the arch used there
(which might be complicated in the light of different ECs with different
arches), allow passing in the board and a set of cross compilers.

The core/*/build.mk then pick the compiler that is responsible for them.
The current method works just the same: If you've already set
CROSS_COMPILE, no override happens. If you set neither CROSS_COMPILE nor
CROSS_COMPILE_$arch, the same default as before this CL is set.

BUG=none
BRANCH=none
TEST=emerge-{samus,kevin} chromeos-ec behave reasonably with adapted
ebuild

Change-Id: Icf1866f296412dd92ecfe134394224c49f7c3df5
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/549344
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@google.com>
(cherry picked from commit 1a67ac2ad6)
Reviewed-on: https://chromium-review.googlesource.com/598516
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
This commit is contained in:
Patrick Georgi 2017-06-27 15:26:58 +02:00 committed by ChromeOS Commit Bot
parent 44b64f9b39
commit a71c1e41fa
6 changed files with 24 additions and 15 deletions

View File

@ -446,19 +446,22 @@ endif
help:
@echo "Google Chromium EC build"
@echo "Common Targets:"
@echo " all [BOARD=] - Build a single board (Default target)"
@echo " clean [BOARD=] - Clean a single board"
@echo " buildall - Build and test all boards"
@echo " clobber - Clean all boards"
@echo " proj-<boardname> - Build a single board (similar to 'all BOARD=boardname')"
@echo " savesizes - Save the filesizes of currently built boards for comparison"
@echo " newsizes - Compare previously saved filesizes against new sizes"
@echo " all [BOARD=] - Build a single board (Default target)"
@echo " clean [BOARD=] - Clean a single board"
@echo " buildall - Build and test all boards"
@echo " clobber - Clean all boards"
@echo " proj-<boardname> - Build a single board (similar to 'all BOARD=boardname')"
@echo " savesizes - Save the filesizes of currently built boards for comparison"
@echo " newsizes - Compare previously saved filesizes against new sizes"
@echo "Common Variables:"
@echo " BOARD= - Set the board name to build (Default is $(BOARD))"
@echo " CROSS_COMPILE= - Set the compiler for the board"
@echo " V=1 - Show make output"
@echo " V=1 - Show make output"
@echo " BOARD= - Set the board name to build (Default is $(BOARD))"
@echo " CROSS_COMPILE= - Set the compiler for the board"
@echo " CROSS_COMPILE_arch= - Set the compiler for arch"
@echo " The board picks its CROSS_COMPILE_arch if CROSS_COMPILE is not set."
@echo " arch may be one of 'arm', 'i386', 'nds32'."
@echo "Example:"
@echo " make BOARD=reef CROSS_COMPILE='arm-eabi-'"
@echo " make BOARD=reef CROSS_COMPILE_arm='arm-eabi-'"
.PHONY: savesizes
savesizes:

View File

@ -89,3 +89,9 @@ LDFLAGS=-nostdlib -Wl,-X -Wl,--gc-sections -Wl,--build-id=none $(LDFLAGS_EXTRA)
BUILD_LDFLAGS=$(LIBFTDI_LDLIBS)
HOST_TEST_LDFLAGS=-T core/host/host_exe.lds -lrt -pthread -rdynamic -lm\
$(if $(TEST_COVERAGE),-fprofile-arcs,)
# utility function to provide overridable defaults
# $1: name of variable to set
# $2: first default to use
# $3: second default to use
set-option = $(eval $1?=$$(if $(2),$(2),$(3)))

View File

@ -7,7 +7,7 @@
#
# Select ARMv7-m bare-metal toolchain
CROSS_COMPILE?=arm-none-eabi-
$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_arm),arm-none-eabi-)
# FPU compilation flags
CFLAGS_FPU-$(CONFIG_FPU)=-mfpu=fpv4-sp-d16 -mfloat-abi=hard

View File

@ -7,7 +7,7 @@
#
# Select ARMv6-m compatible bare-metal toolchain
CROSS_COMPILE?=arm-none-eabi-
$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_arm),arm-none-eabi-)
# CPU specific compilation flags
CFLAGS_CPU+=-mthumb -Os -mno-sched-prolog

View File

@ -7,7 +7,7 @@
#
# Select Minute-IA bare-metal toolchain
CROSS_COMPILE=i686-pc-linux-gnu-
$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_i386),i686-pc-linux-gnu-)
# FPU compilation flags
CFLAGS_FPU-$(CONFIG_FPU)=

View File

@ -7,7 +7,7 @@
#
# Select Andes bare-metal toolchain
CROSS_COMPILE?=nds32le-cros-elf-
$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_nds32),nds32le-cros-elf-)
# CPU specific compilation flags
CFLAGS_CPU+=-march=v3m -Os