From f9e3ebc75dfcae47bdc7a6e28affb34d00166783 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 13 Sep 2022 13:41:47 -0700 Subject: Makefile: Set prefixed toolchain for host When building with portage, the build fails if we use the "unprefixed" compiler (e.g., "g++"). Explicitly use the prefixed compiler when building for the host. BRANCH=none BUG=b:246424843 TEST=emerge-hatch chromeos-ec Force-Relevant-Builds: all Signed-off-by: Tom Hughes Change-Id: I50d2b437374bf6857b19151edb5eaea24a7330c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3894407 Reviewed-by: Eric Yilun Lin --- Makefile | 2 -- Makefile.rules | 2 +- core/host/toolchain.mk | 9 +++++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 core/host/toolchain.mk diff --git a/Makefile b/Makefile index cd2af16ea5..5dc693c793 100644 --- a/Makefile +++ b/Makefile @@ -119,9 +119,7 @@ include chip/$(CHIP)/build.mk # (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 diff --git a/Makefile.rules b/Makefile.rules index 05a0ae4e45..12418e5be1 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -116,7 +116,7 @@ cmd_cxx_to_host = $(HOSTCXX) -std=gnu++17 $(HOST_CXXFLAGS) \ $(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.cc)) $(wildcard $*.cc)) $(HOST_LDFLAGS) cmd_o_to_a = $(AR) rcs $@ $^ cmd_host_test = $(MAKE) BOARD=host PROJECT=$* \ - V=$(V) out=build/host/$* TEST_BUILD=y EMU_BUILD=y CROSS_COMPILE= \ + V=$(V) out=build/host/$* TEST_BUILD=y EMU_BUILD=y \ $(if $(TEST_SCRIPT),TEST_SCRIPT=$(TEST_SCRIPT)) $(TEST_FLAG) \ build/host/$*/$*.exe cmd_coverage_test = $(subst build/host,build/coverage,$(cmd_host_test)) diff --git a/core/host/toolchain.mk b/core/host/toolchain.mk new file mode 100644 index 0000000000..168d0e24c2 --- /dev/null +++ b/core/host/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. + +CROSS_COMPILE_HOST_DEFAULT:=x86_64-pc-linux-gnu- + +$(call set-option,CROSS_COMPILE,\ + $(CROSS_COMPILE_host),\ + $(CROSS_COMPILE_HOST_DEFAULT)) -- cgit v1.2.1