Summary: | sys-devel/clang-7.0.0 fails to build on MacOS: "ld: library not found for -latomic" | ||
---|---|---|---|
Product: | Gentoo/Alt | Reporter: | Jonathan Lovelace <kingjon3377> |
Component: | Mac OSX | Assignee: | Gentoo Prefix <prefix> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jstein, llvm, mgorny, toolchain, tsjk |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | OS X | ||
URL: | https://reviews.llvm.org/D56061 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
build.log.gz
llvm and clang build logs, llvm/lib/cmake directory /etc/portage/patches/sys-devel/clang/0001-clangd-Fix-detecting-atomics-in-stand-alone-builds.patch |
Description
Jonathan Lovelace
2018-09-24 21:53:18 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? Created attachment 548238 [details]
build.log.gz
Build log now attached. No, libatomic_ops is not installed.
for some reason libatomic is used, while it should use compiler-rt IMO 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. 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? I'd rather like to look why it's happening first. I'll try to find some time over the weekend. 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? yes that's exactly what I did locally 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. (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. 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. 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.
Ping. Do you need any help here? I'd really like to apply the workaround for the time being. 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. 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.
I can confirm the patch allows to build 7.0.1 I've submitted it for upstream review. Once I commit it, I'll backport the final version to Gentoo. 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(+) |