diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-06-01 15:45:56 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-06-06 16:37:49 +0000 |
commit | 0090ba818fd500b807863f79d2c708800fff9a69 (patch) | |
tree | b3a632e7c280c5c83aea37a9cbab0cf3445fc9cb | |
parent | edfb2cfb0a1c369d3ee70e406ba36cbd0af72260 (diff) |
Add -lang-c and lang-c++ arguments to QCC compiler when needed
Because the compiler names differ only by case in older versions of
the QNX SDK, this doesn't work in case insensitive environments to
automatically determine the language type from the compiler name.
Task-number: QBS-1139
Change-Id: I1e1ebf67367450c90c6f53825bdcb4641f4e9587
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index 82f5c5834..b01331915 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -204,7 +204,7 @@ function escapeLinkerFlags(product, inputs, linkerFlags) { return linkerFlags; } -function linkerFlags(project, product, inputs, output) { +function linkerFlags(project, product, inputs, output, linkerPath) { var libraryPaths = product.cpp.libraryPaths; var distributionLibraryPaths = product.cpp.distributionLibraryPaths; var libraryDependencies = collectLibraryDependencies(product); @@ -245,6 +245,13 @@ function linkerFlags(project, product, inputs, output) { ["--as-needed"])); } + if (isLegacyQnxSdk(product)) { + ["c", "cpp"].map(function (tag) { + if (linkerPath === product.cpp.compilerPathByLanguage[tag]) + args = args.concat(qnxLangArgs(product, tag)); + }); + } + var targetLinkerFlags = product.cpp.targetLinkerFlags; if (targetLinkerFlags) args = args.concat(escapeLinkerFlags(product, inputs, targetLinkerFlags)); @@ -432,6 +439,12 @@ function languageTagFromFileExtension(toolchain, fileName) { return m[fileName.substring(i + 1)]; } +// Older versions of the QNX SDK have C and C++ compilers whose filenames differ only by case, +// which won't work in case insensitive environments like Win32+NTFS, HFS+ and APFS +function isLegacyQnxSdk(config) { + return config.qbs.toolchain.contains("qcc") && config.qnx && !config.qnx.qnx7; +} + function effectiveCompilerInfo(toolchain, input, output) { var compilerPath, language; var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags)); @@ -442,8 +455,14 @@ function effectiveCompilerInfo(toolchain, input, output) { var compilerPathByLanguage = input.cpp.compilerPathByLanguage; if (compilerPathByLanguage) compilerPath = compilerPathByLanguage[tag]; - if (!compilerPath || tag !== languageTagFromFileExtension(toolchain, input.fileName)) - language = languageName(tag) + (pchOutput ? '-header' : ''); + if (!compilerPath + || tag !== languageTagFromFileExtension(toolchain, input.fileName) + || isLegacyQnxSdk(input)) { + if (input.qbs.toolchain.contains("qcc")) + language = qnxLangArgs(input, tag); + else + language = ["-x", languageName(tag) + (pchOutput ? '-header' : '')]; + } if (!compilerPath) // fall back to main compiler compilerPath = input.cpp.compilerPath; @@ -454,6 +473,18 @@ function effectiveCompilerInfo(toolchain, input, output) { }; } + +function qnxLangArgs(config, tag) { + switch (tag) { + case "c": + return ["-lang-c"]; + case "cpp": + return ["-lang-c++"]; + default: + return []; + } +} + function compilerFlags(project, product, input, output) { var i; @@ -565,8 +596,8 @@ function compilerFlags(project, product, input, output) { } if (compilerInfo.language) - // Only push '-x language' if we have to. - args.push("-x", compilerInfo.language); + // Only push language arguments if we have to. + Array.prototype.push.apply(args, compilerInfo.language); args = args.concat(ModUtils.moduleProperty(input, 'platformFlags'), ModUtils.moduleProperty(input, 'flags'), @@ -910,7 +941,7 @@ function prepareLinker(project, product, inputs, outputs, input, output) { var linkerPath = effectiveLinkerPath(product, inputs) - var args = linkerFlags(project, product, inputs, primaryOutput) + var args = linkerFlags(project, product, inputs, primaryOutput, linkerPath); var wrapperArgsLength = 0; var wrapperArgs = product.cpp.linkerWrapper; if (wrapperArgs && wrapperArgs.length > 0) { |