1From bae24edf61de8e374a43b7eede7be8c90a2a32e5 Mon Sep 17 00:00:00 2001
2From: Samuli Piippo <samuli.piippo@qt.io>
3Date: Wed, 15 Mar 2017 13:53:28 +0200
4Subject: [PATCH] Force host toolchain configuration
5
6Force gcc/g++ to be used for parts using host toolchain, since
7the option(host_build) does not work in yocto builds.
8
9Don't use QT_ARCH for the host architecture, since that's always
10the target architecture in bitbake builds, instead ask specifically
11for the qmakes's host architecture.
12
13Upstream-Status: Inappropriate [OE specific]
14Signed-off-by: Samuli Piippo <samuli.piippo@qt.io>
15---
16 src/buildtools/config/linux.pri   |  2 +-
17 src/buildtools/configure_host.pro | 14 +++++++-------
18 src/buildtools/gn.pro             |  5 ++---
19 3 files changed, 10 insertions(+), 11 deletions(-)
20
21diff --git a/src/buildtools/config/linux.pri b/src/buildtools/config/linux.pri
22index 7507d51ef..1e078cbfe 100644
23--- a/src/buildtools/config/linux.pri
24+++ b/src/buildtools/config/linux.pri
25@@ -118,7 +118,7 @@ contains(QT_ARCH, "mips") {
26
27 host_build {
28     gn_args += custom_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\"
29-    GN_HOST_CPU = $$gnArch($$QT_ARCH)
30+    GN_HOST_CPU = $$gnArch($$QMAKE_HOST.arch)
31     gn_args += host_cpu=\"$$GN_HOST_CPU\"
32     # Don't bother trying to use system libraries in this case
33     gn_args += use_glib=false
34diff --git a/src/buildtools/configure_host.pro b/src/buildtools/configure_host.pro
35index dd0d3e327..6312c8678 100644
36--- a/src/buildtools/configure_host.pro
37+++ b/src/buildtools/configure_host.pro
38@@ -4,7 +4,7 @@ TEMPLATE = aux
39 # Pick up the host toolchain
40 option(host_build)
41
42-GN_HOST_CPU = $$gnArch($$QT_ARCH)
43+GN_HOST_CPU = $$gnArch($$QMAKE_HOST.arch)
44 !isEmpty(QT_TARGET_ARCH): GN_TARGET_CPU = $$gnArch($$QT_TARGET_ARCH)
45 else: GN_TARGET_CPU = $$GN_HOST_CPU
46 GN_OS = $$gnOS()
47@@ -31,9 +31,9 @@ GN_CONTENTS = \
48 "import(\"//build/config/sysroot.gni\")" \
49 "import(\"//build/toolchain/gcc_toolchain.gni\")" \
50 "gcc_toolchain(\"host\") {" \
51-"  cc = \"$$which($$QMAKE_CC)\" " \
52-"  cxx = \"$$which($$QMAKE_CXX)\" " \
53-"  ld = \"$$which($$QMAKE_LINK)\" " \
54+"  cc = \"$$which($$CC_host)\" " \
55+"  cxx = \"$$which($$CXX_host)\" " \
56+"  ld = \"$$which($$CXX_host)\" " \
57 "  ar = \"$$which(ar)\" " \
58 "  nm = \"$$which(nm)\" " \
59 "  extra_cppflags = \"$$GN_HOST_EXTRA_CPPFLAGS\" " \
60@@ -45,9 +45,9 @@ GN_CONTENTS = \
61 "  } " \
62 "}" \
63 "gcc_toolchain(\"v8_snapshot\") {" \
64-"  cc = \"$$which($$QMAKE_CC)\" " \
65-"  cxx = \"$$which($$QMAKE_CXX)\" " \
66-"  ld = \"$$which($$QMAKE_LINK)\" " \
67+"  cc = \"$$which($$CC_host)\" " \
68+"  cxx = \"$$which($$CXX_host)\" " \
69+"  ld = \"$$which($$CXX_host)\" " \
70 "  ar = \"$$which(ar)\" " \
71 "  nm = \"$$which(nm)\" " \
72 "  toolchain_args = { " \
73diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro
74index f94694da0..a8ca6567b 100644
75--- a/src/buildtools/gn.pro
76+++ b/src/buildtools/gn.pro
77@@ -19,9 +19,8 @@ build_pass|!debug_and_release {
78             gn_bootstrap = $$system_path($$absolute_path(gn/build/gen.py, $$src_3rd_party_dir))
79
80             gn_gen_args = --no-last-commit-position --out-path $$out_path \
81-                          --cc \"$$which($$QMAKE_CC)\" --cxx \"$$which($$QMAKE_CXX)\" \
82-                          --ld \"$$which($$QMAKE_LINK)\"
83-            !isEmpty(QMAKE_AR): gn_gen_args += --ar \"$$which($$first(QMAKE_AR))\"
84+                          --cc \"$$which($$CC_host)\" --cxx \"$$which($$CXX_host)\" \
85+                          --ld \"$$which($$CXX_host)\" --ar \"$$which(ar)\"
86
87             msvc:!clang_cl: gn_gen_args += --use-lto
88
89