Created attachment 173264 [details] Full build log I tried to build with the following *FLAGS to optimize the build: `-flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing` Link-Time Optimization is a massively global compiler optimization pass which is pretty handy for producing faster executables. It also has the interesting property that because the compiler does whole-program analysis using bytecode, it can save type information and perform error checks that it normally doesn’t have enough insight for. In particular, checking for ODR issues and checking function type signature mismatches. Note that *all* the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error. I got this error: ``` [411/412] : && /usr/bin/x86_64-pc-linux-gnu-g++ -pipe -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -fno-operator-names -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Werror=init-self -Wvla -Wdate-time -Wsuggest-override -Wlogical-op -fdiagnostics-color=always -Wl,--enable-new-dtags -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 tests/CMakeFiles/k3bexternalbinmanagertest.dir/k3bexternalbinmanagertest_autogen/mocs_compilation.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/k3bexternalbinmanagertest.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/stub-k3bapplication.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bburnprogressdialog.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bdebuggingoutputdialog.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bemptydiscwaiter.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bjobinterface.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bdebuggingoutputcache.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bthememanager.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bthemedlabel.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bdebuggingoutputfile.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bjobprogressdialog.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/k3bjobinterfaceadaptor.cpp.o -o bin/k3bexternalbinmanagertest -Wl,-rpath,/var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0_build/bin /usr/lib64/libQt6Test.so.6.7.2 /usr/lib64/libKF6Notifications.so.6.5.0 bin/libk3blib.so.8.0.0 bin/libk3bdevice.so.8.0.0 /usr/lib64/libKF6Completion.so.6.5.0 /usr/lib64/libKF6KCMUtils.so.6.5.0 /usr/lib64/libKF6XmlGui.so.6.5.0 /usr/lib64/libKF6IconThemes.so.6.5.0 /usr/lib64/libKF6ConfigWidgets.so.6.5.0 /usr/lib64/libKF6WidgetsAddons.so.6.5.0 /usr/lib64/libKF6ColorScheme.so.6.5.0 /usr/lib64/libKF6KCMUtilsQuick.so.6.5.0 /usr/lib64/libKF6KCMUtilsCore.so.6.5.0 /usr/lib64/libQt6Qml.so.6.7.2 /usr/lib64/libQt6QmlBuiltins.a /usr/lib64/libQt6Widgets.so.6.7.2 /usr/lib64/libKF6KIOCore.so.6.5.0 /usr/lib64/libKF6I18n.so.6.5.0 /usr/lib64/libKF6Service.so.6.5.0 /usr/lib64/libQt6Xml.so.6.7.2 /usr/lib64/libKF6CoreAddons.so.6.5.0 /usr/lib64/libKF6ConfigGui.so.6.5.0 /usr/lib64/libKF6ConfigCore.so.6.5.0 /usr/lib64/libQt6Gui.so.6.7.2 /usr/lib64/libQt6DBus.so.6.7.2 /usr/lib64/libGLX.so /usr/lib64/libOpenGL.so /usr/lib64/libQt6Network.so.6.7.2 /usr/lib64/libQt6Core.so.6.7.2 && : FAILED: bin/k3bexternalbinmanagertest : && /usr/bin/x86_64-pc-linux-gnu-g++ -pipe -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -fno-operator-names -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Werror=init-self -Wvla -Wdate-time -Wsuggest-override -Wlogical-op -fdiagnostics-color=always -Wl,--enable-new-dtags -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 tests/CMakeFiles/k3bexternalbinmanagertest.dir/k3bexternalbinmanagertest_autogen/mocs_compilation.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/k3bexternalbinmanagertest.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/stub-k3bapplication.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bburnprogressdialog.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bdebuggingoutputdialog.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bemptydiscwaiter.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bjobinterface.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bdebuggingoutputcache.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bthememanager.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bthemedlabel.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bdebuggingoutputfile.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/__/src/k3bjobprogressdialog.cpp.o tests/CMakeFiles/k3bexternalbinmanagertest.dir/k3bjobinterfaceadaptor.cpp.o -o bin/k3bexternalbinmanagertest -Wl,-rpath,/var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0_build/bin /usr/lib64/libQt6Test.so.6.7.2 /usr/lib64/libKF6Notifications.so.6.5.0 bin/libk3blib.so.8.0.0 bin/libk3bdevice.so.8.0.0 /usr/lib64/libKF6Completion.so.6.5.0 /usr/lib64/libKF6KCMUtils.so.6.5.0 /usr/lib64/libKF6XmlGui.so.6.5.0 /usr/lib64/libKF6IconThemes.so.6.5.0 /usr/lib64/libKF6ConfigWidgets.so.6.5.0 /usr/lib64/libKF6WidgetsAddons.so.6.5.0 /usr/lib64/libKF6ColorScheme.so.6.5.0 /usr/lib64/libKF6KCMUtilsQuick.so.6.5.0 /usr/lib64/libKF6KCMUtilsCore.so.6.5.0 /usr/lib64/libQt6Qml.so.6.7.2 /usr/lib64/libQt6QmlBuiltins.a /usr/lib64/libQt6Widgets.so.6.7.2 /usr/lib64/libKF6KIOCore.so.6.5.0 /usr/lib64/libKF6I18n.so.6.5.0 /usr/lib64/libKF6Service.so.6.5.0 /usr/lib64/libQt6Xml.so.6.7.2 /usr/lib64/libKF6CoreAddons.so.6.5.0 /usr/lib64/libKF6ConfigGui.so.6.5.0 /usr/lib64/libKF6ConfigCore.so.6.5.0 /usr/lib64/libQt6Gui.so.6.7.2 /usr/lib64/libQt6DBus.so.6.7.2 /usr/lib64/libGLX.so /usr/lib64/libOpenGL.so /usr/lib64/libQt6Network.so.6.7.2 /usr/lib64/libQt6Core.so.6.7.2 && : /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/src/k3bapplication.h:29:11: error: type ‘struct Application’ violates the C++ One Definition Rule [-Werror=odr] 29 | class Application : public QApplication | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:12:11: note: a type with different bases is defined in another translation unit 12 | class Application | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/src/k3bapplication.h:58:24: error: type ‘struct Core’ violates the C++ One Definition Rule [-Werror=odr] 58 | class Application::Core : public K3b::Core | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:18:24: note: a different type is defined in another translation unit 18 | class Application::Core : public K3b::Core | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/src/k3bapplication.h:103:21: note: the first difference of corresponding definitions is field ‘m_mainWindow’ 103 | MainWindow* m_mainWindow; | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:18:24: note: a type with different number of fields is defined in another translation unit 18 | class Application::Core : public K3b::Core | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/src/k3bapplication.h:108:22: error: ‘s_k3bAppCore’ violates the C++ One Definition Rule [-Werror=odr] 108 | static Core* s_k3bAppCore; | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:18:24: note: type ‘struct Core’ itself violates the C++ One Definition Rule 18 | class Application::Core : public K3b::Core | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/src/k3bapplication.h:58:24: note: the incompatible type is defined here 58 | class Application::Core : public K3b::Core | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:34:25: note: ‘s_k3bAppCore’ was previously declared here 34 | K3b::Application::Core* K3b::Application::Core::s_k3bAppCore = 0; | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:34:25: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/src/k3bapplication.h:63:9: error: type of ‘__ct_comp ’ does not match original declaration [-Werror=lto-type-mismatch] 63 | Core( QObject* parent ); | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:36:1: note: implicit this pointer type mismatch 36 | K3b::Application::Core::Core( QObject* parent ) | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:18:24: note: type ‘struct Core’ itself violates the C++ One Definition Rule 18 | class Application::Core : public K3b::Core | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/src/k3bapplication.h:58:24: note: the incompatible type is defined here 58 | class Application::Core : public K3b::Core | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:36:1: note: ‘__ct_comp ’ was previously declared here 36 | K3b::Application::Core::Core( QObject* parent ) | ^ /var/tmp/portage/kde-apps/k3b-24.08.0/work/k3b-24.08.0/tests/stub-k3bapplication.cpp:36:1: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used lto1: some warnings being treated as errors lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status compilation terminated. /usr/libexec/gcc/x86_64-pc-linux-gnu/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status ``` Originally reported downstream: https://bugs.gentoo.org/924376 Attached is a full build log.