Bug 484572 - Build fails with LTO
Summary: Build fails with LTO
Status: REPORTED
Alias: None
Product: kst
Classification: Applications
Component: packaging (show other bugs)
Version: 2.0.8
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-27 05:22 UTC by Eli Schwartz
Modified: 2024-03-27 05:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Full build log (2.34 MB, text/x-log)
2024-03-27 05:22 UTC, Eli Schwartz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eli Schwartz 2024-03-27 05:22:18 UTC
Created attachment 167831 [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`

Note 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:
```
[1138/1138] : && /usr/bin/x86_64-pc-linux-gnu-g++ -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Wall -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0    -rdynamic src/kst/CMakeFiles/kst2.dir/main.cpp.o src/kst/CMakeFiles/kst2.dir/qrc_icons.cpp.o -o build/bin/kst2  -Wl,-rpath,/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8_build/build/lib64:  src/libkstapp/libkst2app.a  build/lib64/libkst2widgets.so.2.0.8  build/lib64/libkst2math.so.2.0.8  build/lib64/libkst2core.so.2.0.8  /usr/lib64/libQt5Xml.so.5.15.12  /usr/lib64/libQt5Network.so.5.15.12  /usr/lib64/libQt5PrintSupport.so.5.15.12  /usr/lib64/libQt5Widgets.so.5.15.12  /usr/lib64/libQt5Gui.so.5.15.12  /usr/lib64/libQt5Core.so.5.15.12 && :
FAILED: build/bin/kst2 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Wall -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0    -rdynamic src/kst/CMakeFiles/kst2.dir/main.cpp.o src/kst/CMakeFiles/kst2.dir/qrc_icons.cpp.o -o build/bin/kst2  -Wl,-rpath,/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8_build/build/lib64:  src/libkstapp/libkst2app.a  build/lib64/libkst2widgets.so.2.0.8  build/lib64/libkst2math.so.2.0.8  build/lib64/libkst2core.so.2.0.8  /usr/lib64/libQt5Xml.so.5.15.12  /usr/lib64/libQt5Network.so.5.15.12  /usr/lib64/libQt5PrintSupport.so.5.15.12  /usr/lib64/libQt5Widgets.so.5.15.12  /usr/lib64/libQt5Gui.so.5.15.12  /usr/lib64/libQt5Core.so.5.15.12 && :
/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8/src/libkstapp/mainwindow.h:53:7: error: type ‘struct MainWindow’ violates the C++ One Definition Rule [-Werror=odr]
   53 | class MainWindow : public QMainWindow
      |       ^
/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8/src/libkstapp/mainwindow.h:53:7: note: a different type is defined in another translation unit
   53 | class MainWindow : public QMainWindow
      |       ^
/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8/src/libkstapp/mainwindow.h:258:14: note: the first difference of corresponding definitions is field ‘_createSvgAct’
  258 |     QAction *_createSvgAct;
      |              ^
/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8/src/libkstapp/mainwindow.h:260:14: note: a field with different name is defined in another translation unit
  260 |     QAction *_createSharedAxisBoxAct;
      |              ^
/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8/src/libkstapp/mainwindow.h:64:10: error: type of ‘initFromCommandLine’ does not match original declaration [-Werror=lto-type-mismatch]
   64 |     bool initFromCommandLine();
      |          ^
/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8/src/libkstapp/mainwindow.cpp:431:6: note: ‘initFromCommandLine’ was previously declared here
  431 | bool MainWindow::initFromCommandLine() {
      |      ^
/var/tmp/portage/sci-visualization/kst-2.0.8-r2/work/Kst-2.0.8/src/libkstapp/mainwindow.cpp:431:6: 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/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
```

Originally reported downstream: https://bugs.gentoo.org/863296