Fix precompiled headers with clang-cl
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>
This commit is contained in:
parent
fe7a8d61d1
commit
eaf20420f8
@ -44,7 +44,4 @@ QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
|
|||||||
# Leave QMAKE_LFLAGS_LTCG empty because lld-link doesn't need any additional parameters
|
# Leave QMAKE_LFLAGS_LTCG empty because lld-link doesn't need any additional parameters
|
||||||
QMAKE_LFLAGS_LTCG =
|
QMAKE_LFLAGS_LTCG =
|
||||||
|
|
||||||
# Precompiled headers are not supported yet by clang
|
|
||||||
CONFIG -= precompile_header
|
|
||||||
|
|
||||||
load(qt_config)
|
load(qt_config)
|
||||||
|
@ -165,10 +165,14 @@ QString NmakeMakefileGenerator::var(const ProKey &value) const
|
|||||||
|| value == "QMAKE_RUN_CXX_IMP"
|
|| value == "QMAKE_RUN_CXX_IMP"
|
||||||
|| value == "QMAKE_RUN_CXX");
|
|| value == "QMAKE_RUN_CXX");
|
||||||
if ((isRunCpp && usePCH) || (isRunC && usePCHC)) {
|
if ((isRunCpp && usePCH) || (isRunC && usePCHC)) {
|
||||||
QFileInfo precompHInfo(fileInfo(precompH));
|
QString precompH_f = escapeFilePath(fileFixify(precompH, FileFixifyBackwards));
|
||||||
QString precompH_f = escapeFilePath(precompHInfo.fileName());
|
|
||||||
QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3")
|
QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3")
|
||||||
.arg(precompH_f, precompH_f, escapeFilePath(isRunC ? precompPchC : precompPch));
|
.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);
|
QString p = MakefileGenerator::var(value);
|
||||||
p.replace(QLatin1String("-c"), precompRule);
|
p.replace(QLatin1String("-c"), precompRule);
|
||||||
return p;
|
return p;
|
||||||
@ -230,7 +234,10 @@ void NmakeMakefileGenerator::init()
|
|||||||
precompObj = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext;
|
precompObj = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext;
|
||||||
precompPch = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch.pch";
|
precompPch = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch.pch";
|
||||||
// Add linking of precompObj (required for whole precompiled classes)
|
// 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
|
// Add pch file to cleanup
|
||||||
project->values("QMAKE_CLEAN") += precompPch;
|
project->values("QMAKE_CLEAN") += precompPch;
|
||||||
// Return to variable pool
|
// Return to variable pool
|
||||||
@ -240,7 +247,8 @@ void NmakeMakefileGenerator::init()
|
|||||||
if (usePCHC) {
|
if (usePCHC) {
|
||||||
precompObjC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c" + Option::obj_ext;
|
precompObjC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c" + Option::obj_ext;
|
||||||
precompPchC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c.pch";
|
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("QMAKE_CLEAN") += precompPchC;
|
||||||
project->values("PRECOMPILED_OBJECT_C") = ProStringList(precompObjC);
|
project->values("PRECOMPILED_OBJECT_C") = ProStringList(precompObjC);
|
||||||
project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC);
|
project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC);
|
||||||
|
Loading…
Reference in New Issue
Block a user