Page MenuHome GnuPG

qgpgme-qt6: Build failure for some distributions
Closed, ResolvedPublic

Description

Many people build KDE projects and their dependencies have reported a build failure of qgpgme-qt6. Linking the tests fails:

/bin/sh ../../../libtool  --tag=CXX   --mode=link g++ -std=c++17  -g -O2 -Wall -Wextra -Wno-shadow -no-install  -o t-addexistingsubkey t-addexistingsubkey.o t-support.o ../../cpp/src/libgpgmepp.la ../src/libqgpgmeqt6.la ../../../src/libgpgme.la -lQt6Core  -lgpg-error -lQt6Test -lQt6Core  -Wl,--disable-new-dtags -lstdc++ 
mv -f .deps/t-revokekey.Tpo .deps/t-revokekey.Po
mv -f .deps/run-receivekeysjob.Tpo .deps/run-receivekeysjob.Po
/bin/sh ../../../libtool  --tag=CXX   --mode=link g++ -std=c++17  -g -O2 -Wall -Wextra -Wno-shadow -no-install  -o t-decryptverify t-decryptverify.o t-support.o ../../cpp/src/libgpgmepp.la ../src/libqgpgmeqt6.la ../../../src/libgpgme.la -lQt6Core  -lgpg-error -lQt6Test -lQt6Core  -Wl,--disable-new-dtags -lstdc++ 
/bin/sh ../../../libtool  --tag=CXX   --mode=link g++ -std=c++17  -g -O2 -Wall -Wextra -Wno-shadow -no-install  -o t-keylist t-keylist.o t-support.o  ../../cpp/src/libgpgmepp.la ../src/libqgpgmeqt6.la ../../../src/libgpgme.la -lQt6Core  -lgpg-error -lQt6Test -lQt6Core  -Wl,--disable-new-dtags -lstdc++ 
libtool: link: g++ -std=c++17 -g -O2 -Wall -Wextra -Wno-shadow -o t-keylist t-keylist.o t-support.o -Wl,--disable-new-dtags  ../../cpp/src/.libs/libgpgmepp.so ../src/.libs/libqgpgmeqt6.so ../../../src/.libs/libgpgme.so -lgpg-error -lQt6Test -lQt6Core -lstdc++ -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/cpp/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/qt/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/usr/lib
libtool: link: g++ -std=c++17 -g -O2 -Wall -Wextra -Wno-shadow -o t-addexistingsubkey t-addexistingsubkey.o t-support.o -Wl,--disable-new-dtags  ../../cpp/src/.libs/libgpgmepp.so ../src/.libs/libqgpgmeqt6.so ../../../src/.libs/libgpgme.so -lgpg-error -lQt6Test -lQt6Core -lstdc++ -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/cpp/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/qt/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/usr/lib
libtool: link: g++ -std=c++17 -g -O2 -Wall -Wextra -Wno-shadow -o t-decryptverify t-decryptverify.o t-support.o -Wl,--disable-new-dtags  ../../cpp/src/.libs/libgpgmepp.so ../src/.libs/libqgpgmeqt6.so ../../../src/.libs/libgpgme.so -lgpg-error -lQt6Test -lQt6Core -lstdc++ -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/cpp/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/qt/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/usr/lib
mv -f .deps/run-importjob.Tpo .deps/run-importjob.Po
/bin/sh ../../../libtool  --tag=CXX   --mode=link g++ -std=c++17  -g -O2 -Wall -Wextra -Wno-shadow -no-install  -o t-keylocate t-keylocate.o t-support.o ../../cpp/src/libgpgmepp.la ../src/libqgpgmeqt6.la ../../../src/libgpgme.la -lQt6Core  -lgpg-error -lQt6Test -lQt6Core  -Wl,--disable-new-dtags -lstdc++ 
libtool: link: g++ -std=c++17 -g -O2 -Wall -Wextra -Wno-shadow -o t-keylocate t-keylocate.o t-support.o -Wl,--disable-new-dtags  ../../cpp/src/.libs/libgpgmepp.so ../src/.libs/libqgpgmeqt6.so ../../../src/.libs/libgpgme.so -lgpg-error -lQt6Test -lQt6Core -lstdc++ -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/cpp/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/lang/qt/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/build/gpgme/src/.libs -Wl,-rpath -Wl,/home/shreevathsa/kde/usr/lib
/usr/bin/ld: t-keylocate.o: copy relocation against non-copyable protected symbol `_ZTV14QTestEventLoop@@Qt_6' in /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/libQt6Test.so
collect2: error: ld returned 1 exit status
/usr/bin/ld: t-support.o: copy relocation against non-copyable protected symbol `_ZTV14QTestEventLoop@@Qt_6' in /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/libQt6Test.so
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:951: t-keylocate] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: *** [Makefile:935: t-decryptverify] Error 1
/usr/bin/ld: t-addexistingsubkey.o: copy relocation against non-copyable protected symbol `_ZTV14QTestEventLoop@@Qt_6' in /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/libQt6Test.so
/usr/bin/ld: t-keylist.o: copy relocation against non-copyable protected symbol `_ZTV14QTestEventLoop@@Qt_6' in /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/libQt6Test.so
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:923: t-addexistingsubkey] Error 1
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:947: t-keylist] Error 1
mv -f .deps/run-refreshkeysjob.Tpo .deps/run-refreshkeysjob.Po
mv -f .deps/run-signarchivejob.Tpo .deps/run-signarchivejob.Po
make[4]: Leaving directory '/home/shreevathsa/kde/build/gpgme/lang/qt/tests'

