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

FTBFS on macOS: moc does not get all the paths it needs

    XMLWordPrintable

Details

    • macOS

    Description

      When building the 5.8 beta sources (and current 5.8 branch), the build fails because Q_OS_MAC isn't defined while moc parses source code. That is caused by moc not receiving all the paths it needs from qmake.

      The error is:

      Undefined symbols for architecture x86_64:
        "QMacStyle::staticMetaObject", referenced from:
            showToolTip(QHelpEvent*, QWidget*, QStyleOptionComplex const&, QStyle::ComplexControl, QStyle::SubControl) in qmdisubwindow.o
            QMdiSubWindowPrivate::updateCursor() in qmdisubwindow.o
            QMdiSubWindowPrivate::getRegion(QMdiSubWindowPrivate::Operation) const in qmdisubwindow.o
            QMdiSubWindowPrivate::processClickedSubControl() in qmdisubwindow.o
            QMdiSubWindowPrivate::setSizeGrip(QSizeGrip*) in qmdisubwindow.o
            QMdiSubWindow::event(QEvent*) in qmdisubwindow.o
            QMdiSubWindow::showEvent(QShowEvent*) in qmdisubwindow.o
            ...
        "vtable for QMacStyle", referenced from:
            QMacStyle::QMacStyle() in qmacstyle_mac.o
            QMacStyle::~QMacStyle() in qmacstyle_mac.o
        NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
      ld: symbol(s) not found for architecture x86_64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      make[3]: *** [../../lib/QtWidgets.framework/QtWidgets] Error 1
      make[2]: *** [release-all] Error 2
      make[1]: *** [sub-widgets-make_first] Error 2
      make: *** [sub-src-make_first] Error 2
      

      With an earlier warning from moc:

      /private/tmp/qtbase-opensource-src-5.8.0-beta/bin/moc -DQT_NO_USING_NAMESPACE -DQT_NO_STYLE_WINDOWSVISTA -DQT_NO_STYLE_WINDOWSXP -DQT_NO_STYLE_ANDROID -DQT_BUILD_WIDGETS_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_GUI_LIB -DQT_CORE_LIB --include .moc/debug/moc_predefs.h -I/private/tmp/qtbase-opensource-src-5.8.0-beta/mkspecs/macx-clang -I/private/tmp/qtbase-opensource-src-5.8.0-beta/src/widgets -I/private/tmp/qtbase-opensource-src-5.8.0-beta/src/widgets/dialogs -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtWidgets -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtWidgets/5.8.0 -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtWidgets/5.8.0/QtWidgets -I/private/tmp/qtbase-opensource-src-5.8.0-beta/src/widgets/.uic -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtGui/5.8.0 -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtGui/5.8.0/QtGui -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtCore/5.8.0 -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtCore/5.8.0/QtCore -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtGui -I/private/tmp/qtbase-opensource-src-5.8.0-beta/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 -I/usr/local/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.0.0/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -F/private/tmp/qtbase-opensource-src-5.8.0-beta/lib styles/qmacstyle_mac_p.h -o .moc/debug/moc_qmacstyle_mac_p.cpp
      styles/qmacstyle_mac_p.h:0: Note: No relevant classes found. No output generated.
      

      The class in question (QMacStyle) is defined as:

      qmacstyle_p.h
      #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
      
      class QPalette;
      
      class QPushButton;
      class QStyleOptionButton;
      class QMacStylePrivate;
      class QMacStyle : public QCommonStyle
      {
          Q_OBJECT
      

      In turn, Q_OS_MAC is defined as:

      qsystemdetection.h
      #if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
      #  include <TargetConditionals.h>
      #  if defined(TARGET_OS_MAC) && TARGET_OS_MAC
      #    define Q_OS_DARWIN
      

      And the file TargetConditionals.h is found at:

      $ locate TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/AppleTVOS.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/AppleTVSimulator.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/MacOSX.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/WatchOS.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/WatchSimulator.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/iPhoneOS.sdk/usr/include/TargetConditionals.h
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/iPhoneSimulator.sdk/usr/include/TargetConditionals.h
      

      As can be seen, none of the paths where this file can be found were passed to moc by qmake. That means moc could not find TargetConditionals.h, which means TARGET_OS_MAC was not defined, which means Q_OS_DARWIN was not defined, which means Q_OS_MAC was not defined, which means the class QMacStyle was #ifdef'ed out, which means the output file was blank and no meta object was generated.

      $ cat .qmake.stash 
      QMAKE_DEFAULT_INCDIRS = \
          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 \
          /usr/local/include \
          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.0.0/include \
          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
      QMAKE_DEFAULT_LIBDIRS = \
          /lib \
          /usr/lib
      QMAKE_XCODE_DEVELOPER_PATH = /Applications/Xcode.app/Contents/Developer
      QMAKE_XCODE_VERSION = 8.0
      QMAKE_MAC_SDK.macosx.Path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
      QMAKE_MAC_SDK.macosx.PlatformPath = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
      QMAKE_MAC_SDK.macosx.SDKVersion = 10.12
      QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
      QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_CXX = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
      QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_FIX_RPATH = \
          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool \
          -id
      QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_AR = \
          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar \
          cq
      QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_RANLIB = \
          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib \
          -s
      QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_LINK = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
      QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_LINK_SHLIB = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
      

      The path wasn't found by qmake. That was found via:

      mkspecs/features/default_post.prf
              output = $$system("$$cmd_prefix $$QMAKE_CXX $$QMAKE_CXXFLAGS -xc++ -E -v - 2>&1 $$cmd_suffix", lines)
      

      Which is incorrect, since that doesn't run the compiler that the build actually uses. It needs to run the correct compiler (which is found by sdk.prf).

      Attachments

        Issue Links

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

          Activity

            People

              buddenha Oswald Buddenhagen
              thiago Thiago Macieira
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes