Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 902777 - dev-debug/gdb-13.1-r1: undefined reference to `__atomic_fetch_add_4' on MIPS (/usr/lib/gcc/mips-unknown-linux-gnu/12/include/g++-v12/ext/atomicity.h:66: more undefined references to `__atomic_fetch_add_4' follow)
Summary: dev-debug/gdb-13.1-r1: undefined reference to `__atomic_fetch_add_4' on MIPS ...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: MIPS Linux
: Normal major (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: libatomic-linking
  Show dependency tree
 
Reported: 2023-03-23 03:36 UTC by BRULE Herman
Modified: 2024-01-13 11:00 UTC (History)
1 user (show)

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


Attachments
build.log (build.log,410.29 KB, text/x-log)
2023-03-23 04:58 UTC, BRULE Herman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description BRULE Herman 2023-03-23 03:36:56 UTC
undefined reference to `__atomic_fetch_add_4' on MIPS

Reproducible: Always

Steps to Reproduce:
1.try compile gdb on MIPS from last stage

Actual Results:  
fail with undefined reference to `__atomic_fetch_add_4'

Expected Results:  
compile well

Portage 3.0.45.3 (python 3.10.10-final-0, default/linux/mips/17.0/o32, gcc-12, glibc-2.36-r7, 4.19.0-21-4kc-malta mips)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.19.0-21-4kc-malta-mips-MIPS_24Kc_V0.0_FPU_V0.0-with-glibc2.36
KiB Mem:      248648 total,     36268 free
KiB Swap:    2097148 total,   2092696 free
Timestamp of repository gentoo: Tue, 21 Mar 2023 02:30:01 +0000
Head commit of repository gentoo: 77dcc89a0820ea54319aec1149cc0883c8f5e340
sh bash 5.2_p15-r2
ld GNU ld (Gentoo 2.40 p3) 2.40.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p15-r2::gentoo
dev-lang/perl:             5.36.0-r2::gentoo
dev-lang/python:           3.10.10_p2::gentoo, 3.11.2_p1::gentoo
dev-util/meson:            1.0.1::gentoo
sys-apps/baselayout:       2.13-r1::gentoo
sys-apps/openrc:           0.46::gentoo
sys-apps/sandbox:          2.30-r1::gentoo
sys-devel/autoconf:        2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.40-r3::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/gcc:             12.2.1_p20230304::gentoo
sys-devel/gcc-config:      2.10::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/make:            4.4.1::gentoo
sys-kernel/linux-headers:  6.2::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r7::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-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 

ACCEPT_KEYWORDS="mips ~mips"
ACCEPT_LICENSE="@FREE"
CBUILD="mips-unknown-linux-gnu"
CFLAGS="-O2 -march=mips1 -mabi=32 -mno-plt -mno-llsc -mno-unaligned-access -g"
CHOST="mips-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=mips1 -mabi=32 -mno-plt -mno-llsc -mno-unaligned-access -g"
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="-O2 -march=mips1 -mabi=32 -mno-plt -mno-llsc -mno-unaligned-access -g"
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 preserve-libs protect-owned qa-unresolved-soname-deps sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -march=mips1 -mabi=32 -mno-plt -mno-llsc -mno-unaligned-access -g"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
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="acl big-endian bzip2 cli crypt gdbm iconv ipv6 libglvnd mips ncurses nls nptl pam pcre readline seccomp split-usr ssl test-rust unicode xattr zlib" ABI_MIPS="o32" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby27 ruby30" USERLAND="GNU" VIDEO_CARDS="fbdev impact dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
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, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-23 04:00:34 UTC
Please always include the full build.log.
Comment 2 BRULE Herman 2023-03-23 04:58:43 UTC
Created attachment 858663 [details]
build.log
Comment 3 Gordon Bos 2023-04-09 11:59:25 UTC
This is a returning issue. I got met with it this week on dev-util/apr and www-servers/apache.

To try overcome the issue I added LDFLAGS="${LDFLAGS} -Wl,--as-needed -latomic" in the package environment but that results in the following link line failing:

================================================
 armv5tel-softfloat-linux-gnueabi-gcc -O2 -pipe -march=armv5te -Wl,-O1 -o ab ab.o  -Wl,--as-needed //usr/lib/gcc/armv5tel-softfloat-linux-gnueabi/12/libatomic.so -Wl,--no-as-needed -laprutil-1 -lgdbm -lapr-1 -lm -lssl -lcrypto -pthread -Wl,-rpath -Wl,//usr/lib/gcc/armv5tel-softfloat-linux-gnueabi/12
/usr/lib/gcc/armv5tel-softfloat-linux-gnueabi/12/../../../../armv5tel-softfloat-linux-gnueabi/bin/ld: /usr/lib/gcc/armv5tel-softfloat-linux-gnueabi/12/../../../libapr-1.so: undefined reference to `__atomic_exchange_8'
...
collect2: error: ld returned 1 exit status
================================================

* Note that '-latomic' gets translated to the actual path of libatomic.so

It is apparent that the order of definitions is important, because what does work is when '-Wl,--as-needed -latomic' is added to the end of the line, i.e.:

================================================
 armv5tel-softfloat-linux-gnueabi-gcc -O2 -pipe -march=armv5te -Wl,-O1 -o ab ab.o  -Wl,--as-needed //usr/lib/gcc/armv5tel-softfloat-linux-gnueabi/12/libatomic.so -Wl,--no-as-needed -laprutil-1 -lgdbm -lapr-1 -lm -lssl -lcrypto -pthread -Wl,-rpath -Wl,//usr/lib/gcc/armv5tel-softfloat-linux-gnueabi/12 -Wl,--as-needed -latomic
================================================

So I tried various combinations of forcing libatomic into the build through LDFLAGS but it turns out that libtool even overrides '-Wl,--no-as-needed' and due to the order of processing gcc considers libatomic in the resulting link command as not needed and the build still requires libatomic to be added manually to complete it after going bust.