This has been reported by people using Arch Linux.

Event Timeline

The official build for Arch Linux doesn't seem to run into this problem. The Qt6 build is configured with

./configure \
  --prefix=/usr \
  --disable-fd-passing \
  --disable-static \
  --disable-gpgsm-test \
  --enable-languages=cpp,qt6

See https://archlinux.org/packages/core/x86_64/gpgme/

Compiles for me, too with Qt 6.5.2 from tumbleweed.

So I think that the problem here is that ArchLinux either does not build Qt6 with -fPIC or it does and others don't and that our check for wether or not to add -fPIC is not really working as it should. When compiling executables we should also add -fPIE instead of -fPIC.

But my bet would be that it is not built with -fPIC, our test still thinks it works because the test is wrong and we add -fPIC to our QGpgME build when we should not add it. And then this failure occurs.

I found this in the change log of Qt 5.4.2:

- On x86 and x86-64 systems with ELF binaries (especially Linux), due to
  a new optimization in GCC 5.x in combination with a recent version of
  GNU binutils, compiling Qt applications with -fPIE is no longer
  enough with GCC 5.x. Applications now need to be compiled with
  the -fPIC option if Qt's option "reduce relocations" is active. For
  backward compatibility only, Qt accepts the use of -fPIE for GCC 4.x
  versions.
  Note that Clang is known to generate incompatible code even with -fPIC if
  the -flto option is active.

ArchLinux builds Qt without "reduce relocations" (because of https://bugreports.qt.io/browse/QTBUG-86173), but it seems to use LTO.
See https://archlinux.org/packages/extra/x86_64/qt5-base/

Well 5.4.2 o.O and we on Tumbleweed are at 13.x gcc

I would appreciate it if you would take this up and maybe ask for an arch linux user on kde-devel to test a fix. I really want to loose the image of "GpgME is blocking builds".

This is a Qt issue. Reported at https://bugreports.qt.io/browse/QTBUG-117398

That's good news. I suppose we still need to add a workaround, e.g. a configure switch to enable the -mno-direct-extern-access flag.

ikloecker added a project: Restricted Project.
ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
ikloecker changed the task status from Open to Testing.Sep 21 2023, 11:03 AM
ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.

The Qt 6 bindings will now be compiled with the -mno-direct-extern-access flag if --enable-no-direct-extern-access is passed to configure.

It would be great if people who can reproduce this problem could verify that enabling this configure option fixes the problem.

No need for QA on build issues.

Per IRC discussion, this could be autodetected in qt6.m4 by querying Qt6Platform.pc for mkspecsdir and grepping ${mkspecsdir}/qconfig.pri for QT_CONFIG.*no_direct_extern_access.

Attaching Arch's qconfig.pri

Relevant lines from Arch's qconfig.pri:

QT.global.enabled_features = shared pkg-config rpath reduce_relocations signaling_nan zstd thread future concurrent dbus openssl-linked opensslv30 shared shared rpath reduce_exports no_direct_extern_access reduce_relocations openssl
QT.global.disabled_features = static cross_compile debug_and_release separate_debug_info appstore-compliant simulator_and_device force_asserts framework c++20 c++2a c++2b c++2b wasm-simd128 wasm-exceptions opensslv11
QT.global.disabled_features += release build_all
QT_CONFIG += shared rpath reduce_exports no_direct_extern_access reduce_relocations openssl release
CONFIG +=  shared plugin_manifest
ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.

Re-open to add auto-detection.

ikloecker moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.