InBetweenNames / gentooLTO

A Gentoo Portage configuration for building with -O3, Graphite, and LTO optimizations
GNU General Public License v2.0
571 stars 96 forks source link

Problems with gcc9 #317

Open KlausMeier opened 5 years ago

KlausMeier commented 5 years ago

With gcc8 everything works fine for me. But after switching to gcc9 I had no problem to build the packages, but some packages crashed, when I start them. There was mpv, kodi and the plasma system settings. But I think, they crashed because of some libraries. I rebuild mpv with normal cflags, no difference. At the moment I try with -O2.

InBetweenNames commented 5 years ago

I actually just did a full system rebuild so I will try these packages ASAP.

KlausMeier commented 5 years ago

The problem is not the build, that works very well, you had to test every application. They crashed. And then I don't know, where is the reason. Because I rebuild mpv with standard flags but it crashed again with a memory access error.

pchome commented 5 years ago

@KlausMeier media-video/mpv is OK for me.

I usually don't do (read "never") full system rebuild after GCC upgrade, but only packages containing static libraries (similar to lto-rebuild). So mpv was last built a month ago using gcc8, rebuilt using gcc9 still OK.

media-video/mpv-0.29.1-r1::gentoo was built with the following:
USE="X alsa cli egl iconv jack jpeg lcms libass lua luajit openal opengl pulseaudio uchardet vdpau xv zlib (-aqua) -archive -bluray -cdda (-coreaudio) -cplugins -cuda -doc -drm -dvb -dvd -gbm -javascript -libcaca -libmpv -oss (-raspberry-pi) -rubberband -samba -sdl (-selinux) -test -tools -v4l -vaapi -vulkan -wayland -zsh-completion" ABI_X86="(64)" PYTHON_TARGETS="python2_7 python3_7 -python3_5 -python3_6"
CFLAGS="-march=native -O3 -pipe -fgraphite-identity -ftree-loop-distribution -floop-nest-optimize -fipa-pta -flto=3 -fuse-linker-plugin -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu"
CXXFLAGS="-march=native -O3 -pipe -fgraphite-identity -ftree-loop-distribution -floop-nest-optimize -fipa-pta -flto=3 -fuse-linker-plugin -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu"
KlausMeier commented 5 years ago

Yes, I told you, this is not a problem of mpv. I rebuild mpv with standard flags and it crashed again. But I told you three times, that it is not a problem of mpv but a problem of a library. And i don't know which library. mpv crashed, because I rebuild a library, that you don't rebuild.

InBetweenNames commented 5 years ago

I am getting a crash on systemsettings5 after the rebuild. I'll investigate that.

javashin commented 5 years ago

This Is Why I dont Built with ipa and no-plt and no others strange flags gcc 9.1 worked fine here but i rolled back to my backup with no ipa and no no-plt and fastmath i masked gcc 9.1 and everything works fine this way also i changed from ld.gold to bfd and compiled firefox with clang+pgo+lto+-O3 everything working fine

CC="gcc" CXX="g++" AR="gcc-ar" NM="gcc-nm" RANLIB="gcc-ranlib" STRIP="gcc-strip" LD="ld.bfd" CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fuse-ld=bfd -pipe" CXXFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fuse-ld=bfd -pipe" CPPFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fuse-ld=bfd -pipe" FFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fuse-ld=bfd -pipe" FCFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fuse-ld=bfd -pipe" F77FLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fuse-ld=bfd -pipe" LDFLAGS="-Wl,-O2 -Wl,--as-needed -Wl,--hash-style=gnu"

InBetweenNames commented 5 years ago

I don't see what any of that has to do with this.

InBetweenNames commented 5 years ago

Getting a:

Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)

Qt and systemsettings are compiled with GCC 9.1, -O2 -march=native -pipe only just to be sure. It may be a Qt bug.

InBetweenNames commented 5 years ago

My other KDE apps seem fine too

InBetweenNames commented 5 years ago

Updated Qt to 5.13.9999, problem does not seem present anymore!

Supded commented 5 years ago

FFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fuse-ld=bfd -pipe" Is that legit?

InBetweenNames commented 5 years ago

It's not a supported configuration, but it shouldn't break anything at least.

InBetweenNames commented 5 years ago

Update: Downgraded again to Qt 5.12.3, did a full rebuild of KDE. systemsettings5 problem is still resolved.

InBetweenNames commented 5 years ago

Kodi seems to work fine too.

InBetweenNames commented 5 years ago

@KlausMeier under what circumstances does mpv crash?

lferra commented 5 years ago

I am getting a crash on systemsettings5 after the rebuild. I'll investigate that.

