0012-Link-with-ldl-option-only-when-it-is-supported.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From 438f088ad520ac91ae47dba9a515ab0d1088c89c Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
  3. Date: Fri, 15 Apr 2016 03:32:02 +0200
  4. Subject: [PATCH] Link with -ldl option only when it is supported
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. `-ldl` option is used unconditionally in `QMAKE_LIBS_DYNLOAD` while libdl is
  9. not supported when libc is static. As the value of `QMAKE_LIBS_DYNLOAD` goes
  10. into 'Libs.private' field of the pkgconfig files created by qmake, static
  11. linking with qt will fail with:
  12. /usr/bin/ld: cannot find -ldl
  13. Fix this issue by adding a build test to configure to check if libdl is
  14. supported. `QMAKE_LIBS_DYNLOAD` in "src/corelib/plugin/plugin.pri" is now used
  15. only if libdl is available.
  16. Backported from Qt5:
  17. https://github.com/qtproject/qtbase/commit/f669ea0d54302de31456d57286aa0e4ca1443e98
  18. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
  19. ---
  20. config.tests/unix/libdl/libdl.cpp | 39 +++++++++++++++++++++++++++++++++++++++
  21. config.tests/unix/libdl/libdl.pro | 3 +++
  22. configure | 6 ++++++
  23. src/corelib/plugin/plugin.pri | 2 +-
  24. 4 files changed, 49 insertions(+), 1 deletion(-)
  25. create mode 100644 config.tests/unix/libdl/libdl.cpp
  26. create mode 100644 config.tests/unix/libdl/libdl.pro
  27. diff --git a/config.tests/unix/libdl/libdl.cpp b/config.tests/unix/libdl/libdl.cpp
  28. new file mode 100644
  29. index 0000000..28a8233
  30. --- /dev/null
  31. +++ b/config.tests/unix/libdl/libdl.cpp
  32. @@ -0,0 +1,39 @@
  33. +/****************************************************************************
  34. +**
  35. +** Copyright (C) 2015 The Qt Company Ltd.
  36. +** Contact: http://www.qt.io/licensing/
  37. +**
  38. +** This file is part of the config.tests of the Qt Toolkit.
  39. +**
  40. +** $QT_BEGIN_LICENSE:LGPL21$
  41. +** Commercial License Usage
  42. +** Licensees holding valid commercial Qt licenses may use this file in
  43. +** accordance with the commercial license agreement provided with the
  44. +** Software or, alternatively, in accordance with the terms contained in
  45. +** a written agreement between you and The Qt Company. For licensing terms
  46. +** and conditions see http://www.qt.io/terms-conditions. For further
  47. +** information use the contact form at http://www.qt.io/contact-us.
  48. +**
  49. +** GNU Lesser General Public License Usage
  50. +** Alternatively, this file may be used under the terms of the GNU Lesser
  51. +** General Public License version 2.1 or version 3 as published by the Free
  52. +** Software Foundation and appearing in the file LICENSE.LGPLv21 and
  53. +** LICENSE.LGPLv3 included in the packaging of this file. Please review the
  54. +** following information to ensure the GNU Lesser General Public License
  55. +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
  56. +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  57. +**
  58. +** As a special exception, The Qt Company gives you certain additional
  59. +** rights. These rights are described in The Qt Company LGPL Exception
  60. +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  61. +**
  62. +** $QT_END_LICENSE$
  63. +**
  64. +****************************************************************************/
  65. +
  66. +#include <dlfcn.h>
  67. +
  68. +int main(int, char **)
  69. +{
  70. + dlopen(0, 0);
  71. +}
  72. diff --git a/config.tests/unix/libdl/libdl.pro b/config.tests/unix/libdl/libdl.pro
  73. new file mode 100644
  74. index 0000000..a643934
  75. --- /dev/null
  76. +++ b/config.tests/unix/libdl/libdl.pro
  77. @@ -0,0 +1,3 @@
  78. +SOURCES = libdl.cpp
  79. +CONFIG -= qt dylib
  80. +LIBS += -ldl
  81. \ No newline at end of file
  82. diff --git a/configure b/configure
  83. index 10ad7ca..1c70691 100755
  84. --- a/configure
  85. +++ b/configure
  86. @@ -5506,6 +5506,12 @@ if [ "$CFG_LIBPNG" = "auto" ]; then
  87. fi
  88. fi
  89. +# detect dl
  90. +if ! compileTest unix/libdl "libdl"; then
  91. + QMakeVar add DEFINES QT_NO_DYNAMIC_LIBRARY
  92. + QMAKE_CONFIG="$QMAKE_CONFIG no-libdl"
  93. +fi
  94. +
  95. # detect accessibility
  96. if [ "$CFG_ACCESSIBILITY" = "auto" ]; then
  97. if [ "$XPLATFORM_SYMBIAN" = "yes" ]; then
  98. diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
  99. index eb7a7f7..c342f2e 100644
  100. --- a/src/corelib/plugin/plugin.pri
  101. +++ b/src/corelib/plugin/plugin.pri
  102. @@ -32,4 +32,4 @@ integrity {
  103. SOURCES += plugin/qlibrary_unix.cpp
  104. }
  105. -LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
  106. +!no-libdl: LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
  107. --
  108. 2.8.0