Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 923112 - sys-libs/libstdc++-v3 doesn't build
Summary: sys-libs/libstdc++-v3 doesn't build
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2024-01-28 10:34 UTC by stefan11111
Modified: 2024-03-27 18:07 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,19.25 KB, text/x-log)
2024-01-28 10:34 UTC, stefan11111
Details
build.log.unoptimized (build.log.unoptimized.xz,147.07 KB, application/x-xz)
2024-01-28 15:30 UTC, stefan11111
Details
build.log.flto (build.log.flto,19.25 KB, application/octet-stream)
2024-01-28 15:31 UTC, stefan11111
Details
config logs (gcc.tar,20.00 KB, application/x-tar)
2024-02-03 08:39 UTC, stefan11111
Details

Note You need to log in before you can comment on or make changes to this bug.
Description stefan11111 2024-01-28 10:34:22 UTC
Created attachment 883423 [details]
build.log

Build fails in the configure phase:

checking byte ordering... unknown
configure: error: *** unable to determine endianness
Configure in /var/tmp/portage/sys-libs/libstdc++-v3-3.3.6-r4/work/build/gcc failed, exiting.


emerge --info

Portage 3.0.61 (python 3.12.1-final-0, default/linux/amd64/17.1, gcc-13, glibc-2.38-r9, 6.6.9-gentoo x86_64)
=================================================================
System uname: Linux-6.6.9-gentoo-x86_64-Intel-R-_Core-TM-_i5-7400_CPU_@_3.00GHz-with-glibc2.38
KiB Mem:     8123216 total,    287140 free
KiB Swap:   16777212 total,  14579196 free
Timestamp of repository gentoo: Sat, 27 Jan 2024 21:30:01 +0000
Head commit of repository gentoo: 102c2f5b2beaf5374cf9b510d9adb7abaa21a5b4
Head commit of repository gentoo-static: fbaa062b86d01c107c589eb9ab0dd82b264f7164

Timestamp of repository guru: Sat, 27 Jan 2024 17:35:16 +0000
Head commit of repository guru: 8fed0852166136b43380c168b3892795b3445285

Timestamp of repository khoverlay: Sat, 27 Jan 2024 17:35:13 +0000
Head commit of repository khoverlay: 5d1b3a49ce4000a42e141098ce7c1e37d61ab19a

Timestamp of repository libressl: Sat, 27 Jan 2024 17:35:02 +0000
Head commit of repository libressl: f54d6e1caad910fcedd087fc3f5c808f5b281b25

Head commit of repository librewolf: 2e7225f295e1c6fda913be45be6111ba26149a39

Timestamp of repository palemoon: Sat, 27 Jan 2024 17:35:04 +0000
Head commit of repository palemoon: afef13c449eec1deeb3d02f45d0a383a1672d396

Timestamp of repository steam-overlay: Sat, 27 Jan 2024 17:35:06 +0000
Head commit of repository steam-overlay: 840da74af43f8c072ac373ceab331f3afa246bec

Head commit of repository stefan_overlay: 7c5393a5aee2356557eb3aa87fe9b3f8ec1b4764

sh bash 5.2_p26
ld GNU ld (Gentoo 2.41 p5) 2.41.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p26::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.16.5-r1::gentoo
dev-build/cmake:           3.28.1-r1::gentoo
dev-build/libtool:         2.4.7-r2::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.3.1-r1::gentoo
dev-lang/perl:             5.38.2-r1::gentoo
dev-lang/python:           2.7.18_p16-r1::libressl, 3.12.1_p1::libressl
sys-apps/baselayout:       2.14-r1::gentoo
sys-apps/openrc:           0.53::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/binutils:        2.41-r5::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/gcc:             13.2.1_p20240113-r1::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-kernel/linux-headers:  6.7::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r9::gentoo
sys-libs/libselinux:       3.6::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 
    sync-rsync-verify-max-age: 24

