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

target QMAKE_DEFAULT_LIBDIRS is used for host builds

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.0 Beta 2
    • 5.7.1
    • Build tools: qmake
    • None
    • f67afee9e932dd220474227882a745233455d729

    Description

      I'm cross-compiling Qt from Fedora to Windows using Fedora's mingw toolchain.

      I've encountered a number of build failure when compiling host tools (i.e. lupdate, lrelease, etc) due to
      LIBS = $(SUBLIBS) -lQt5Bootstrap -lpthread
      missing the host library path
      -L/usr/i686-w64-mingw32/lib

      Investigating I've discovered the following:

      • Module libdirs are filtered by QMAKE_DEFAULT_LIBDIRS:
        qt.prf: MODULE_LIBS_ADD -= $$QMAKE_DEFAULT_LIBDIRS
      • QMAKE_DEFAULT_LIBDIRS is assembled in toolchain.prf, on my Fedora system based on the output of
        LC_ALL=C i686-w64-mingw32-g++ -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 --param=ssp-buffer-size=4 -fno-keep-inline-dllexport -xc++ -E -v - 2>&1 </dev/null >/dev/null
      • The output of the above command contains
        LIBRARY_PATH=/usr/lib/gcc/i686-w64-mingw32/6.3.0/:/usr/lib/gcc/i686-w64-mingw32/6.3.0/../../../../i686-w64-mingw32/lib/../lib/:/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/:/usr/lib/gcc/i686-w64-mingw32/6.3.0/../../../../i686-w64-mingw32/lib/:/usr/i686-w64-mingw32/sys-root/mingw/lib/
      • Some of the entries in LIBRARY_PATH resolve to /usr/i686-w64-mingw32/lib which is the host library directory (as opposed to /usr/i686-w64-mingw32/sys-root/mingw/lib/ which is the target directory).

      My conclusion is that QMAKE_DEFAULT_LIBDIRS should not contain the host library directory. Indeed a hacky patch along the lines of

      --- a/mkspecs/features/toolchain.prf
      +++ b/mkspecs/features/toolchain.prf
      @@ -30,6 +30,12 @@ isEmpty(QMAKE_DEFAULT_INCDIRS):!host_build {
                   }
               }
               QMAKE_DEFAULT_LIBDIRS = $$unique(QMAKE_DEFAULT_LIBDIRS)
      +        #HACK Don't include the native libdir to the default libdirs when crosscompiling
      +        #Fixes -lQt5Bootstrap not found due to missing -L (module libdirs are filtered by QMAKE_DEFAULT_LIBDIRS)
      +        cross_compile: {
      +            QMAKE_DEFAULT_LIBDIRS -= $$[QT_HOST_LIBS]
      +        }
      +
           }
       
           unix {
      

      fixes the build failures.

      I'm not sure if my analysis is correct and if this is possibly a bug in the toolchain, i.e. that the host directory should not even be listed in LIBRARY_PATH. Reporting here to get the opinion of someone more familiar with the qmake internals.

      Attachments

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

        Activity

          People

            buddenha Oswald Buddenhagen
            smani Sandro Mani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes