https://bugs.kde.org/show_bug.cgi?id=527117

            Bug ID: 527117
           Summary: Build fails with LTO due to ODR violations and lto
                    type mismatch
    Classification: Frameworks and Libraries
           Product: frameworks-kauth
      Version First 6.29.0
       Reported In:
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 197124
  --> https://bugs.kde.org/attachment.cgi?id=197124&action=edit
/var/log/portage/build/kde-frameworks/kauth-6.29.0:20261015-141648.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 Undefined Behavior (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:
```
FAILED: [code=1] bin/FdHelper 
: && /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -pipe -march=native
-fstack-protector-all -O3 -fdiagnostics-color=always -frecord-gcc-switches
-freport-bug -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 -Werror=undef -Wvla -Wdate-time
-Wsuggest-override -Wlogical-op -pedantic -Wzero-as-null-pointer-constant
-Wmissing-include-dirs -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 -fdiagnostics-color=always
-Wl,--defsym=__gentoo_check_ldflags__=0
autotests/CMakeFiles/FdHelper.dir/FdHelper_autogen/mocs_compilation.cpp.o
autotests/CMakeFiles/FdHelper.dir/FdHelper.cpp.o -o bin/FdHelper 
lib/libkauth_tests_static.a  /usr/lib64/libQt6Gui.so.6.11.2 
/usr/lib64/libGLX.so  /usr/lib64/libOpenGL.so 
/usr/lib64/libKF6CoreAddons.so.6.29.0  /usr/lib64/libQt6DBus.so.6.11.2 
/usr/lib64/libQt6Core.so.6.11.2 && :
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/src/BackendsManager.h:17:24:
error: type ‘struct BackendsManager’ violates the C++ One Definition Rule
[-Werror=odr]
   17 | class KAUTHCORE_EXPORT BackendsManager
      |                        ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/autotests/BackendsManager.h:15:7:
note: a different type is defined in another translation unit
   15 | class BackendsManager
      |       ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/src/BackendsManager.h:31:18:
note: the first difference of corresponding definitions is field ‘helper’
   31 |     HelperProxy *helper = nullptr;
      |                  ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/autotests/BackendsManager.h:29:37:
note: a field with different name is defined in another translation unit
   29 |     QHash<QThread *, HelperProxy *> proxiesForThreads;
      |                                     ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/src/BackendsManager.h:24:18:
error: type of ‘authBackend’ does not match original declaration
[-Werror=lto-type-mismatch]
   24 |     AuthBackend *authBackend();
      |                  ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/autotests/BackendsManager.cpp:48:14:
note: ‘authBackend’ was previously declared here
   48 | AuthBackend *BackendsManager::authBackend()
      |              ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/autotests/BackendsManager.cpp:48:14:
note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/src/BackendsManager.h:25:18:
error: type of ‘helperProxy’ does not match original declaration
[-Werror=lto-type-mismatch]
   25 |     HelperProxy *helperProxy();
      |                  ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/autotests/BackendsManager.cpp:57:14:
note: ‘helperProxy’ was previously declared here
   57 | HelperProxy *BackendsManager::helperProxy()
      |              ^
/var/tmp/portage/kde-frameworks/kauth-6.29.0/work/kauth-6.29.0/autotests/BackendsManager.cpp:57:14:
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/x86_64-pc-linux-gnu/binutils-bin/2.46.1/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
```



SOFTWARE/OS VERSIONS
Operating System: Gentoo Linux 2.18
KDE Plasma Version: 6.7.5
KDE Frameworks Version: 6.29.0
Qt Version: 6.11.2

ADDITIONAL INFORMATION

Originally reported downstream: https://bugs.gentoo.org/973328
Full build log attached.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to