cmake.mk,rules.mk: fix host builds using CMake and ccache
authorPetr Štetiar <ynezz@true.cz>
Fri, 27 Nov 2020 21:50:32 +0000 (22:50 +0100)
committerPetr Štetiar <ynezz@true.cz>
Sat, 5 Dec 2020 19:50:19 +0000 (20:50 +0100)
Commit f98878e4c17d ("cmake.mk: set C/CXX compiler for host builds as
well") has introduced regression as it didn't taken usage of ccache into
the account so fix it by handling ccache use cases as well.

In order to get this working we need to export HOSTCXX_NOCACHE in
rules.mk as well.

Fixes: f98878e4c17d ("cmake.mk: set C/CXX compiler for host builds as well")
Reported-by: Ansuel Smith <ansuelsmth@gmail.com>
Tested-by: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
(cherry picked from commit 524fb5646eec6147aadfdd508219f39bcf8ba8fc)

include/cmake.mk
rules.mk

index 1f764ab95593e68a359250e7b3b692faa91ce807..8989b4744fe0e31f2ad4663b974949bb584391dd 100644 (file)
@@ -22,12 +22,22 @@ ifeq ($(CONFIG_CCACHE),)
  CMAKE_CXX_COMPILER:=$(call cmake_tool,$(TARGET_CXX))
  CMAKE_C_COMPILER_ARG1:=
  CMAKE_CXX_COMPILER_ARG1:=
+
+ CMAKE_HOST_C_COMPILER:=$(HOSTCC)
+ CMAKE_HOST_CXX_COMPILER:=$(HOSTCXX)
+ CMAKE_HOST_C_COMPILER_ARG1:=
+ CMAKE_HOST_CXX_COMPILER_ARG1:=
 else
   CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
   CMAKE_C_COMPILER:=$(CCACHE)
   CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
   CMAKE_CXX_COMPILER:=$(CCACHE)
   CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
+
+  CMAKE_HOST_C_COMPILER:=$(CCACHE)
+  CMAKE_HOST_C_COMPILER_ARG1:=$(HOSTCC_NOCACHE)
+  CMAKE_HOST_CXX_COMPILER:=$(CCACHE)
+  CMAKE_HOST_CXX_COMPILER_ARG1:=$(HOSTCXX_NOCACHE)
 endif
 CMAKE_AR:=$(call cmake_tool,$(TARGET_AR))
 CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
@@ -90,8 +100,12 @@ define Host/Configure/Default
                LDFLAGS="$(HOST_LDFLAGS)" \
                cmake \
                        -DCMAKE_BUILD_TYPE=Release \
-                       -DCMAKE_C_COMPILER="$(HOSTCC)" \
-                       -DCMAKE_CXX_COMPILER="$(HOSTCXX)" \
+                       -DCMAKE_C_COMPILER="$(CMAKE_HOST_C_COMPILER)" \
+                       -DCMAKE_C_COMPILER_ARG1="$(CMAKE_HOST_C_COMPILER_ARG1)" \
+                       -DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)" \
+                       -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_HOST_CXX_COMPILER_ARG1)" \
+                       -DCMAKE_ASM_COMPILER="$(CMAKE_HOST_C_COMPILER)" \
+                       -DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_HOST_C_COMPILER_ARG1)" \
                        -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
                        -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
                        -DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
index 80cb3d63f449fa9e8d9ca72448d7bfe61e9c650d..41ed9bafd01b458a1ff3bf7b7b43cc6c48cca845 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -291,6 +291,7 @@ HOSTCXX_NOCACHE:=$(HOSTCXX)
 export TARGET_CC_NOCACHE
 export TARGET_CXX_NOCACHE
 export HOSTCC_NOCACHE
+export HOSTCXX_NOCACHE
 
 ifneq ($(CONFIG_CCACHE),)
   TARGET_CC:= ccache_cc