After the switch had also a crash with systemsettings5, and as suggested I tried to rebuild qt packages, with no success. Attempting to build the packages in order to obtain meaningful debug info, I realized that in my case the culprit was kde-frameworks/kactivities-stats package build with -O3: overriding the flags with -O2 get rid of the problem.

KlausMeier commented 5 years ago

At the moment I rebuild my system step for step with CFLAGS="-march=native -O2 ${FLTO} -fuse-linker-plugin -ftree-vectorize -pipe" and mpv and kodi now works without any problem. But the plasma settings is still crashing.

InBetweenNames commented 5 years ago

You may have to rebuild KDE too. The crashes stopped after I fully rebuilt Qt and KDE.

KlausMeier commented 5 years ago

I rebuild frameworks, no I can use the settings.

InBetweenNames commented 5 years ago

Try rebuilding anything in kde-apps as well. It seems the problem went away when I upgraded to the Qt 5.13 beta, and it still remained fixed when I downgraded to 5.12.3. Both required a full rebuild of KDE.

ms178 commented 5 years ago

First, I am not on Gentoo but on Tumbleweed, but I've encountered similar symptoms as mentioned by the op while compiling the 32 bit build of Intel's Threading Building Blocks with GCC 9.1 and 10. The compilation itself is fine but as soon as I start the app where I use the binaries, it crashes back to desktop halfway through a loading screen. This is with the release build, the debug build runs fine. I had no such issues, even with the most aggressive compiler flags with GCC 8.3.1. More details here: https://github.com/intel/tbb/issues/145

If someone could replicate the issue or tell me what the problem is, that would already help.

funghetto commented 5 years ago

There seem to be issues with wine and gcc 9 too: https://bugs.winehq.org/show_bug.cgi?id=47167

pchome commented 5 years ago

Everybody aware, but for collection: bcache corruption bug https://bugzilla.kernel.org/show_bug.cgi?id=203573 https://bugzilla.redhat.com/show_bug.cgi?id=1708315

InBetweenNames commented 5 years ago

Hopefully those problems can be fixed in a point release of GCC.

Peter-Levine commented 5 years ago

I am getting a crash on systemsettings5 after the rebuild. I'll investigate that.

After the switch had also a crash with systemsettings5, and as suggested I tried to rebuild qt packages, with no success. Attempting to build the packages in order to obtain meaningful debug info, I realized that in my case the culprit was kde-frameworks/kactivities-stats package build with -O3: overriding the flags with -O2 get rid of the problem.

Yep. Building kde-frameworks/kactivities-stats with -O2 worked for me.

pchome commented 5 years ago

More GCC 9 problems ...

346

https://bugzilla.suse.com/show_bug.cgi?id=1137071#c11

There's self-contained test-case ```c char memory[128]; int main(int argc, char **argv) { const char *str; switch (argc) { case 1: str = (const char []){'C','h','a','i','n','i','n','g','M','o','d','e','E','C','B',0}; break; default: str = (const char []){'C','h','a','i','n','i','n','g','M','o','d','e','G','C','M',0}; break; } __builtin_memcpy(memory, str, __builtin_strlen (str) + 1); if (memory[14] != 'B') __builtin_abort (); return 0; } ```

https://www.gnu.org/software/gcc/gcc-9/porting_to.html#complit

Should we use -Werror=c90-c99-compat for GCC 9 to prevent such issues?

wine2.c: In function 'main':
wine2.c:9:28: error: ISO C90 forbids compound literals [-Werror=c90-c99-compat]
    9 |       str = (const char []){'C','h','a','i','n','i','n','g','M','o','d','e','E','C','B',0}; break;
      |                            ^
wine2.c:11:28: error: ISO C90 forbids compound literals [-Werror=c90-c99-compat]
   11 |       str = (const char []){'C','h','a','i','n','i','n','g','M','o','d','e','G','C','M',0}; break;
      |                            ^
cc1: some warnings being treated as errors

Otherwise it's pain in the ass.

EDIT: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89990

pchome commented 5 years ago

-fstack-reuse=none or -fsanitize-address-use-after-scope

InBetweenNames commented 5 years ago

It's tough, because -Werror=c90-c99-compat will also error out on code that could be perfectly fine. The issue looks like people were relying on a bug in GCC: https://www.gnu.org/software/gcc/gcc-9/porting_to.html#complit

When the GCC devs fixed the bug, the code written that depended on it working broke.

pchome commented 5 years ago

I currently testing -fstack-reuse=none in CFLAGS only. Cause using this I can compile and successfully run the above test.

"Possible performance hit" vs "possible data lose".

kanyck commented 4 years ago

I keep having internal compiler error: in record_target_from_binfo, at ipa-devirt.c:2667 when trying to build LibreOffice with GCC9. UPD: opened a new issue: https://github.com/InBetweenNames/gentooLTO/issues/448