Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 578064 - sys-devel/llvm-3.8.0: build fails on Gentoo/FreeBSD.
Summary: sys-devel/llvm-3.8.0: build fails on Gentoo/FreeBSD.
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All FreeBSD
: Normal normal (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-23 10:35 UTC by Yuta SATOH
Modified: 2016-06-23 16:08 UTC (History)
1 user (show)

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


Attachments
Log, fatal error: 'stdarg.h' file not found (578064_1.log,2.95 KB, text/plain)
2016-03-23 10:37 UTC, Yuta SATOH
Details
Log, error: 'stoull' is not a member of 'std' (578064_2.log,3.85 KB, text/plain)
2016-03-23 10:38 UTC, Yuta SATOH
Details
Log, link error (578064_3.log,15.33 KB, text/plain)
2016-03-23 10:39 UTC, Yuta SATOH
Details
sample patch for llvm-3.8.0.ebuild (bug578064.patch,1.62 KB, patch)
2016-03-23 10:43 UTC, Yuta SATOH
Details | Diff
files/llvm-3.8-compiler-rt-fbsd.patch (llvm-3.8-compiler-rt-fbsd.patch,1.13 KB, patch)
2016-03-23 10:44 UTC, Yuta SATOH
Details | Diff
build log, CMAKE_ARGS= -DLLVM_LINK_LLVM_DYLIB=ON on vanilla FreeBSD 10.3-RC3 (llvm-3.8_vanilla_FBSD.log,32.29 KB, text/plain)
2016-03-25 12:22 UTC, Yuta SATOH
Details
sample patch for llvm-3.8.0.ebuild (bug578064_2.patch,1.57 KB, patch)
2016-03-25 12:24 UTC, Yuta SATOH
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuta SATOH 2016-03-23 10:35:19 UTC
3 build issues...

* When using CXX=clang++, fails to build can not be found stdarg.h.
It has been fixed in upstream.
https://github.com/llvm-mirror/compiler-rt/commit/6606c7b50cbb4ec7eab4ecbebbbaaa049734bbd3

* When using gcc, got error: 'stoull' is not a member of 'std', build will fail.
Maybe, gcc issue. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193528
Add -D_GLIBCXX_USE_C99 to CXXFLAGS, build was successful.

* Fails to link.
Change -DLLVM_LINK_LLVM_DYLIB=ON to -DBUILD_SHARED_LIBS=ON, link was successful.
Comment 1 Yuta SATOH 2016-03-23 10:37:51 UTC
Created attachment 428804 [details]
Log, fatal error: 'stdarg.h' file not found
Comment 2 Yuta SATOH 2016-03-23 10:38:29 UTC
Created attachment 428806 [details]
Log, error: 'stoull' is not a member of 'std'
Comment 3 Yuta SATOH 2016-03-23 10:39:02 UTC
Created attachment 428808 [details]
Log, link error
Comment 4 Yuta SATOH 2016-03-23 10:43:17 UTC
Created attachment 428810 [details, diff]
sample patch for llvm-3.8.0.ebuild
Comment 5 Yuta SATOH 2016-03-23 10:44:06 UTC
Created attachment 428812 [details, diff]
files/llvm-3.8-compiler-rt-fbsd.patch
Comment 6 Bernard Cafarelli gentoo-dev 2016-03-24 13:05:45 UTC
Thanks for the work here!

The first 2 fixes look good to go, as they are compile-time only and freebsd-specific, but I am more worried about the linking problem

I switched from BUILD_SHARED_LIBS to the newer option as lldb does not compile with it (maybe now in trunk, but 3.8 does not), and upstream explicitely recommends against it (http://llvm.org/releases/3.8.0/docs/CMake.html#frequently-used-cmake-variables):
"BUILD_SHARED_LIBS is only recommended for use by LLVM developers. If you want to build LLVM as a shared library, you should use the LLVM_BUILD_LLVM_DYLIB option."
And the resulting libs organization is a bit different between these flags.

If possible, it would be much better to fix the link error itself, as it works fine on Linux (if that gets too complicated, we can switch back the flag for freebsd of course)
Comment 7 Bernard Cafarelli gentoo-dev 2016-03-24 14:28:37 UTC
Hmm, rechecking the build log, all link-time failures relate to cxx11 ABI calls.
Maybe playing with the _GLIBCXX_USE_CXX11_ABI flag could help here (https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html)?
Comment 8 Yuta SATOH 2016-03-25 12:22:13 UTC
Created attachment 428982 [details]
build log, CMAKE_ARGS= -DLLVM_LINK_LLVM_DYLIB=ON on vanilla FreeBSD 10.3-RC3

(In reply to Bernard Cafarelli from comment #6)
> Thanks for the work here!
> 
> The first 2 fixes look good to go, as they are compile-time only and
> freebsd-specific, but I am more worried about the linking problem
> 
> I switched from BUILD_SHARED_LIBS to the newer option as lldb does not
> compile with it (maybe now in trunk, but 3.8 does not), and upstream
> explicitely recommends against it
> (http://llvm.org/releases/3.8.0/docs/CMake.html#frequently-used-cmake-
> variables):
> "BUILD_SHARED_LIBS is only recommended for use by LLVM developers. If you
> want to build LLVM as a shared library, you should use the
> LLVM_BUILD_LLVM_DYLIB option."
> And the resulting libs organization is a bit different between these flags.
> 
> If possible, it would be much better to fix the link error itself, as it
> works fine on Linux (if that gets too complicated, we can switch back the
> flag for freebsd of course)

Thanks for review.

I have installed vanilla FreeBSD for link issue to investigate whether FreeBSD issue or Gentoo/FreeBSD-specific issues.

I was tested by adding CMAKE_ARGS= -DLLVM_LINK_LLVM_DYLIB=ON to Makefile of ports on vanilla FreeBSD 10.3-RC3.
And it failed to link.

I think that -DLLVM_LINK_LLVM_DYLIB=ON does not work correctly on FreeBSD......

# cc --version
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.3
Thread model: posix

# c++ --version
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.3
Thread model: posix

Makefile)
https://svnweb.freebsd.org/ports/head/devel/llvm38/Makefile?revision=411371&view=markup


FreeBSD ports seems to disable the shared library.
I'll update patch.
https://svnweb.freebsd.org/ports?view=revision&revision=407336
Comment 9 Yuta SATOH 2016-03-25 12:24:01 UTC
Created attachment 428984 [details, diff]
sample patch for llvm-3.8.0.ebuild
Comment 10 Bernard Cafarelli gentoo-dev 2016-03-29 08:03:36 UTC
We could go without shared library indeed, though mgorny changed back to shared libraries build in 3.8.0-r1 (good to know we are not the only ones where lldb fails to build), so this could end with a workaround.
So -D_GLIBCXX_USE_CXX11_ABI (enabled or disabled) did not have any effect?
Comment 11 Patrice Clement gentoo-dev 2016-06-23 16:08:53 UTC
commit 12280fd5851883571f9e0f0ec44432d2bd17e187 (HEAD -> master, origin/master, origin/HEAD)
Author:     Yuta Satoh <nigoro.dev@gmail.com>
AuthorDate: Sat Jun 18 14:44:10 2016 +0900
Commit:     Patrice Clement <monsieurp@gentoo.org>
CommitDate: Thu Jun 23 15:26:09 2016 +0000

sys-devel/llvm: Fix build fails on Gentoo/FreeBSD.

Gentoo-Bug: https://bugs.gentoo.org/578064
Closes: https://github.com/gentoo/gentoo/pull/1693

Signed-off-by: Patrice Clement <monsieurp@gentoo.org>

sys-devel/llvm/files/clang-3.8-compiler-rt-fbsd.patch | 20 ++++++++++++++++++++
sys-devel/llvm/llvm-3.8.0-r2.ebuild                   |  7 +++++++
2 files changed, 27 insertions(+)
create mode 100644 sys-devel/llvm/files/clang-3.8-compiler-rt-fbsd.patch