gentoo-static
    location: /var/db/repos/gentoo-static
    sync-type: git
    sync-uri: https://github.com/NeddySeagoon/gentoo-static.git
    masters: gentoo
    volatile: False

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo
    volatile: False

khoverlay
    location: /var/db/repos/khoverlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/khoverlay.git
    masters: gentoo
    volatile: False

libressl
    location: /var/db/repos/libressl
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/libressl.git
    masters: gentoo
    volatile: False

librewolf
    location: /var/db/repos/librewolf
    sync-type: git
    sync-uri: https://codeberg.org/librewolf/gentoo.git
    masters: gentoo
    volatile: False

palemoon
    location: /var/db/repos/palemoon
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/palemoon.git
    masters: gentoo
    volatile: False

steam-overlay
    location: /var/db/repos/steam-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/steam-overlay.git
    masters: gentoo
    volatile: False

stefan_overlay
    location: /var/db/repos/stefan_overlay
    sync-type: git
    sync-uri: https://github.com/stefan11111/stefan_overlay.git
    masters: gentoo
    volatile: False

Binary Repositories:

binhost
    priority: 9999
    sync-uri: https://mirror.bytemark.co.uk/gentoo/releases/amd64/binpackages/17.1/x86-64

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O3 -pipe -march=native -fno-stack-protector -ftree-vectorize -ffast-math -funswitch-loops -fuse-linker-plugin -flto -fdevirtualize-at-ltrans -fno-plt -fno-semantic-interposition -falign-functions=64 -fgraphite-identity -floop-nest-optimize"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O3 -pipe -march=native -fno-stack-protector -ftree-vectorize -ffast-math -funswitch-loops -fuse-linker-plugin -flto -fdevirtualize-at-ltrans -fno-plt -fno-semantic-interposition -falign-functions=64 -fgraphite-identity -floop-nest-optimize"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O3 -pipe -march=native -fno-stack-protector -ftree-vectorize -ffast-math -funswitch-loops -fuse-linker-plugin -flto -fdevirtualize-at-ltrans -fno-plt -fno-semantic-interposition -falign-functions=64 -fgraphite-identity -floop-nest-optimize"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O3 -pipe -march=native -fno-stack-protector -ftree-vectorize -ffast-math -funswitch-loops -fuse-linker-plugin -flto -fdevirtualize-at-ltrans -fno-plt -fno-semantic-interposition -falign-functions=64 -fgraphite-identity -floop-nest-optimize"
GENTOO_MIRRORS="http://ftp.romnet.org/gentoo/ http://mirrors.xservers.ro/gentoo/ http://bloodnoc.org/~roy/olde-distfiles/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--sort-common"
LEX="flex"
MAKEOPTS="-j4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X alsa amd64 asm custom-cflags git grub ipv6 jit jumbo-build libressl lto man minimal native-symlinks olde-gentoo rsync-verify split-usr ssl strip system-man test-rust threads verify-sig" ABI_X86="64" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="libressl" ELIBC="glibc" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="mouse keyboard" KERNEL="linux" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby31" VIDEO_CARDS="nvidia"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 stefan11111 2024-01-28 11:33:54 UTC
Seems like this is a bigger problem that just -flto.
It fails to build even with CFLAGS="" CXXFLAGS=""

The way to build was to put: 

CFLAGS="-O3 -pipe -march=native"
CXXFLAGS="-O3 -pipe -march=native"

in /etc/portage/env/sys-libs/libstdc++-v3.

And to put this patch:

--- a/gcc/cp/except.c   2024-01-28 13:17:40.624860056 +0200
+++ b/gcc/cp/except.c   2024-01-28 13:18:00.367901034 +0200
@@ -890,8 +890,7 @@
     /* Can't be a C library function.  */
     return 0;

