Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 646234 - dev-libs/boost-1.65.0: missing linkage to libatomic on sparc (undefined reference to `__atomic_fetch_sub_4')
Summary: dev-libs/boost-1.65.0: missing linkage to libatomic on sparc (undefined refer...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: Sparc64 Linux
: Normal normal (vote)
Assignee: C++ Team [disbanded]
Depends on:
Blocks: 544378 644808
  Show dependency tree
Reported: 2018-01-31 19:11 UTC by Rolf Eike Beer
Modified: 2018-09-16 21:28 UTC (History)
2 users (show)

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

build.log (dev-libs_boost-1.65.0_use_ZmDAF,526.02 KB, application/octet-stream)
2018-01-31 19:11 UTC, Rolf Eike Beer

Note You need to log in before you can comment on or make changes to this bug.
Description Rolf Eike Beer archtester 2018-01-31 19:11:30 UTC
Created attachment 517286 [details]

This is no new problem, I have seen it before with Boost on sparc but forgot to report. Until now I have not seen it when building sparc, but only when linking other things to sparc.

Portage 2.3.19 (python 3.5.4-final-0, default/linux/sparc/17.0, gcc-6.4.0, glibc-2.25-r9, 4.14.14 sparc64)
System uname: Linux-4.14.14-sparc64-sun4v-with-gentoo-2.3
KiB Mem:    33133552 total,  16703336 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Wed, 31 Jan 2018 01:15:01 +0000
Head commit of repository gentoo: 6f3d79acd554da6385348b94032f35730b1c64c6
sh bash 4.4_p12
ld GNU ld (Gentoo 2.29.1 p3) 2.29.1
app-shells/bash:          4.4_p12::gentoo
dev-lang/perl:            5.24.3::gentoo
dev-lang/python:          2.7.14-r1::gentoo, 3.4.5-r1::gentoo, 3.5.4-r1::gentoo, 3.6.3-r1::gentoo
dev-util/cmake:           3.9.6::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.34.11::gentoo
sys-apps/sandbox:         2.12::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r2::gentoo, 1.13.4-r1::gentoo, 1.15.1-r1::gentoo
sys-devel/binutils:       2.29.1-r1::gentoo
sys-devel/gcc:            6.4.0-r1::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.13::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r9::gentoo

    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://
    priority: -1000

CFLAGS="-O2 -mcpu=niagara2 -pipe"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/spool/torque"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.1/ext-active/ /etc/php/cgi-php7.1/ext-active/ /etc/php/cli-php7.1/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -mcpu=niagara2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
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"
USE="acl berkdb big-endian bzip2 cli crypt cxx dri fortran gdbm iconv ipv6 modules ncurses nls nptl openmp pam pcre readline sparc ssl tcpd unicode xattr zlib" 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="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_5" RUBY_TARGETS="ruby22 ruby23" USERLAND="GNU" VIDEO_CARDS="fbdev glint mach64 mga r128 radeon sunbw2 suncg14 suncg3 suncg6 sunffb sunleo dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Comment 1 Rolf Eike Beer archtester 2018-03-31 08:24:13 UTC
Also affects 1.63.0.
Comment 2 Rolf Eike Beer archtester 2018-07-18 15:23:02 UTC
The problem is tools/build/src/tools/gcc.{py,jam}: here Boost tries to guess which CPU it has to use and adds a -mcpu flag for it. It does not know about anything newer than ultrasparc3 (like my niagara2), so it adds it's default: v7. That one has only byte-wise atomics, so int-wise things wont work with that instruction set. It's end up calling this:

"sparc-unknown-linux-gnu-g++"   -O2 -mcpu=niagara2 -pipe -std=c++14 -finline-functions -Wno-inline -Wall -mcpu=v7 -pthread -m32  -DBOO ...

I have no idea why it does all this cpu detection, I think entirely removing it would do no harm (at least not on sparc).
Comment 3 Rolf Eike Beer archtester 2018-07-19 19:15:19 UTC
I meanwhile managed to get it working. All you need to do is to remove the "default=True" from /usr/share/boost-build/tools/ and " : default" from /usr/share/boost-build/tools/gcc.jam (no idea which one is the right one, I just did both). This causes the build system to not add "-mcpu=v7" when it can't determine the CPU. This also affects x86 as the only other arch:

/usr/share/boost-build/tools/'gcc', 'OPTIONS', 'x86', 'i686', ['-march=i686'], default=True)

The setting for sparc is entirely bogus: v7 is the gcc default anyway, and all CPUs since 1995 (!) are v9 ones. So I guess these default settings should just be removed, at least in Gentoo, but probably just upstream.
Comment 4 Larry the Git Cow gentoo-dev 2018-09-16 21:28:48 UTC
The bug has been closed via the following commit(s):

commit 68b4b694543cddeb2f33115f5581403d1187fe3f
Author:     Rolf Eike Beer <>
AuthorDate: 2018-09-07 18:57:31 +0000
Commit:     Sergei Trofimovich <>
CommitDate: 2018-09-16 21:28:40 +0000

    dev-util/boost-build: add patch to unbreak compiler options on sparc
    Boost tries to autodetect the processor architecture and overrides any flags
    set with CXXFLAGS with the -mcpu value it thinks it is appropiate. Sadly the
    most recent architecture it knows of is ultrasparc3. For every newer cpu type
    it falls back to it's default, which is v7 (which would be the compiler default
    anyway). This avoids any advanced cpu instructions, e.g. those that support
    atomic operations on thing larger than a byte. Remove the whole outdated cruft
    and just use whatever the user passed in.
    Signed-off-by: Sergei Trofimovich <>
    Package-Manager: Portage-2.3.40, Repoman-2.3.9

 dev-util/boost-build/boost-build-1.62.0-r1.ebuild  |  1 +
 dev-util/boost-build/boost-build-1.63.0.ebuild     |  1 +
 dev-util/boost-build/boost-build-1.65.0.ebuild     |  1 +
 dev-util/boost-build/boost-build-1.66.0.ebuild     |  1 +
 dev-util/boost-build/boost-build-1.67.0.ebuild     |  1 +
 ...boost-build-1.62.0-sparc-no-default-flags.patch | 47 ++++++++++++++++++++++
 6 files changed, 52 insertions(+)