Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 667016 - sys-devel/clang-7.0.0 fails to build on MacOS: "ld: library not found for -latomic"
Summary: sys-devel/clang-7.0.0 fails to build on MacOS: "ld: library not found for -la...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Mac OSX (show other bugs)
Hardware: All OS X
: Normal normal
Assignee: Gentoo Prefix
URL: https://reviews.llvm.org/D56061
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-24 21:53 UTC by Jonathan Lovelace
Modified: 2019-01-03 18:37 UTC (History)
5 users (show)

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


Attachments
build.log.gz (build.log.gz,52.89 KB, application/x-gzip)
2018-09-29 16:01 UTC, Jonathan Lovelace
Details
llvm and clang build logs, llvm/lib/cmake directory (clang-7-build.tar.xz,165.75 KB, application/x-xz)
2018-12-12 19:29 UTC, Fabian Groffen
Details
/etc/portage/patches/sys-devel/clang/0001-clangd-Fix-detecting-atomics-in-stand-alone-builds.patch (0001-clangd-Fix-detecting-atomics-in-stand-alone-builds.patch,788 bytes, patch)
2018-12-23 14:02 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Lovelace 2018-09-24 21:53:18 UTC
In my Prefix installation under Mac OS Sierra, =dev-lang/clang-7.0.0 fails to build with the error "ld: library not found for -latomic". This was when trying to build lib/libclangDaemon.dylib , and that is the first mention of libatomic in the log file. (FWIW, "locate libatomic" only turns up Portage-tree files and a Homebrew formula for libatomic_ops.)

emerge --info:
Portage 2.3.40.3-prefix (python 3.6.5-final-0, prefix/darwin/macos/10.12/x64, [unavailable], unavailable, 16.7.0 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Darwin-16.7.0-x86_64-i386-64bit
Timestamp of repository gentoo_prefix: Mon, 24 Sep 2018 00:56:29 +0000
Head commit of repository gentoo_prefix: bd7f60f003cb9e5c3c8198df92a88ced4a43877c
sh bash 4.3_p48-r1
app-shells/bash:    4.3_p48-r1::gentoo_prefix
dev-lang/perl:      5.26.2::gentoo_prefix
dev-lang/python:    2.7.14-r2::gentoo_prefix, 3.6.5-r1::gentoo_prefix
dev-util/cmake:     3.12.2::gentoo_prefix
dev-util/pkgconfig: 0.29.2::gentoo_prefix
sys-devel/autoconf: 2.69-r4::gentoo_prefix
sys-devel/automake: 1.16.1-r1::gentoo_prefix
sys-devel/libtool:  2.4.6-r5::gentoo_prefix
sys-devel/make:     4.2.1-r4::gentoo_prefix
Repositories:

gentoo_prefix
    location: /Users/kingjon/Gentoo/usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 

localoverlay_prefix
    location: /Users/kingjon/Gentoo/usr/local/portage
    masters: gentoo_prefix

ACCEPT_KEYWORDS="~x64-macos"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-apple-darwin16"
CC="x86_64-apple-darwin16-clang"
CFLAGS="-march=native -O2 -pipe -march=native"
CHOST="x86_64-apple-darwin16"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CXX="x86_64-apple-darwin16-clang++"
CXXFLAGS="-march=native -O2 -pipe -march=native"
DISTDIR="/Users/kingjon/Gentoo/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--autounmask-keep-masks=y --complete-graph --with-bdeps=y"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS=""
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles force-prefix merge-sync multilib-strict news nostrip parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans unprivileged"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-dead_strip_dylibs"
MAKEOPTS="-j2"
PKGDIR="/Users/kingjon/Gentoo/usr/portage/packages"
PORTAGE_CONFIGROOT="/Users/kingjon/Gentoo/"
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="/Users/kingjon/Gentoo/var/tmp"
USE="aqua coreaudio cxx ipv6 mmx mmxext modules ncurses nls objc objc++ prefix prefix-guest readline sse sse2 sse3 sse4_1 ssl ssse3 unicode x64-macos zlib" ABI_X86="64" 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 plan sheets stage words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 ssse3" ELIBC="Darwin" 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="keyboard mouse" KERNEL="Darwin" 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 postgres10" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby24" USERLAND="GNU" 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"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

sys-devel/clang-6.0.1::gentoo_prefix was built with the following:
USE="(prefix) (prefix-guest) static-analyzer -debug -default-compiler-rt -default-libcxx -doc -test -xml (-z3)" LLVM_TARGETS="BPF (X86) -AArch64 -AMDGPU -ARM -Hexagon -Lanai -MSP430 -Mips -NVPTX -PowerPC -Sparc -SystemZ -XCore" PYTHON_TARGETS="python2_7"


sys-devel/llvm-6.0.1-r1::gentoo_prefix was built with the following:
USE="libffi ncurses (prefix) (prefix-guest) -debug -doc -gold -libedit -test -xar -xml" LLVM_TARGETS="BPF (X86) -AArch64 -AMDGPU -ARM -Hexagon -Lanai -MSP430 -Mips -NVPTX -PowerPC -Sparc -SystemZ -XCore"


sys-devel/llvm-7.0.0::gentoo_prefix was built with the following:
USE="libffi ncurses (prefix) (prefix-guest) -debug -doc -exegesis -gold -libedit -test -xar -xml" LLVM_TARGETS="BPF (X86) -AArch64 -AMDGPU -ARM -Hexagon -Lanai -MSP430 -Mips -NVPTX -PowerPC -Sparc -SystemZ -XCore"
Comment 1 Jonas Stein gentoo-dev 2018-09-29 13:10:16 UTC
Thank you for the report. Please recompile and 
*attach* the logfiles and 
paste the emerge info as described on
https://wiki.gentoo.org/wiki/Attach_the_logs_to_the_bug_ticket
The logs must be part of the ticket, but not on external websites.
We need to have all information at hand before ticket assignment, so that the maintainer can look after it in one session with minimal number of callbacks.
Please reopen this ticket (Status:unconfirmed) afterwards.

Is dev-libs/libatomic_ops installed?
Comment 2 Jonathan Lovelace 2018-09-29 16:01:40 UTC
Created attachment 548238 [details]
build.log.gz

Build log now attached. No, libatomic_ops is not installed.
Comment 3 Fabian Groffen gentoo-dev 2018-11-28 09:30:35 UTC
for some reason libatomic is used, while it should use compiler-rt IMO
Comment 4 Fabian Groffen gentoo-dev 2018-11-28 14:15:26 UTC
It appears as if HAVE_CXX_ATOMICS64_WITHOUT_LIB is never set such that -latomic is always added to flags.  If I set it myself

mycmakeargs+=(
        "-DHAVE_CXX_ATOMICS64_WITHOUT_LIB:BOOL=TRUE"
)

I can build clang-7.0.0 just fine.
Comment 5 Fabian Groffen gentoo-dev 2018-11-29 09:06:20 UTC
I think the problem is that CheckAtomic.cmake is somehow not around in the clang ebuild.

@llvm: this is probably only a problem for Darwin, are you ok with working around this problem with the define from comment #4 conditionalised for Darwin?
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-11-29 17:10:23 UTC
I'd rather like to look why it's happening first. I'll try to find some time over the weekend.
Comment 7 Tamas Jantvik 2018-11-30 12:13:29 UTC
So, if I understand this correctly, a temporary workaround would be to patch the ebuild, like for example:


--- clang-7.0.0.ebuild.orig     2018-11-30 13:10:39.000000000 +0100
+++ clang-7.0.0.ebuild  2018-11-30 13:07:34.000000000 +0100
@@ -181,6 +181,12 @@
                )
        fi

