InBetweenNames / gentooLTO

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

sys-apps/attr-2.4.48-r3: building with -flto cripples the system #268

Open jelinekto opened 5 years ago

jelinekto commented 5 years ago

This one is particularly nasty since it prevents even emerge from functioning (see the example log). And in general destroys everything, e.g. cp -a now results in terminated by signal SIGSEGV (Address boundary error). LTO is the one to blame as the problem is present after building with plain -march=native -O2 -flto -pipe.

See also related Gentoo bug #644048.

emerge-fail.log emerge-info.txt

EDIT: It's worth pointing out this issue isn't caused by ld.gold, the ebuild now forces ld.bfd.

InBetweenNames commented 5 years ago

Strange -- I've built this package a number of times without running into this. Can anyone else confirm issues with sys-apps/attr? As noted, on my system ld.bfd is enforced for this package.

gcs-github commented 5 years ago

I have encountered the following situation as described in comments on the Gentoo bug:

LTO:
readelf -sW lib64/libattr.so.1 | grep getxattr
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lgetxattr@GLIBC_2.3 (8)
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fgetxattr@GLIBC_2.3 (8)
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getxattr@GLIBC_2.3 (8)
    49: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  ABS lgetxattr@ATTR_1.0
    53: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  ABS getxattr@ATTR_1.0
    65: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  ABS fgetxattr@ATTR_1.0

NO-LTO:
readelf -sW lib64/libattr.so.1 | grep getxattr
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lgetxattr@GLIBC_2.3 (8)
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fgetxattr@GLIBC_2.3 (8)
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getxattr@GLIBC_2.3 (8)
    49: 00000000000000b0     0 FUNC    GLOBAL DEFAULT  ABS lgetxattr@ATTR_1.0
    53: 0000000000000090     0 FUNC    GLOBAL DEFAULT  ABS getxattr@ATTR_1.0
    65: 00000000000000d0     0 FUNC    GLOBAL DEFAULT  ABS fgetxattr@ATTR_1.0

but I haven't personally experienced nefarious side-effects as a result. I'm also able to compile wpa_supplicant despite this.

Note: I'm on a hardened profile, which imposes building position-independent executables by default. Relocation errors as described early on the Gentoo bug comments are therefore probably less likely to be a problem.

javashin commented 5 years ago

sys-apps/attr-2.4.48-r3::gentoo was built with the following: USE="nls -debug -static-libs" ABI_X86="32 (64) (-x32)" CFLAGS="-march=native -mfpmath=both -funroll-loops -floop-block -floop-interchange -floop-strip-mine -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=4 -fuse-linker-plugin -pipe -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" CXXFLAGS="-march=native -mfpmath=both -funroll-loops -floop-block -floop-interchange -floop-strip-mine -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=4 -fuse-linker-plugin -pipe -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -march=native -mfpmath=both -funroll-loops -floop-block -floop-interchange -floop-strip-mine -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=4 -fuse-linker-plugin -pipe -fuse-ld=bfd -fuse-ld=bfd"

and i have no problems

gcs-github commented 5 years ago

~Considering that we're not reproducing, can you try building attr with more conservative CFLAGS, such as just "${FLTO} ${GRAPHITE} -O3 -pipe -march=native" ? You seem to have some "extreme" flags such as ${FASTMATH} and a few others that are less common than the ones we seem to be running here. Just to eliminate the possibility that they might be the ones messing with your build.~

Sorry, just realized you tried that already.

wolfwood commented 5 years ago

I've masked >=sys-apps/attr-2.4.48-r2

the mask file is named gold, so I may have tested it with bfd and it worked?

if you are going to mess around with this it's a good idea to download (and extract) the binary package for your version of attr and leave a root privileged shell open running busybox. that way you can recover without a liveCD

On Wed, Apr 3, 2019, 16:41 javashin notifications@github.com wrote:

USE="nls -debug -static-libs" ABI_X86="32 (64) (-x32)" CFLAGS="-march=native -mfpmath=both -funroll-loops -floop-block -floop-interchange -floop-strip-mine -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=4 -fuse-linker-plugin -pipe -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" CXXFLAGS="-march=native -mfpmath=both -funroll-loops -floop-block -floop-interchange -floop-strip-mine -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=4 -fuse-linker-plugin -pipe -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -march=native -mfpmath=both -funroll-loops -floop-block -floop-interchange -floop-strip-mine -falign-functions=32 -O3 -fgraphite-identity -floop-nest-optimize -fno-semantic-interposition -flto=4 -fuse-linker-plugin -pipe -fuse-ld=bfd -fuse-ld=bfd"

and i have no problems

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/InBetweenNames/gentooLTO/issues/268#issuecomment-479696745, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB74uMVjzGPV4FA4ERtf-EY8rqZ3s-Yks5vdTw-gaJpZM4cZHd- .

wolfwood commented 5 years ago

https://forums.gentoo.org/viewtopic-p-8168196.html describes the problem and links to this binary package for rescue: http://packages.gentooexperimental.org/packages/amd64-unstable/sys-apps/attr-2.4.47-r2.tbz2

InBetweenNames commented 5 years ago

Just to be on the safe side, I'll merge the related PR for this.