summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2018-10-09 13:51:46 +0300
committerMartin Storsjö <martin@martin.st>2018-10-12 14:01:59 +0000
commitd92c25b1b4ac0423a824715a08b2db2def4b6e25 (patch)
treeb120ae231c0948b6638578121e83ba071e0b7689
parent8d2deea49c506330a1077eedd1ec104beced65e7 (diff)
qmake: Fix building with lld with mingw makefiles
lld for coff/mingw doesn't support linker scripts, which qmake used for passing larger numbers of input file names to the linker. Instead of using a fullblown linker script for this, just use a plain response file, which both lld and binutils ld support. Change-Id: I3aace7902fa6ca861a0a9fe67feaa236e7ea417b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
-rw-r--r--qmake/generators/win32/mingw_make.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 13412e971a..99788394ea 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -131,22 +131,25 @@ QString MingwMakefileGenerator::installRoot() const
return QStringLiteral("$(INSTALL_ROOT:@msyshack@%=%)");
}
-void createLdObjectScriptFile(const QString &fileName, const ProStringList &objList)
+void createLdResponseFile(const QString &fileName, const ProStringList &objList)
{
QString filePath = Option::output_dir + QDir::separator() + fileName;
QFile file(filePath);
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream t(&file);
- t << "INPUT(\n";
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
QString path = (*it).toQString();
- // ### quoting?
- if (QDir::isRelativePath(path))
- t << "./" << path << endl;
- else
- t << path << endl;
+ // In response files, whitespace and special characters are
+ // escaped with a backslash; backslashes themselves can either
+ // be escaped into double backslashes, or, as this is a list of
+ // path names, converted to forward slashes.
+ path.replace(QLatin1Char('\\'), QLatin1String("/"))
+ .replace(QLatin1Char(' '), QLatin1String("\\ "))
+ .replace(QLatin1Char('\t'), QLatin1String("\\\t"))
+ .replace(QLatin1Char('"'), QLatin1String("\\\""))
+ .replace(QLatin1Char('\''), QLatin1String("\\'"));
+ t << path << endl;
}
- t << ");\n";
t.flush();
file.close();
}
@@ -307,14 +310,13 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS"));
objectsLinkLine = ar_cmd + " -M < " + escapeFilePath(ar_script_file);
} else {
- QString ld_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
- if (!var("BUILD_NAME").isEmpty()) {
- ld_script_file += "." + var("BUILD_NAME");
- }
+ QString ld_response_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
+ if (!var("BUILD_NAME").isEmpty())
+ ld_response_file += "." + var("BUILD_NAME");
if (!var("MAKEFILE").isEmpty())
- ld_script_file += "." + var("MAKEFILE");
- createLdObjectScriptFile(ld_script_file, project->values("OBJECTS"));
- objectsLinkLine = escapeFilePath(ld_script_file);
+ ld_response_file += "." + var("MAKEFILE");
+ createLdResponseFile(ld_response_file, project->values("OBJECTS"));
+ objectsLinkLine = "@" + escapeFilePath(ld_response_file);
}
Win32MakefileGenerator::writeObjectsPart(t);
}