-  id = DECL_ASSEMBLER_NAME (fn);
-  return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
+  return 1;
 }

 /* Returns nonzero if an exception of type FROM will be caught by a

in /etc/portage/patches/sys-libs/libstdc++-v3.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-28 15:04:42 UTC
(In reply to stefan11111 from comment #1)
> Seems like this is a bigger problem that just -flto.
> It fails to build even with CFLAGS="" CXXFLAGS=""
> 

That is usually expected to fail because of no optimisation. Would help to see the log.
Comment 3 stefan11111 2024-01-28 15:30:33 UTC
Created attachment 883458 [details]
build.log.unoptimized
Comment 4 stefan11111 2024-01-28 15:31:22 UTC
Created attachment 883459 [details]
build.log.flto
Comment 5 stefan11111 2024-01-28 15:32:56 UTC
(In reply to Sam James from comment #2)
> (In reply to stefan11111 from comment #1)
> > Seems like this is a bigger problem that just -flto.
> > It fails to build even with CFLAGS="" CXXFLAGS=""
> > 
> 
> That is usually expected to fail because of no optimisation. Would help to
> see the log.

Didn't think that something could fail to build because of too little optimization.

Seems like it does build correctly with:

CFLAGS="-O3 -pipe -march=native"
CXXFLAGS="-O3 -pipe -march=native"

even without patching.
Comment 6 Arsen Arsenović gentoo-dev 2024-01-30 02:33:10 UTC
the compiler is highly restrained when not optimizing..

why are you building this, btw?
Comment 7 stefan11111 2024-01-30 05:49:51 UTC
(In reply to Arsen Arsenović from comment #6)
> the compiler is highly restrained when not optimizing..
> 
> why are you building this, btw?

https://github.com/anyc/steam-overlay/issues/354
Comment 8 Arsen Arsenović gentoo-dev 2024-01-31 16:27:25 UTC
can you post the config.log(s)?
Comment 9 stefan11111 2024-02-03 08:39:58 UTC
Created attachment 884078 [details]
config logs

Configure logs
Comment 10 James Le Cuirot gentoo-dev 2024-02-13 22:51:23 UTC
The endianness test fails because it's looking for an "endian:" string in conftest.o that isn't there when using -flto. There are instances of this issue in other projects. You can either perform the link by changing -c to -shared or you can add the -ffat-lto-objects flag. You don't want to do the latter everywhere though. Need to find out how best to fix it in this case.
Comment 11 James Le Cuirot gentoo-dev 2024-02-17 15:55:49 UTC
I found that the only sane way to do this is to just patch gcc/configure to add -ffat-lto-objects to ac_compile for this specific test. Presumably we don't care about also patching configure.in, which isn't really viable in this case.

Once you fix that, you have to do the same thing for the floating point format test immediately afterwards.

It's all for nothing though because xgcc eventually fails because it doesn't understand -flto. We have previously stripped out new flags for this reason, but this one probably has the greatest potential impact on performance.

Even if we just strip out -flto entirely, configure dies almost immediately with GCC 14. :(
Comment 12 Enne Eziarc 2024-03-27 18:07:09 UTC
-flto is just a symptom of a bigger problem. I was about to report a nearly identical bug for "-mno-omit-leaf-frame-pointer" and found a few dozen more.

So I went and looked into it and the package is using flag-o-matic as a source of truth, i.e. anything the *host* CC thinks is valid gets passed to gcc-3.3.6, minus a very short hand-picked list of exclusions. So that's obviously wrong, and it's only going to be whack-a-mole until the end of time as new C compilers add new switches. There's no reasonable way to work around that to do the right thing either - you'd have to stop the build between stage 1 and 2, find the xgcc binary, re-test the current cflags against it, then resume the build. I've looked at the option-parsing code in gcc itself and trying to extract valid flags from there is completely out of the question.

There *is* a static list of valid options in the tarball though: the manpage.
Do a `grep -o ' "\(-[^=, ]*\)"' "${S}"/gcc/doc/gcc.1 | sort -u` and it pulls out a list of 955 flags that don't take params. That might be a good starting point, and it's not going to change in future.

(Yeah, this doesn't magically make LTO work, but this is a compatibility lib for 20 year old binaries. My 24-core desktop isn't exactly struggling to run UT2004 for lack of it.)