+       if [[ ${CHOST} == *-darwin* ]] ; then
+               mycmakeargs+=(
+                       -DHAVE_CXX_ATOMICS64_WITHOUT_LIB:BOOL=TRUE
+               )
+       fi
+
        if [[ -n ${EPREFIX} ]]; then
                mycmakeargs+=(
                        -DGCC_INSTALL_PREFIX="${EPREFIX}/usr"


Right?
Comment 8 Fabian Groffen gentoo-dev 2018-11-30 12:46:14 UTC
yes that's exactly what I did locally
Comment 9 Tamas Jantvik 2018-11-30 13:17:09 UTC
Yes, ok, that did work. However, my bootstapping choked on sys-libs/compiler-rt-sanitizers-7.0.0 afterwards (macos 10.11). Guess that's another bug, however.
Comment 10 Fabian Groffen gentoo-dev 2018-12-06 10:12:39 UTC
(In reply to Michał Górny from comment #6)
> I'd rather like to look why it's happening first. I'll try to find some time
> over the weekend.

Michał, did you have some time to look at this?  I'd like to apply the workaround for the time being since every mac user runs into this problem.
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-12-08 14:07:55 UTC
Could you also include the build log for LLVM?  I think it's not passing something from LLVM to Clang but I don't get where it gets -latomic from.  Also .tar with your /usr/lib/llvm/7/lib*/cmake.
Comment 12 Fabian Groffen gentoo-dev 2018-12-12 19:29:29 UTC
Created attachment 557688 [details]
llvm and clang build logs, llvm/lib/cmake directory

Here you go.  I left the machine in this state, so I can provide other things easily if necessary.
Comment 13 Fabian Groffen gentoo-dev 2018-12-23 11:31:11 UTC
Ping.  Do you need any help here?  I'd really like to apply the workaround for the time being.
Comment 14 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-12-23 13:55:43 UTC
Ok, I finally found the culprit.  It's in clang-tools-extra repository; that's why I haven't been able to find it.  I'll attach a patch for testing in a few minutes.
Comment 15 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-12-23 14:02:20 UTC
Created attachment 558406 [details, diff]
/etc/portage/patches/sys-devel/clang/0001-clangd-Fix-detecting-atomics-in-stand-alone-builds.patch

Please test the attached patch to sys-devel/clang.  It's suitable for using as user patch.
Comment 16 Fabian Groffen gentoo-dev 2018-12-23 19:26:52 UTC
I can confirm the patch allows to build 7.0.1
Comment 17 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-12-23 20:06:27 UTC
I've submitted it for upstream review.  Once I commit it, I'll backport the final version to Gentoo.
Comment 18 Larry the Git Cow gentoo-dev 2019-01-03 18:37:20 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1393d91fc66fd5afad091e408fbadf5bab514678

commit 1393d91fc66fd5afad091e408fbadf5bab514678
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2019-01-03 18:36:29 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2019-01-03 18:37:12 +0000

    sys-devel/clang: Backport atomic detection fix
    
    Closes: https://bugs.gentoo.org/667016
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 sys-devel/clang/clang-7.0.1.ebuild                 |  4 +++
 ...x-detecting-atomics-in-stand-alone-builds.patch | 38 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)