From 999f6311644e6be137a70f8fa3c7f36286aa4be0 Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@qt.io>
Date: Tue, 28 Mar 2017 14:20:30 +0200
Subject: [PATCH] Fix build on 32 bit msvc toolchain

Bring back the logic to disable debugging symbols for 32
bit native compilers on Windows (symbol_level = 0), or
only do minimal debugging symbols useful for e.g. stack
traces (symbol_level = 1).

The corresponding gyp logic got removed in commit c5282c347929.

Change-Id: Ibb7d43814992a00f5413d024f9c362d41dc5a3a5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
---
 src/core/config/windows.pri | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri
index bc086277f..8d5a65f6f 100644
--- a/src/core/config/windows.pri
+++ b/src/core/config/windows.pri
@@ -19,6 +19,33 @@ isDeveloperBuild() {
         use_incremental_linking=false
 }
 
+defineTest(usingMSVC32BitCrossCompiler) {
+    CL_DIR =
+    for(dir, QMAKE_PATH_ENV) {
+        exists($$dir/cl.exe) {
+            CL_DIR = $$dir
+            break()
+        }
+    }
+    isEmpty(CL_DIR): {
+        warning(Cannot determine location of cl.exe.)
+        return(false)
+    }
+    CL_DIR = $$system_path($$CL_DIR)
+    CL_DIR = $$split(CL_DIR, \\)
+    CL_PLATFORM = $$last(CL_DIR)
+    equals(CL_PLATFORM, amd64_x86): return(true)
+    return(false)
+}
+
+msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() {
+    # The 32 bit MSVC linker runs out of memory if we do not remove all debug information.
+    gn_args += symbol_level=0
+} else {
+    # Chromium builds with debug info in release by default but Qt doesn't
+    CONFIG(release, debug|release):!force_debug_info: gn_args += symbol_level=1
+}
+
 msvc {
     equals(MSVC_VER, 14.0) {
         MSVS_VERSION = 2015
-- 
GitLab