Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with LTO #222

Open
eli-schwartz opened this issue May 6, 2024 · 0 comments
Open

Build fails with LTO #222

eli-schwartz opened this issue May 6, 2024 · 0 comments

Comments

@eli-schwartz
Copy link

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:

x86_64-pc-linux-gnu-g++ src/HexEditorGui.o src/FAL.o src/HexDialogs.o src/HexPanels.o src/HexEditorApp.o src/HexEditor.o src/HexEditorCtrl/HexEditorCtrl.o src/HexEditorCtrl/wxHexCtrl/TagDialogGui.o src/HexEditorCtrl/wxHexCtrl/wxHexCtrl.o src/HexEditorCtrl/wxHexCtrl/Tag.o src/HexEditorCtrl/HexEditorCtrlGui.o src/HexEditorFrame.o -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -fopenmp -lgomp -ludis86 -lmhash -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  `wx-config --libs` `wx-config --libs aui` `wx-config --libs core` -o wxHexEditor
src/HexEditorFrame.h:65:7: error: type ‘struct HexEditorFrame’ violates the C++ One Definition Rule [-Werror=odr]
   65 | class HexEditorFrame : public HexEditorGui {
      |       ^
src/HexEditorFrame.h:65:7: note: a different type is defined in another translation unit
   65 | class HexEditorFrame : public HexEditorGui {
      |       ^
src/HexEditorFrame.h:97:31: note: the first difference of corresponding definitions is field ‘MyAUI’
   97 |                 wxAuiManager *MyAUI;
      |                               ^
src/HexEditorFrame.h:74:38: note: a field with different name is defined in another translation unit
   74 |                 wxFileSystemWatcher *file_watcher;
      |                                      ^
src/HexEditorFrame.h:72:34: error: type of ‘GetActiveHexEditor’ does not match original declaration [-Werror=lto-type-mismatch]
   72 |                 class HexEditor* GetActiveHexEditor(void);
      |                                  ^
src/HexEditorFrame.cpp:505:12: note: ‘GetActiveHexEditor’ was previously declared here
  505 | HexEditor* HexEditorFrame::GetActiveHexEditor( void ){
      |            ^
src/HexEditorFrame.cpp:505:12: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
src/HexEditorFrame.h:71:34: error: type of ‘OpenFile’ does not match original declaration [-Werror=lto-type-mismatch]
   71 |                 class HexEditor* OpenFile(wxFileName flname, bool openAtRight=false);
      |                                  ^
src/HexEditorFrame.cpp:445:12: note: ‘OpenFile’ was previously declared here
  445 | HexEditor* HexEditorFrame::OpenFile(wxFileName filename, bool openAtRight){
      |            ^
src/HexEditorFrame.cpp:445:12: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: 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
make: *** [Makefile:55: wxHexEditor] Error 1

Downstream report: https://bugs.gentoo.org/854414
Full build log: build.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant