InBetweenNames / gentooLTO

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

x11-libs/libX11-1.6.8::gentoo ld.bfd no lto causes problems #399

Closed javashin closed 5 years ago

javashin commented 5 years ago

I Recompiled x11-libs/libX11 with this >>>

x11-libs/libX11-1.6.8::gentoo was built with the following: CFLAGS="-march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fuse-ld=bfd -O3 -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,--hash-style=gnu" CXXFLAGS="-march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fuse-ld=bfd -O3 -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,--hash-style=gnu"

and causes firefox To Segfault , Xorg-server Dont Found The Modules , intel ddx and modesetting wont start up the X , and more problems .

Before Was Set to :::::

CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe"

if i recompile back to ^^^^^^ ld.gold and flto firefox works fine and xorg works too , someone can tell me wha is the problem ?

do i need to rebuild world to use ld.bfd for everything ?

javashin commented 5 years ago

firefox Segmentation fault (core dumped)

javashin commented 5 years ago

[ 780.470] (EE) Failed to load /usr/lib64/xorg/modules/drivers/modesetting_drv.so: /usr/lib64/xorg/modules/drivers/modesetting_drv.so: undefined symbol: shadowRemove

[ 613.055] (EE) Failed to load /usr/lib64/xorg/modules/drivers/intel_drv.so: /usr/lib64/xorg/modules/drivers/intel_drv.so: undefined symbol: vgaHWFreeHWRec

jiblime commented 5 years ago

I'm starting to think having ssp would be a good way to prevent UB when using aggressive optimizations. How should debugging this be handled? Could have more symbols to get a better debug understanding and even more LTO opportunity (nostrip comes to mind) but it already feels like the performance to security ratio is becoming off balance. Perhaps a set of -Wflags to monitor and -fmax-errors=n?

Edit: Gold does a better job at linking and I do use it from time to time, but I still worry enough to have BFD as my default. I've read that long ago you could append -r to get more symbols so that it can link correctly.

ionenwks commented 5 years ago

May or may not be related... Been a while since I used -fno-plt but I recall it broke xorg modules (like -z now breaks them, they need lazy bindings to work last I know of), even if manage to compile I'm pretty sure it's a bad idea to use it on anything xorg-anything (or at least anything that build modules). Could be affecting libX11 under certain conditions, maybe try to rebuild xorg-server without it?

They're apparently working on making -z now work (which would make -fno-plt safe): https://gitlab.freedesktop.org/xorg/xserver/issues/692

Possible that it works fine under certain configurations though (seeing the overlay doesn't have an override for it, I assume it does).

Edit: Oh and also remove -z now to test since you seem to have it in there as well -- though I have no idea if you used anything different for xorg-server already.

javashin commented 5 years ago

x11-base/xorg-server-1.20.5::gentoo was built with the following: USE="glamor ipv6 suid systemd udev wayland xorg xvfb -debug -dmx -doc (-elogind) -kdrive -libressl -minimal (-selinux) -static-libs -unwind -xcsecurity -xephyr -xnest" ABI_X86="(64)" CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -mxsave -pipe -Wl,-O2 -Wl,--as-needed,-z,now -fuse-ld=gold -Wl,--hash-style=gnu" CXXFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -mxsave -pipe -Wl,-O2 -Wl,--as-needed,-z,now -fuse-ld=gold -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O2 -Wl,--as-needed,-z,now -fuse-ld=gold -Wl,--hash-style=gnu -O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -mxsave -pipe -Wl,-z,lazy"

-Wl,-z,lazy was added automatically by the ebuild

maybe is that ^^

because libX11 DONT x11-libs/libX11-1.6.8::gentoo was built with the following: USE="ipv6 -doc -static-libs -test" ABI_X86="32 (64) (-x32)" CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -flimit-function-alignment -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -fomit-frame-pointer -fno-strict-aliasing -fopenmp-simd -ftree-parallelize-loops=4 -pipe -Wl,-O2 -Wl,--as-needed,-z,now -fuse-ld=gold -Wl,--hash-style=gnu" CXXFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -flimit-function-alignment -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -fomit-frame-pointer -fno-strict-aliasing -fopenmp-simd -ftree-parallelize-loops=4 -pipe -Wl,-O2 -Wl,--as-needed,-z,now -fuse-ld=gold -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O2 -Wl,--as-needed,-z,now -fuse-ld=gold -Wl,--hash-style=gnu -O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -flimit-function-alignment -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -fomit-frame-pointer -fno-strict-aliasing -fopenmp-simd -ftree-parallelize-loops=4 -pipe"

javashin commented 5 years ago

LTO + BFD works x11-base/xorg-server-1.20.5::gentoo was built with the following: USE="glamor ipv6 suid systemd udev wayland xorg xvfb -debug -dmx -doc (-elogind) -kdrive -libressl -minimal (-selinux) -static-libs -unwind -xcsecurity -xephyr -xnest" ABI_X86="(64)" CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" CXXFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu -O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-z,lazy"

x11-libs/libX11-1.6.8::gentoo was built with the following: USE="ipv6 -doc -static-libs -test" ABI_X86="32 (64) (-x32)" CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" CXXFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu -O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=3 -fuse-linker-plugin -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-stack-protector -pipe"

adding -Wl,-z,lazy

javashin commented 5 years ago

OK this ALSO works NO LTO + BFD x11-base/xorg-server-1.20.5::gentoo was built with the following: USE="glamor ipv6 suid systemd udev wayland xorg xvfb -debug -dmx -doc (-elogind) -kdrive -libressl -minimal (-selinux) -static-libs -unwind -xcsecurity -xephyr -xnest" ABI_X86="(64)" CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-strict-aliasing -fomit-frame-pointer -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" CXXFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-strict-aliasing -fomit-frame-pointer -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu -Wl,-z,lazy"

x11-libs/libX11-1.6.8::gentoo was built with the following: USE="ipv6 -doc -static-libs -test" ABI_X86="32 (64) (-x32)" CFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-strict-aliasing -fomit-frame-pointer -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" CXXFLAGS="-O3 -march=native -mfpmath=both -funroll-loops -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -fipa-pta -fno-plt -fno-math-errno -fno-trapping-math -fdevirtualize-at-ltrans -fno-strict-aliasing -fomit-frame-pointer -fno-stack-protector -pipe -Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O2 -Wl,--as-needed,-z,now -Wl,-z,lazy -fuse-ld=bfd -Wl,--hash-style=gnu"

Thanks For the tip @ionenwks
Closing now , solved !