diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-05-23 19:01:10 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-05-27 08:27:28 +0000 |
commit | 8c7b2115e6e2641c1c41d2082c087ea3d0fc101f (patch) | |
tree | 827135c5208de4efb06d05a939cdbc4afe55ebbd /share | |
parent | 9ca0b41dd60575fdc579dd83a10702c80886cac3 (diff) |
C/C++: Prevent adjacent duplicate libs
It is never necessary to have the same library on the linker command
line twice in a row, so we can safely remove such duplicates.
Change-Id: Ie6ebe489862702828996fb78533eb4ac400df1cd
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'share')
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 4 | ||||
-rw-r--r-- | share/qbs/modules/cpp/msvc.js | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index 7e25fa402..6936beb5e 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -440,9 +440,13 @@ function linkerFlags(project, product, inputs, outputs, primaryOutput, linkerPat } var wholeArchiveActive = false; + var prevLib; for (i = 0; i < libraryDependencies.libraries.length; ++i) { var dep = libraryDependencies.libraries[i]; var lib = dep.filePath; + if (lib === prevLib) + continue; + prevLib = lib; if (dep.wholeArchive && !wholeArchiveActive) { var wholeArchiveFlag; if (isDarwin) { diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js index 5da2ad0cf..9deffa064 100644 --- a/share/qbs/modules/cpp/msvc.js +++ b/share/qbs/modules/cpp/msvc.js @@ -449,10 +449,15 @@ function prepareLinker(project, product, inputs, outputs, input, output) { var wholeArchiveSupported = linkerSupportsWholeArchive(product); var wholeArchiveRequested = false; var libDeps = collectLibraryDependencies(product); + var prevLib; for (i = 0; i < libDeps.length; ++i) { var dep = libDeps[i]; + var lib = dep.filePath; + if (lib === prevLib) + continue; + prevLib = lib; args.push((wholeArchiveSupported && dep.wholeArchive ? "/WHOLEARCHIVE:" : "") - + FileInfo.toWindowsSeparators(dep.filePath)); + + FileInfo.toWindowsSeparators(lib)); if (dep.wholeArchive) wholeArchiveRequested = true; } |