summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-06-13 18:04:58 -0700
committerJake Petroules <jake.petroules@qt.io>2017-06-14 09:10:04 +0000
commiteb2e67a44ffa445a1bb360d1f75d5a722c0fa08a (patch)
tree5a13f251fce47449aa685e4351f343c7117742c0
parent5bfef74f12e59bfc699b7c8e93ea05c2625891d5 (diff)
downloadqbs-eb2e67a44ffa445a1bb360d1f75d5a722c0fa08a.tar.gz
Make sure qcc handles response files properly for linking
Task-number: QBS-1143 Change-Id: I588412c269222419cecc3394f4588a4269eb3a52 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--share/qbs/modules/cpp/gcc.js17
-rw-r--r--tests/auto/blackbox/testdata/response-files/response-files.qbs35
2 files changed, 50 insertions, 2 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index 387b3daca..78b534298 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -942,11 +942,24 @@ function prepareLinker(project, product, inputs, outputs, input, output) {
args = wrapperArgs.concat(args);
}
+ var responseFileArgumentIndex = wrapperArgsLength;
+
+ // qcc doesn't properly handle response files, so we have to do it manually
+ var useQnxResponseFileHack = product.qbs.toolchain.contains("qcc")
+ && useCompilerDriverLinker(product, inputs);
+ if (useQnxResponseFileHack) {
+ // qcc needs to see at least one object/library file to think it has something to do,
+ // so start the response file at the second object file (so, 3 after the last -o option)
+ var idx = args.lastIndexOf("-o");
+ if (idx !== -1 && idx + 3 < args.length)
+ responseFileArgumentIndex += idx + 3;
+ }
+
cmd = new Command(linkerPath, args);
cmd.description = 'linking ' + primaryOutput.fileName;
cmd.highlight = 'linker';
- cmd.responseFileArgumentIndex = wrapperArgsLength;
- cmd.responseFileUsagePrefix = '@';
+ cmd.responseFileArgumentIndex = responseFileArgumentIndex;
+ cmd.responseFileUsagePrefix = useQnxResponseFileHack ? "-Wl,@" : "@";
commands.push(cmd);
var debugInfo = outputs.debuginfo_app || outputs.debuginfo_dll
diff --git a/tests/auto/blackbox/testdata/response-files/response-files.qbs b/tests/auto/blackbox/testdata/response-files/response-files.qbs
index 7913287e1..2979fcdfd 100644
--- a/tests/auto/blackbox/testdata/response-files/response-files.qbs
+++ b/tests/auto/blackbox/testdata/response-files/response-files.qbs
@@ -34,4 +34,39 @@ Project {
}
}
}
+ Product {
+ name: "lotsofobjects"
+ type: ["dynamiclibrary"]
+ Depends { name: "cpp" }
+ Rule {
+ multiplex: true
+ outputFileTags: ["cpp"]
+ outputArtifacts: {
+ var artifacts = [];
+ for (var i = 0; i < 1000; ++i)
+ artifacts.push({filePath: "source-" + i + ".cpp", fileTags: ["cpp"]});
+ return artifacts;
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "generating " + outputs["cpp"].length + " dummy source files";
+ cmd.outputFilePaths = outputs["cpp"].map(function (a) {
+ return a.filePath;
+ });
+ cmd.sourceCode = function () {
+ var index = 0;
+ outputFilePaths.map(function (fp) {
+ var tf = new TextFile(fp, TextFile.WriteOnly);
+ try {
+ tf.writeLine("extern int foo" + index + "() { return 0; }");
+ ++index;
+ } finally {
+ tf.close();
+ }
+ });
+ };
+ return [cmd];
+ }
+ }
+ }
}