Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/libcxx/
Date: Wed, 03 Jan 2018 22:22:36
Message-Id: 1515018103.9a40afcacf984698fb0749752dc7a8cd90f0abc9.mgorny@gentoo
1 commit: 9a40afcacf984698fb0749752dc7a8cd90f0abc9
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 3 21:47:22 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 3 22:21:43 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9a40afca
7
8 sys-libs/libcxx: Add a live ebuild for 6.0 branch
9
10 sys-libs/libcxx/libcxx-6.0.9999.ebuild | 210 +++++++++++++++++++++++++++++++++
11 1 file changed, 210 insertions(+)
12
13 diff --git a/sys-libs/libcxx/libcxx-6.0.9999.ebuild b/sys-libs/libcxx/libcxx-6.0.9999.ebuild
14 new file mode 100644
15 index 00000000000..803726e9d93
16 --- /dev/null
17 +++ b/sys-libs/libcxx/libcxx-6.0.9999.ebuild
18 @@ -0,0 +1,210 @@
19 +# Copyright 1999-2018 Gentoo Foundation
20 +# Distributed under the terms of the GNU General Public License v2
21 +
22 +EAPI=6
23 +
24 +# Ninja provides better scalability and cleaner verbose output, and is used
25 +# throughout all LLVM projects.
26 +: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
27 +# (needed due to CMAKE_BUILD_TYPE != Gentoo)
28 +CMAKE_MIN_VERSION=3.7.0-r1
29 +EGIT_REPO_URI="https://git.llvm.org/git/libcxx.git
30 + https://github.com/llvm-mirror/libcxx.git"
31 +EGIT_BRANCH="release_60"
32 +PYTHON_COMPAT=( python2_7 )
33 +
34 +[[ ${PV} == *9999 ]] && SCM="git-r3" || SCM=""
35 +
36 +inherit ${SCM} cmake-multilib llvm python-any-r1 toolchain-funcs
37 +
38 +DESCRIPTION="New implementation of the C++ standard library, targeting C++11"
39 +HOMEPAGE="https://libcxx.llvm.org/"
40 +if [[ ${PV} != *9999 ]] ; then
41 + SRC_URI="https://llvm.org/releases/${PV}/${P}.src.tar.xz"
42 + S="${WORKDIR}/${P}.src"
43 +else
44 + SRC_URI=""
45 +fi
46 +
47 +LICENSE="|| ( UoI-NCSA MIT )"
48 +SLOT="0"
49 +if [[ ${PV} != *9999 ]] ; then
50 + KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
51 +else
52 + KEYWORDS=""
53 +fi
54 +IUSE="elibc_glibc elibc_musl +libcxxabi libcxxrt +libunwind +static-libs test"
55 +REQUIRED_USE="libunwind? ( || ( libcxxabi libcxxrt ) )
56 + ?? ( libcxxabi libcxxrt )"
57 +RESTRICT="!test? ( test )"
58 +
59 +RDEPEND="
60 + libcxxabi? ( ~sys-libs/libcxxabi-${PV}[libunwind=,static-libs?,${MULTILIB_USEDEP}] )
61 + libcxxrt? ( sys-libs/libcxxrt[libunwind=,static-libs?,${MULTILIB_USEDEP}] )
62 + !libcxxabi? ( !libcxxrt? ( >=sys-devel/gcc-4.7:=[cxx] ) )"
63 +# LLVM 4 required for llvm-config --cmakedir
64 +# clang-3.9.0 installs necessary target symlinks unconditionally
65 +# which removes the need for MULTILIB_USEDEP
66 +DEPEND="${RDEPEND}
67 + test? ( >=sys-devel/clang-3.9.0
68 + $(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]') )
69 + app-arch/xz-utils
70 + >=sys-devel/llvm-4"
71 +
72 +DOCS=( CREDITS.TXT )
73 +
74 +PATCHES=(
75 + # Add link flag "-Wl,-z,defs" to avoid underlinking; this is needed in a
76 + # out-of-tree build.
77 + "${FILESDIR}/${PN}-3.9-cmake-link-flags.patch"
78 +)
79 +
80 +# least intrusive of all
81 +CMAKE_BUILD_TYPE=RelWithDebInfo
82 +
83 +python_check_deps() {
84 + has_version "dev-python/lit[${PYTHON_USEDEP}]"
85 +}
86 +
87 +pkg_setup() {
88 + llvm_pkg_setup
89 + use test && python-any-r1_pkg_setup
90 +
91 + if ! use libcxxabi && ! use libcxxrt && ! tc-is-gcc ; then
92 + eerror "To build ${PN} against libsupc++, you have to use gcc. Other"
93 + eerror "compilers are not supported. Please set CC=gcc and CXX=g++"
94 + eerror "and try again."
95 + die
96 + fi
97 + if tc-is-gcc && [[ $(gcc-version) < 4.7 ]] ; then
98 + eerror "${PN} needs to be built with gcc-4.7 or later (or other"
99 + eerror "conformant compilers). Please use gcc-config to switch to"
100 + eerror "gcc-4.7 or later version."
101 + die
102 + fi
103 +}
104 +
105 +multilib_src_configure() {
106 + local cxxabi cxxabi_incs
107 + if use libcxxabi; then
108 + cxxabi=libcxxabi
109 + cxxabi_incs="${EPREFIX}/usr/include/libcxxabi"
110 + elif use libcxxrt; then
111 + cxxabi=libcxxrt
112 + cxxabi_incs="${EPREFIX}/usr/include/libcxxrt"
113 + else
114 + local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)"
115 + cxxabi=libsupc++
116 + cxxabi_incs="${gcc_inc};${gcc_inc}/${CHOST}"
117 + fi
118 +
119 + # we want -lgcc_s for unwinder, and for compiler runtime when using
120 + # gcc, clang with gcc runtime (or any unknown compiler)
121 + local extra_libs=() want_gcc_s=ON
122 + if use libunwind; then
123 + # work-around missing -lunwind upstream
124 + extra_libs+=( -lunwind )
125 + # if we're using libunwind and clang with compiler-rt, we want
126 + # to link to compiler-rt instead of -lgcc_s
127 + if tc-is-clang; then
128 + # get the full library list out of 'pretend mode'
129 + # and grep it for libclang_rt references
130 + local args=( $($(tc-getCC) -### -x c - 2>&1 | tail -n 1) )
131 + local i
132 + for i in "${args[@]}"; do
133 + if [[ ${i} == *libclang_rt* ]]; then
134 + want_gcc_s=OFF
135 + extra_libs+=( "${i}" )
136 + fi
137 + done
138 + fi
139 + fi
140 +
141 + local libdir=$(get_libdir)
142 + local mycmakeargs=(
143 + -DLIBCXX_LIBDIR_SUFFIX=${libdir#lib}
144 + -DLIBCXX_ENABLE_SHARED=ON
145 + -DLIBCXX_ENABLE_STATIC=$(usex static-libs)
146 + -DLIBCXX_CXX_ABI=${cxxabi}
147 + -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi_incs}
148 + # we're using our own mechanism for generating linker scripts
149 + -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
150 + -DLIBCXX_HAS_MUSL_LIBC=$(usex elibc_musl)
151 + -DLIBCXX_HAS_GCC_S_LIB=${want_gcc_s}
152 + -DLIBCXX_INCLUDE_TESTS=$(usex test)
153 + -DCMAKE_SHARED_LINKER_FLAGS="${extra_libs[*]} ${LDFLAGS}"
154 + )
155 +
156 + if use test; then
157 + mycmakeargs+=(
158 + -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
159 + -DLLVM_LIT_ARGS="-vv"
160 + )
161 + fi
162 + cmake-utils_src_configure
163 +}
164 +
165 +multilib_src_test() {
166 + local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 2>/dev/null)
167 +
168 + [[ -n ${clang_path} ]] || die "Unable to find ${CHOST}-clang for tests"
169 + sed -i -e "/cxx_under_test/s^\".*\"^\"${clang_path}\"^" test/lit.site.cfg || die
170 +
171 + cmake-utils_src_make check-libcxx
172 +}
173 +
174 +# Usage: deps
175 +gen_ldscript() {
176 + local output_format
177 + output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
178 + [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
179 +
180 + cat <<-END_LDSCRIPT
181 +/* GNU ld script
182 + Include missing dependencies
183 +*/
184 +${output_format}
185 +GROUP ( $@ )
186 +END_LDSCRIPT
187 +}
188 +
189 +gen_static_ldscript() {
190 + local libdir=$(get_libdir)
191 + local cxxabi_lib=$(usex libcxxabi "libc++abi.a" "$(usex libcxxrt "libcxxrt.a" "libsupc++.a")")
192 +
193 + # Move it first.
194 + mv "${ED}/usr/${libdir}/libc++.a" "${ED}/usr/${libdir}/libc++_static.a" || die
195 + # Generate libc++.a ldscript for inclusion of its dependencies so that
196 + # clang++ -stdlib=libc++ -static works out of the box.
197 + local deps="libc++_static.a ${cxxabi_lib} $(usex libunwind libunwind.a libgcc_eh.a)"
198 + # On Linux/glibc it does not link without libpthread or libdl. It is
199 + # fine on FreeBSD.
200 + use elibc_glibc && deps+=" libpthread.a libdl.a"
201 +
202 + gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.a" || die
203 +}
204 +
205 +gen_shared_ldscript() {
206 + local libdir=$(get_libdir)
207 + # libsupc++ doesn't have a shared version
208 + local cxxabi_lib=$(usex libcxxabi "libc++abi.so" "$(usex libcxxrt "libcxxrt.so" "libsupc++.a")")
209 +
210 + mv "${ED}/usr/${libdir}/libc++.so" "${ED}/usr/${libdir}/libc++_shared.so" || die
211 + local deps="libc++_shared.so ${cxxabi_lib} $(usex libunwind libunwind.so libgcc_s.so)"
212 +
213 + gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.so" || die
214 +}
215 +
216 +multilib_src_install() {
217 + cmake-utils_src_install
218 + gen_shared_ldscript
219 + use static-libs && gen_static_ldscript
220 +}
221 +
222 +pkg_postinst() {
223 + elog "This package (${PN}) is mainly intended as a replacement for the C++"
224 + elog "standard library when using clang."
225 + elog "To use it, instead of libstdc++, use:"
226 + elog " clang++ -stdlib=libc++"
227 + elog "to compile your C++ programs."
228 +}