Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt5 watchpoints with GDB on Linux without -fPIC (and fails to build Qt5.14 from source on Debian/Sid/x86-64)



  • Hello All,

    All technical details are here. To summarize: RefPerSys is a GPLv3+ project on Linux x86-64 (and I don't care at all about portability to any other platform supported by Qt5). It uses Qt5.12. It is generating C++ code at runtime and compiling it as a shared library then dlopen(3)-ing it as a plugin.

    For ease of debugging with gdb and to facilitate using its watchpoints, I want to disable position-independent-code in my ./refpersys executable. Of course, the Qt5 libraries remain PIC.

    But when I compile without -fPIC I am getting a compile-time error mentioning You must build your code with position independent code .... Is there any way to avoid such an error?

    I could compile Qt5 from its source code if that helps. What is the magical configuration option to use then?

    Thanks for reading.

    BTW, I did try to compile Qt5.14 from source code. Configured it with:

    ../configure  -opensource    -ccache  -no-reduce-exports  -no-reduce-relocations  -gui -widgets  -c++std c++17  -static -shared  -xcb -inotify  -sqlite -sql-sqlite  -sql-psql    -force-debug-info
    

    But after more than an hour computer time running time nohup nice make -j15 the build finally fails with

    make[3]: Entering directory '/usr/src/X11/qt5/_Build/qtwebengine/src/process'
    /usr/src/X11/qt5/_Build/qtbase/bin/qmake -o Makefile /usr/src/X11/qt5/qtwebengine/src/process/process.pro
    CCACHE_SLOPPINESS="pch_defines,time_macros${CCACHE_SLOPPINESS+,$CCACHE_SLOPPINESS}" CCACHE_CPP2=true ccache g++ -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../lib -Wl,-rpath-link,/usr/src/X11/qt5/_Build/qtwebengine/lib -o ../../libexec/QtWebEngineProcess .obj/main.o   /usr/src/X11/qt5/_Build/qtbase/lib/libQt5Gui.so /usr/src/X11/qt5/_Build/qtbase/lib/libQt5Core.so -lGL -lpthread /usr/src/X11/qt5/_Build/qtwebengine/lib/libQt5WebEngineCore.so /usr/src/X11/qt5/_Build/qtdeclarative/lib/libQt5Quick.so /usr/src/X11/qt5/_Build/qtdeclarative/lib/libQt5QmlModels.so /usr/src/X11/qt5/_Build/qtwebchannel/lib/libQt5WebChannel.so /usr/src/X11/qt5/_Build/qtdeclarative/lib/libQt5Qml.so /usr/src/X11/qt5/_Build/qtbase/lib/libQt5Network.so /usr/src/X11/qt5/_Build/qtbase/lib/libQt5Gui.so /usr/src/X11/qt5/_Build/qtlocation/lib/libQt5Positioning.so /usr/src/X11/qt5/_Build/qtbase/lib/libQt5Core.so  
    /usr/bin/ld: .obj/main.o: in function `main':
    /usr/src/X11/qt5/qtwebengine/src/process/main.cpp:130: undefined reference to `QtWebEngineCore::processMain(int, char const**)'
    collect2: error: ld returned 1 exit status
    make[3]: *** [Makefile:72: ../../libexec/QtWebEngineProcess] Error 1
    make[3]: Leaving directory '/usr/src/X11/qt5/_Build/qtwebengine/src/process'
    make[2]: *** [Makefile:103: sub-process-make_first] Error 2
    make[2]: Leaving directory '/usr/src/X11/qt5/_Build/qtwebengine/src'
    make[1]: *** [Makefile:49: sub-src-make_first] Error 2
    make[1]: Leaving directory '/usr/src/X11/qt5/_Build/qtwebengine'
    make: *** [Makefile:1089: module-qtwebengine-make_first] Error 2
    make  288.24s user 22.58s system 103% cpu 5:01.52 total
    

    with in the source tree, for what it is worth:

               
    rimski.x86_64 src/X11/qt5 15:03 .0 % pwd
    /usr/src/X11/qt5
    rimski.x86_64 src/X11/qt5 15:03 .0 % git status 
    On branch 5.14
    Your branch is up to date with 'origin/5.14'.
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    	_Build/
    
    nothing added to commit but untracked files present (use "git add" to track)
    git status  3.79s user 3.00s system 103% cpu 6.549 total
    rimski.x86_64 src/X11/qt5 15:03 .0 % git log -2
    commit ac8b28db576356431a1a414b2c08b2eb09c8b898 (HEAD -> 5.14, origin/5.14)
    Author: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
    Date:   Fri Apr 24 09:47:55 2020 +0200
    
        Update submodules on '5.14' in qt/qt5
        
        Change-Id: I919625c0e3a2fdd5dea9dab691c9bc96f62161fa
        Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
    
    commit 882294edc3b142151eea2933f77ed59110222877
    Merge: 10e07c78 2e7ba38d
    Author: Liang Qi <liang.qi@qt.io>
    Date:   Thu Apr 23 12:27:46 2020 +0200
    
        Merge remote-tracking branch 'origin/5.14.2' into 5.14
        
         Conflicts:
                .gitmodules
        
        Change-Id: I950588f85d1b39ba6ce994821db9f340b72fa6d2
    
    rimski.x86_64 src/X11/qt5 15:03 .0 % cat .git/config 
    [core]
    	repositoryformatversion = 0
    	filemode = true
    	bare = false
    	logallrefupdates = true
    [remote "origin"]
    	url = git://code.qt.io/qt/qt5.git
    	fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "dev"]
    	remote = origin
    	merge = refs/heads/dev
    [branch "5.14"]
    	remote = origin
    	merge = refs/heads/5.14
    [submodule "qt3d"]
    	active = true
    	url = git://code.qt.io/qt/qt3d.git
    [submodule "qtactiveqt"]
    	active = true
    	url = git://code.qt.io/qt/qtactiveqt.git
    [submodule "qtandroidextras"]
    	active = true
    	url = git://code.qt.io/qt/qtandroidextras.git
    [submodule "qtbase"]
    	active = true
    	url = git://code.qt.io/qt/qtbase.git
    [submodule "qtcharts"]
    	active = true
    	url = git://code.qt.io/qt/qtcharts.git
    [submodule "qtconnectivity"]
    	active = true
    	url = git://code.qt.io/qt/qtconnectivity.git
    [submodule "qtdatavis3d"]
    	active = true
    	url = git://code.qt.io/qt/qtdatavis3d.git
    [submodule "qtdeclarative"]
    	active = true
    	url = git://code.qt.io/qt/qtdeclarative.git
    [submodule "qtdoc"]
    	active = true
    	url = git://code.qt.io/qt/qtdoc.git
    [submodule "qtgamepad"]
    	active = true
    	url = git://code.qt.io/qt/qtgamepad.git
    [submodule "qtgraphicaleffects"]
    	active = true
    	url = git://code.qt.io/qt/qtgraphicaleffects.git
    [submodule "qtimageformats"]
    	active = true
    	url = git://code.qt.io/qt/qtimageformats.git
    [submodule "qtlocation"]
    	active = true
    	url = git://code.qt.io/qt/qtlocation.git
    [submodule "qtlottie"]
    	active = true
    	url = git://code.qt.io/qt/qtlottie.git
    [submodule "qtmacextras"]
    	active = true
    	url = git://code.qt.io/qt/qtmacextras.git
    [submodule "qtmultimedia"]
    	active = true
    	url = git://code.qt.io/qt/qtmultimedia.git
    [submodule "qtnetworkauth"]
    	active = true
    	url = git://code.qt.io/qt/qtnetworkauth.git
    [submodule "qtpurchasing"]
    	active = true
    	url = git://code.qt.io/qt/qtpurchasing.git
    [submodule "qtqa"]
    	active = true
    	url = git://code.qt.io/qt/qtqa.git
    [submodule "qtquick3d"]
    	active = true
    	url = git://code.qt.io/qt/qtquick3d.git
    [submodule "qtquickcontrols"]
    	active = true
    	url = git://code.qt.io/qt/qtquickcontrols.git
    [submodule "qtquickcontrols2"]
    	active = true
    	url = git://code.qt.io/qt/qtquickcontrols2.git
    [submodule "qtquicktimeline"]
    	active = true
    	url = git://code.qt.io/qt/qtquicktimeline
    [submodule "qtremoteobjects"]
    	active = true
    	url = git://code.qt.io/qt/qtremoteobjects.git
    [submodule "qtrepotools"]
    	active = true
    	url = git://code.qt.io/qt/qtrepotools.git
    [submodule "qtscript"]
    	active = true
    	url = git://code.qt.io/qt/qtscript.git
    [submodule "qtscxml"]
    	active = true
    	url = git://code.qt.io/qt/qtscxml.git
    [submodule "qtsensors"]
    	active = true
    	url = git://code.qt.io/qt/qtsensors.git
    [submodule "qtserialbus"]
    	active = true
    	url = git://code.qt.io/qt/qtserialbus.git
    [submodule "qtserialport"]
    	active = true
    	url = git://code.qt.io/qt/qtserialport.git
    [submodule "qtspeech"]
    	active = true
    	url = git://code.qt.io/qt/qtspeech.git
    [submodule "qtsvg"]
    	active = true
    	url = git://code.qt.io/qt/qtsvg.git
    [submodule "qttools"]
    	active = true
    	url = git://code.qt.io/qt/qttools.git
    [submodule "qttranslations"]
    	active = true
    	url = git://code.qt.io/qt/qttranslations.git
    [submodule "qtvirtualkeyboard"]
    	active = true
    	url = git://code.qt.io/qt/qtvirtualkeyboard.git
    [submodule "qtwayland"]
    	active = true
    	url = git://code.qt.io/qt/qtwayland.git
    [submodule "qtwebchannel"]
    	active = true
    	url = git://code.qt.io/qt/qtwebchannel.git
    [submodule "qtwebengine"]
    	active = true
    	url = git://code.qt.io/qt/qtwebengine.git
    [submodule "qtwebglplugin"]
    	active = true
    	url = git://code.qt.io/qt/qtwebglplugin.git
    [submodule "qtwebsockets"]
    	active = true
    	url = git://code.qt.io/qt/qtwebsockets.git
    [submodule "qtwebview"]
    	active = true
    	url = git://code.qt.io/qt/qtwebview.git
    [submodule "qtwinextras"]
    	active = true
    	url = git://code.qt.io/qt/qtwinextras.git
    [submodule "qtx11extras"]
    	active = true
    	url = git://code.qt.io/qt/qtx11extras.git
    [submodule "qtxmlpatterns"]
    	active = true
    	url = git://code.qt.io/qt/qtxmlpatterns.git
    [commit]
    	template = /usr/src/X11/qt5/.commit-template
    [remote "gerrit"]
    	url = ssh://codereview.qt-project.org/qt/qt5
    	fetch = +refs/heads/*:refs/remotes/gerrit/*
    
    

    Reported https://bugreports.qt.io/browse/QTBUG-84159

    Regards

    --
    Basile Starynkevitch, near Paris, France
    http://starynkevitch.net/Basile/index_en.html
    basile@starynkevitch.net


  • Lifetime Qt Champion

    Hi,

    From the top of my head, you should check the mkspec you use to build Qt.

    As for webengine, just don't build it if you don't use. Two reasons: it's super heavy and IIRC chromium does not support static build.

    In the absolute, you should start with building only qtbase and then the other modules you might need. You'll avoid having to wait the time needed to build things you don't use.


Log in to reply