summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-04-03 12:59:51 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-04-09 21:58:54 +0000
commiteaf20420f8a4d72c804a9d3725c3e294b34c78c8 (patch)
tree85679c23c28b7295667febc7e8885baaa4f2d320
parentfe7a8d61d1428f4d316c2a6884d8dfb8190520f0 (diff)
Fix precompiled headers with clang-clv5.13.0-beta2
Clang-cl couldn't find the header given to it by -FI when it isn't in any of the included directories. Additionally clang-cl 8 has a bug with exported templated classes with inline methods that causes it to have missing symbols at link time. We work around this. Fixes: QTBUG-74563 Change-Id: I7becf05fa8edb07bd4cefe12bee3737e5e1dfa14 Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r--mkspecs/win32-clang-msvc/qmake.conf3
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp16
2 files changed, 12 insertions, 7 deletions
diff --git a/mkspecs/win32-clang-msvc/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf
index 4b9cac3e22..9a7f70454d 100644
--- a/mkspecs/win32-clang-msvc/qmake.conf
+++ b/mkspecs/win32-clang-msvc/qmake.conf
@@ -44,7 +44,4 @@ QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
# Leave QMAKE_LFLAGS_LTCG empty because lld-link doesn't need any additional parameters
QMAKE_LFLAGS_LTCG =
-# Precompiled headers are not supported yet by clang
-CONFIG -= precompile_header
-
load(qt_config)
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index af6d3c5aff..63d89a5388 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -165,10 +165,14 @@ QString NmakeMakefileGenerator::var(const ProKey &value) const
|| value == "QMAKE_RUN_CXX_IMP"
|| value == "QMAKE_RUN_CXX");
if ((isRunCpp && usePCH) || (isRunC && usePCHC)) {
- QFileInfo precompHInfo(fileInfo(precompH));
- QString precompH_f = escapeFilePath(precompHInfo.fileName());
+ QString precompH_f = escapeFilePath(fileFixify(precompH, FileFixifyBackwards));
QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3")
.arg(precompH_f, precompH_f, escapeFilePath(isRunC ? precompPchC : precompPch));
+ // ### For clang_cl 8 we force inline methods to be compiled here instead
+ // linking them from a pch.o file. We do this by pretending we are also doing
+ // the pch.o generation step.
+ if (project->isActiveConfig("clang_cl"))
+ precompRule += QString(" -Xclang -building-pch-with-obj");
QString p = MakefileGenerator::var(value);
p.replace(QLatin1String("-c"), precompRule);
return p;
@@ -230,7 +234,10 @@ void NmakeMakefileGenerator::init()
precompObj = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext;
precompPch = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch.pch";
// Add linking of precompObj (required for whole precompiled classes)
- project->values("OBJECTS") += precompObj;
+ // ### For clang_cl we currently let inline methods be generated in the normal objects,
+ // since the PCH object is buggy (as of clang 8.0.0)
+ if (!project->isActiveConfig("clang_cl"))
+ project->values("OBJECTS") += precompObj;
// Add pch file to cleanup
project->values("QMAKE_CLEAN") += precompPch;
// Return to variable pool
@@ -240,7 +247,8 @@ void NmakeMakefileGenerator::init()
if (usePCHC) {
precompObjC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c" + Option::obj_ext;
precompPchC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c.pch";
- project->values("OBJECTS") += precompObjC;
+ if (!project->isActiveConfig("clang_cl"))
+ project->values("OBJECTS") += precompObjC;
project->values("QMAKE_CLEAN") += precompPchC;
project->values("PRECOMPILED_OBJECT_C") = ProStringList(precompObjC);
project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC);