Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Build error in release mode (Android/Armv4/GCC4.9/Qt5.7.0) but not in debug...

    General and Desktop
    qt 5.7.0 android arm7 gcc
    2
    5
    2562
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KroMignon
      KroMignon last edited by SGaist

      Hi dear GCC/Qt/Android experts.

      I need some help on a very strange problem which I don't understand.

      I have create an Android application base on Qt 5.7.0. This application uses some libraries I'm already using for other projects based on Qt 5.4 (Windows XP/7 and Linux x86/ARM4).

      But one of those libraries won't build as "Release" on Android but build in "Debug"!

      My build configuration is following:

      • Build machine is using Windows 7 Pro/64 bit
      • Qt Creator 4.1.0
      • Android NDK r12 (I've also tested r13b and r14Beta1) 32 bit
      • Android SDK Tools 25.2.4
      • Qt 5.7.0 for Android armv7

      The error I've got is as following:

      C:\Android\android-ndk-r14-beta1/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DAPP_VERSION=\"3.09.101.00000\" -DGCCOMLIB_LIBRARY -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_SQL_LIB -DQT_CORE_LIB -I..\..\..\..\GCComLib\trunk\GCComLib -I. -I..\..\..\..\GCComLib\trunk -I..\..\..\..\StdLib\trunk\StdLib -IC:\Qt\5.7\android_armv7\include -IC:\Qt\5.7\android_armv7\include\QtNetwork -IC:\Qt\5.7\android_armv7\include\QtSql -IC:\Qt\5.7\android_armv7\include\QtCore -I. -isystem C:\Android\android-ndk-r14-beta1\sources\cxx-stl\gnu-libstdc++\4.9\include -isystem C:\Android\android-ndk-r14-beta1\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\include -isystem C:\Android\android-ndk-r14-beta1\platforms\android-9\arch-arm\usr\include -IC:\Qt\5.7\android_armv7\mkspecs\android-g++ -o GCDatagram.obj ..\..\..\..\GCComLib\trunk\GCComLib\UDP\GCDatagram.cpp
      In file included from C:\Qt\5.7\android_armv7\include/QtCore/QtCore:13:0,
                       from C:\Qt\5.7\android_armv7\include/QtSql/QtSqlDepends:3,
                       from C:\Qt\5.7\android_armv7\include/QtSql/QtSql:3,
                       from ..\..\..\..\StdLib\trunk\StdLib/DataType/GCDataType.h:6,
                       from ..\..\..\..\GCComLib\trunk\GCComLib/Messages/MessageBase.h:8,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\UDP\GCDatagram.h:6,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\UDP\GCDatagram.cpp:1:
      C:\Qt\5.7\android_armv7\include/QtCore/qendian.h:53:0: warning: "QT_HAS_BUILTIN" redefined
       #  define QT_HAS_BUILTIN(x)     __has_builtin(x)
       ^
      In file included from C:\Qt\5.7\android_armv7\include/QtCore/qglobal.h:83:0,
                       from ..\..\..\..\GCComLib\trunk\GCComLib/GCComLibGlobal.h:4,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\UDP\GCDatagram.h:4,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\UDP\GCDatagram.cpp:1:
      C:\Qt\5.7\android_armv7\include/QtCore/qcompilerdetection.h:1209:0: note: this is the location of the previous definition
       #  define QT_HAS_BUILTIN(x)             0
       ^
      C:\Android\android-ndk-r14-beta1/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DAPP_VERSION=\"3.09.101.00000\" -DGCCOMLIB_LIBRARY -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_SQL_LIB -DQT_CORE_LIB -I..\..\..\..\GCComLib\trunk\GCComLib -I. -I..\..\..\..\GCComLib\trunk -I..\..\..\..\StdLib\trunk\StdLib -IC:\Qt\5.7\android_armv7\include -IC:\Qt\5.7\android_armv7\include\QtNetwork -IC:\Qt\5.7\android_armv7\include\QtSql -IC:\Qt\5.7\android_armv7\include\QtCore -I. -isystem C:\Android\android-ndk-r14-beta1\sources\cxx-stl\gnu-libstdc++\4.9\include -isystem C:\Android\android-ndk-r14-beta1\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\include -isystem C:\Android\android-ndk-r14-beta1\platforms\android-9\arch-arm\usr\include -IC:\Qt\5.7\android_armv7\mkspecs\android-g++ -o GCComHandler.obj ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCComHandler.cpp
      In file included from C:\Qt\5.7\android_armv7\include/QtCore/QtCore:13:0,
                       from C:\Qt\5.7\android_armv7\include/QtSql/QtSqlDepends:3,
                       from C:\Qt\5.7\android_armv7\include/QtSql/QtSql:3,
                       from ..\..\..\..\StdLib\trunk\StdLib/DataType/GCDataType.h:6,
                       from ..\..\..\..\GCComLib\trunk\GCComLib/Messages/MessageBase.h:8,
                       from ..\..\..\..\GCComLib\trunk\GCComLib/UDP/GCDatagram.h:6,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCUdpSocket.h:11,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCComHandler.h:14,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCComHandler.cpp:1:
      C:\Qt\5.7\android_armv7\include/QtCore/qendian.h:53:0: warning: "QT_HAS_BUILTIN" redefined
       #  define QT_HAS_BUILTIN(x)     __has_builtin(x)
       ^
      In file included from C:\Qt\5.7\android_armv7\include/QtCore/qglobal.h:83:0,
                       from C:\Qt\5.7\android_armv7\include/QtCore/qiodevice.h:43,
                       from C:\Qt\5.7\android_armv7\include/QtNetwork/qabstractsocket.h:43,
                       from C:\Qt\5.7\android_armv7\include\QtNetwork/qudpsocket.h:43,
                       from C:\Qt\5.7\android_armv7\include\QtNetwork/QUdpSocket:1,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCComHandler.h:4,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCComHandler.cpp:1:
      C:\Qt\5.7\android_armv7\include/QtCore/qcompilerdetection.h:1209:0: note: this is the location of the previous definition
       #  define QT_HAS_BUILTIN(x)             0
       ^
      In file included from C:\Android\android-ndk-r14-beta1\sources\cxx-stl\gnu-libstdc++\4.9\include/atomic:41:0,
                       from C:\Qt\5.7\android_armv7\include/QtCore/qatomic_cxx11.h:45,
                       from C:\Qt\5.7\android_armv7\include/QtCore/qbasicatomic.h:53,
                       from C:\Qt\5.7\android_armv7\include/QtCore/qatomic.h:46,
                       from C:\Qt\5.7\android_armv7\include/QtCore/qglobal.h:1145,
                       from C:\Qt\5.7\android_armv7\include/QtCore/qiodevice.h:43,
                       from C:\Qt\5.7\android_armv7\include/QtNetwork/qabstractsocket.h:43,
                       from C:\Qt\5.7\android_armv7\include\QtNetwork/qudpsocket.h:43,
                       from C:\Qt\5.7\android_armv7\include\QtNetwork/QUdpSocket:1,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCComHandler.h:4,
                       from ..\..\..\..\GCComLib\trunk\GCComLib\Client\GCComHandler.cpp:1:
      C:\Android\android-ndk-r14-beta1\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/atomic_base.h: In member function 'void Geocept::GCComLib::Client::GCComHandler::processIncomingMsg(Geocept::GCComLib::Messages::MessageBasePtr)':
      C:\Android\android-ndk-r14-beta1\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/atomic_base.h:584:70: error: failure memory model cannot be stronger than success memory model for '__atomic_compare_exchange'
        return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, __m1, __m2);
      

      Additionnal information
      ==> MessageBasePtr is as typedef of QSharedPointer<MessageBase>
      MessageBase is a virtual class used as base class for message handling.

      I don't understand what this does mean failure memory model cannot be stronger than success memory model for '__atomic_compare_exchange'

      And why this build fine in Debug mode?!?

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @KroMignon last edited by

        @KroMignon
        it seems this is only an issue with gcc 4.x version's optimization.
        It should work with gcc 5.x
        Especially with the -Os flag in release mode.

        See this.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 1
        • KroMignon
          KroMignon last edited by

          @raven-worx : thanks for your quick answer, but GCC comes with Android SDK... so I don't have any chance to change GCC version.

          How can I remove this -Os flag in my project file (PRO format)?

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          KroMignon raven-worx 2 Replies Last reply Reply Quote 0
          • KroMignon
            KroMignon @KroMignon last edited by

            @raven-worx : Thanks a lot for pointing out the problem.

            In fact, it was the -Os optimization from GCC 4.9, I've turn it off for Android in my PRO file with following command:

            android: QMAKE_CXXFLAGS_RELEASE -= -Os
            

            Now I can build my library in release mode :)
            Perhaps this could help someone else.

            Have a nice day.

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            1 Reply Last reply Reply Quote 0
            • raven-worx
              raven-worx Moderators @KroMignon last edited by

              @KroMignon
              you can try the following:

              QMAKE_CXXFLAGS_RELEASE -= -Os
              QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -Os
              

              Maybe add an other optimization flag as desired.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply Reply Quote 3
              • First post
                Last post