Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84747

OpenSSL static linking hidden bug

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.15.0
    • Network: SSL
    • None
    • Debian 10.4 Buster.
    • Linux/X11

    Description

      Hi. I am building static Qt 5.15.0 and have pre-build OpenSSL 1.1.1f on Debian 10.4. Part of my config:

      export OPENSSL_LIBS="-L$OPENSSL_DIR/lib -lssl -lcrypto";
      
      ./configure -static -openssl-linked 
      

       So, result build options contains:

      OpenSSL ................................ yes
      Qt directly linked to OpenSSL ........ yes

      And build is successful. But, when I build applications with this statically build Qt I have OpenSSL shared libs in dependencies list, but they mustn't be there, aren't they? (I check them with 'readelf -d <app-path>').

      So, than I checked config.log file and found strange output, part of it:

      looking for library openssl
      Trying source 0 (type openssl) of library openssl ...
      + cd /usr/local/Qt-5.15.0/src/BUILD/config.tests/openssl && /usr/local/Qt-5.15.0/src/BUILD/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" 'QMAKE_LIBDIR += /usr/local/Qt-5.15.0/lib/third_party/icu/lib' 'INCLUDEPATH += /usr/local/Qt-5.15.0/lib/third_party/icu/include' 'QMAKE_USE += openssl' 'QMAKE_LIBS_OPENSSL = -L/usr/local/Qt-5.15.0/lib/third_party/openssl/lib -lssl -lcrypto' /usr/local/Qt-5.15.0/src/BUILD/config.tests/openssl
      + cd /usr/local/Qt-5.15.0/src/BUILD/config.tests/openssl && MAKEFLAGS= /usr/bin/make
      > g++ -c -pipe -O2 -w -fPIC -I. -I/usr/local/Qt-5.15.0/lib/third_party/icu/include -I/usr/local/Qt-5.15.0/src/qtbase/mkspecs/linux-g++ -o main.o main.cpp
      > g++ -Wl,-O1 -o openssl main.o -L/usr/local/Qt-5.15.0/lib/third_party/icu/lib -L/usr/local/Qt-5.15.0/lib/third_party/openssl/lib -lssl -lcrypto 
      > /usr/bin/ld: /usr/local/Qt-5.15.0/lib/third_party/openssl/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_new':
      > threads_pthread.c:(.text+0x45): undefined reference to `pthread_rwlock_init'
      > /usr/bin/ld: /usr/local/Qt-5.15.0/lib/third_party/openssl/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_read_lock':
      > threads_pthread.c:(.text+0x75): undefined reference to `pthread_rwlock_rdlock'
      > /usr/bin/ld: /usr/local/Qt-5.15.0/lib/third_party/openssl/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_write_lock':
      > threads_pthread.c:(.text+0x95): undefined reference to `pthread_rwlock_wrlock'
      ...................................................................................
      > collect2: error: ld returned 1 exit status
      > make: *** [Makefile:67: openssl] Error 1
       => source failed verification.
      Trying source 1 (type inline) of library openssl ...
        => source failed condition 'config.win32'.
      Trying source 2 (type inline) of library openssl ...
        => source failed condition 'config.msvc'.
      Trying source 3 (type inline) of library openssl ...
        => source failed condition 'config.android'.
      Trying source 4 (type inline) of library openssl ...
      + cd /usr/local/Qt-5.15.0/src/BUILD/config.tests/openssl && /usr/local/Qt-5.15.0/src/BUILD/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" 'QMAKE_LIBDIR += /usr/local/Qt-5.15.0/lib/third_party/icu/lib' 'INCLUDEPATH += /usr/local/Qt-5.15.0/lib/third_party/icu/include' 'QMAKE_USE += openssl' 'QMAKE_LIBS_OPENSSL = -lssl -lcrypto' /usr/local/Qt-5.15.0/src/BUILD/config.tests/openssl
      ...................................................................................
       => source accepted.
      test config.qtbase_network.libraries.openssl succeeded

      We can see that make tries OpenSSL specified by me, it fails and tries some other sources and at the last it seems to take system version of OpenSSL or whatever.
      I don't know exactly if it is a problem with my build of OpenSSL or is it a problem with tests, but it is a weird behavior that Qt takes not the lib from path I specified and prints nothing about this at the output or maybe it should even be an error?
      Check this please. You can find config.log and OpenSSL I used in attachments.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            graullon Sergey Hrushak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes