0005-Fix-dependency_libs-entry-of-.la-files.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From 23e437bb5cba5b13ee327c36d8199a49aad9a8da Mon Sep 17 00:00:00 2001
  2. From: Joerg Bornemann <joerg.bornemann@qt.io>
  3. Date: Wed, 31 Jul 2019 10:55:14 +0200
  4. Subject: [PATCH] Fix dependency_libs entry of .la files
  5. Libtool cannot cope with absolute paths in the dependency_libs entry.
  6. We split absolute paths into -L and -l here.
  7. Change-Id: I30bf11e490d1993d2a4d88c114e07bbae12def6d
  8. Fixes: QTBUG-76625
  9. Upstream: https://codereview.qt-project.org/c/qt/qtbase/+/269146
  10. Signed-off-by: Peter Seiderer <ps.report@gmx.net>
  11. ---
  12. qmake/generators/unix/unixmake2.cpp | 36 +++++++++++++++++++++++++----
  13. 1 file changed, 31 insertions(+), 5 deletions(-)
  14. diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
  15. index d9bcccf2e2..ddc3b063d4 100644
  16. --- a/qmake/generators/unix/unixmake2.cpp
  17. +++ b/qmake/generators/unix/unixmake2.cpp
  18. @@ -1450,6 +1450,33 @@ UnixMakefileGenerator::libtoolFileName(bool fixify)
  19. void
  20. UnixMakefileGenerator::writeLibtoolFile()
  21. {
  22. + auto fixAbsolutePaths
  23. + = [this](const ProStringList &libs)
  24. + {
  25. + ProStringList result;
  26. + for (auto lib : libs) {
  27. + auto fi = fileInfo(lib.toQString());
  28. + if (fi.isAbsolute()) {
  29. + const QString libDirArg = "-L" + fi.path();
  30. + if (!result.contains(libDirArg))
  31. + result += libDirArg;
  32. + QString namespec = fi.fileName();
  33. + int dotPos = namespec.lastIndexOf('.');
  34. + if (dotPos != -1 && namespec.startsWith("lib")) {
  35. + namespec.truncate(dotPos);
  36. + namespec.remove(0, 3);
  37. + } else {
  38. + namespec.prepend(':');
  39. + }
  40. + result += "-l" + namespec;
  41. + } else {
  42. +
  43. + result += lib;
  44. + }
  45. + }
  46. + return result;
  47. + };
  48. +
  49. QString fname = libtoolFileName(), lname = fname;
  50. mkdir(fileInfo(fname).path());
  51. int slsh = lname.lastIndexOf(Option::dir_sep);
  52. @@ -1488,12 +1515,11 @@ UnixMakefileGenerator::writeLibtoolFile()
  53. << ".a'\n\n";
  54. t << "# Libraries that this one depends upon.\n";
  55. + static const ProKey libVars[] = { "LIBS", "QMAKE_LIBS" };
  56. ProStringList libs;
  57. - libs << "LIBS" << "QMAKE_LIBS";
  58. - t << "dependency_libs='";
  59. - for (ProStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it)
  60. - t << fixLibFlags((*it).toKey()).join(' ') << ' ';
  61. - t << "'\n\n";
  62. + for (auto var : libVars)
  63. + libs += fixLibFlags(var);
  64. + t << "dependency_libs='" << fixAbsolutePaths(libs).join(' ') << "'\n\n";
  65. t << "# Version information for " << lname << "\n";
  66. int maj = project->first("VER_MAJ").toInt();
  67. --
  68. 2.22.0