Skip to content

Clang fails to export a single default destructor (out of thousands) #143

Closed

Description

@bog-dan-ro

What happens is so strange and very hard to reproduce and debug. Basically clang fails to export a single default destructor and I had to do this https://codereview.qt-project.org/#/c/160374/ workarround. Qt has probably hundreds or even thousands of default destructors which are exported correctly by clang, but somehow, only this one fails to export it.

Sadly, it was impossible for me to come with a simple example ... so in order to reproduce it you'll have to compile the entire Qt. Because there are a few pending patches that you need to apply first, please let me know when you want to start working on this bug to tell you the steps.
If I'll write them now, probably in a few weeks they will be outdated.

Activity

  1. pirama-arumuga-nainar commented on Aug 9, 2016

    @pirama-arumuga-nainar
    Collaborator

    @bog-dan-ro Can you provide instructions to reproduce the issue?

  2. bog-dan-ro commented on Aug 10, 2016

    @bog-dan-ro
    Author

    Yep, you must compile the entire Qt in order to reproduce it.
    To do that you'll need a linux box and to run the following commands:

    $ git clone -b 5.7 git://code.qt.io/qt/qt5.git
    $ cd qt5
    
    Next command will clone all qt submodules and might take some time, we're skipping qtwebkit qtwebkit-examples qtwebengine
    $ ./init-repository -f --ignore-submodules qtwebkit qtwebkit-examples qtwebengine
    
    After the above command succeeds you need to go to qtconnectivity and revert the workaround
    $ cd qtconectivity 
    $ git revert 19e3ad566f77a5040781
    $ cd ..
    
    Next step is to configure Qt, by running configure script from top qt5 folder (not from qtbase)
    Qt needs an NDK and an SDK with  API 16(or better), latest tools & platform tools installed.
    
    $ ./configure -xplatform android-clang -nomake tests -nomake examples -android-ndk /home/taipan/android/android-ndk -android-sdk /home/taipan/android/android-sdk -skip qtwebkit -skip qtserialport -skip qtwebkit-examples -skip qttranslations -developer-build -release
    
    Replace /home/taipan/android/android-ndk/sdk with your paths
    
    If the configure script succeeds, you can start to build it:
    $ make -j10
    The build take some time to complete (well in our case to fail), and should stop in qtconnectivity complaining that there is no QLlcpServerPrivate::~QLlcpServerPrivate.
    
    
    *IF* you want to compile Qt using gcc, you need to clean everything (or clone it in another folder) and rerun configure script, with -xplatform android-g++ instead of -xplatform android-clang:
    
    $ ./configure -xplatform android-g++ -nomake tests -nomake examples -android-ndk /home/taipan/android/android-ndk -android-sdk /home/taipan/android/android-sdk -skip qtwebkit -skip qtserialport -skip qtwebkit-examples -skip qttranslations -developer-build -release
    
    compiling with gcc will also show you how big are the binaries produced by clang comparing with the ones produced by gcc
    

    @pirama-arumuga-nainar If you need more info on this matter, please feel free to contact me (or other folks) on freenode #necessitas channel, or here.

  3. pirama-arumuga-nainar commented on Aug 10, 2016

    @pirama-arumuga-nainar
    Collaborator

    Is this with r12b? My build with r12b completed succesfully. I am doing a clean rebuild to double check.

  4. bog-dan-ro commented on Aug 10, 2016

    @bog-dan-ro
    Author

    Can you double check if you've reverted my patch?
    Also please try to run make (with no -jX) in qtconectivity folder to be sure there is no error ?
    I tried it with r12a, I thought r12b just have minor fixes to scripts not to clang compiler...

  5. pirama-arumuga-nainar commented on Aug 10, 2016

    @pirama-arumuga-nainar
    Collaborator

    I am able to see that error if I run make in qtconnectivity. Not sure why the top-level build succeeds.

    I am trying to drop-in a newer Clang and reproduce.

  6. bog-dan-ro commented on Aug 11, 2016

    @bog-dan-ro
    Author

    It doesn't succeed, it's just hidden by themake -j10 which doesn't stop all jobs at first error. If you'll run only make (with no -jX) it will stop ;-)

    BTW I created two more patches for clang:

    You need to apply these two patches to qtbase, and you don't need to rebuild everything!
    If you want to change the compiler/linker flags for clang, you need to edit qtbase/mkspecs/android-clang/qmake.conf . There are two more conf files (qtbase/mkspecs/common/android-base-head.conf and qtbase/mkspecs/common/android-base-tail.conf but most probably you'll not need to change them).

  7. pirama-arumuga-nainar commented on Aug 11, 2016

    @pirama-arumuga-nainar
    Collaborator

    There is an ODR violation here.

    qllcpserver.cpp gets definition of class QLlcpServerPrivate from qllcpserver_p_p.h, which declares a (possibly) non-trivial destructor. So Clang generates an explicit call to the destructor in ~QLlcpServer.

    OTOH, the definition of QLlcpServerPrivate in qllcpserver_android_p.h doesn't specify a destructor. Clang doesn't generate an explicit destructor probably because the trivial destructor can be inlined.

    One possible design here seems to be for the class in qllcpserver_android_p.h to be a subclass of the one defined in qllcpserver_p_p.h

  8. pirama-arumuga-nainar commented on Aug 11, 2016

    @pirama-arumuga-nainar
    Collaborator

    PS: Not sure why gcc generates the destructor. Finding which object file among the gcc-built qllcpserver.o and qllcpserver_android.o has the destructor may shed some light.

  9. DanAlbert commented on Aug 11, 2016

    @DanAlbert
    Contributor

    Thanks for tracking that down, @pirama-arumuga-nainar!

  10. bog-dan-ro commented on Aug 16, 2016

    @bog-dan-ro
    Author

    Thanks a lot @pirama-arumuga-nainar, it was my fault because I didn't checked the code properly, sorry...
    Indeed that part of the code is very wrong, the reviewers didn't spot the problems when it was contributed long time ago....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions