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: Mon, 24 Jul 2017 19:04:10
Message-Id: 1500923029.d1cb94be51f9f1e5c844d984802d4a4e715c887c.mgorny@gentoo
1 commit: d1cb94be51f9f1e5c844d984802d4a4e715c887c
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jul 23 16:51:12 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Jul 24 19:03:49 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d1cb94be
7
8 sys-libs/libcxx: Branch for 5.0.0 release
9
10 sys-libs/libcxx/libcxx-5.0.9999.ebuild | 211 +++++++++++++++++++++++++++++++++
11 1 file changed, 211 insertions(+)
12
13 diff --git a/sys-libs/libcxx/libcxx-5.0.9999.ebuild b/sys-libs/libcxx/libcxx-5.0.9999.ebuild
14 new file mode 100644
15 index 00000000000..625b3568537
16 --- /dev/null
17 +++ b/sys-libs/libcxx/libcxx-5.0.9999.ebuild
18 @@ -0,0 +1,211 @@
19 +# Copyright 1999-2017 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_50"
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 +
58 +RDEPEND="
59 + libcxxabi? ( ~sys-libs/libcxxabi-${PV}[libunwind=,static-libs?,${MULTILIB_USEDEP}] )
60 + libcxxrt? ( sys-libs/libcxxrt[libunwind=,static-libs?,${MULTILIB_USEDEP}] )
61 + !libcxxabi? ( !libcxxrt? ( >=sys-devel/gcc-4.7:=[cxx] ) )"
62 +# LLVM 4 required for llvm-config --cmakedir
63 +# clang-3.9.0 installs necessary target symlinks unconditionally
64 +# which removes the need for MULTILIB_USEDEP
65 +DEPEND="${RDEPEND}
66 + test? ( >=sys-devel/clang-3.9.0
67 + $(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]') )
68 + app-arch/xz-utils
69 + >=sys-devel/llvm-4"
70 +
71 +DOCS=( CREDITS.TXT )
72 +
73 +PATCHES=(
74 + # Add link flag "-Wl,-z,defs" to avoid underlinking; this is needed in a
75 + # out-of-tree build.
76 + "${FILESDIR}/${PN}-3.9-cmake-link-flags.patch"
77 +)
78 +
79 +# least intrusive of all
80 +CMAKE_BUILD_TYPE=RelWithDebInfo
81 +
82 +python_check_deps() {
83 + has_version "dev-python/lit[${PYTHON_USEDEP}]"
84 +}
85 +
86 +pkg_setup() {
87 + llvm_pkg_setup
88 + use test && python-any-r1_pkg_setup
89 +
90 + if ! use libcxxabi && ! use libcxxrt && ! tc-is-gcc ; then
91 + eerror "To build ${PN} against libsupc++, you have to use gcc. Other"
92 + eerror "compilers are not supported. Please set CC=gcc and CXX=g++"
93 + eerror "and try again."
94 + die
95 + fi
96 + if tc-is-gcc && [[ $(gcc-version) < 4.7 ]] ; then
97 + eerror "${PN} needs to be built with gcc-4.7 or later (or other"
98 + eerror "conformant compilers). Please use gcc-config to switch to"
99 + eerror "gcc-4.7 or later version."
100 + die
101 + fi
102 +}
103 +
104 +multilib_src_configure() {
105 + local cxxabi cxxabi_incs
106 + if use libcxxabi; then
107 + cxxabi=libcxxabi
108 + cxxabi_incs="${EPREFIX}/usr/include/libcxxabi"
109 + elif use libcxxrt; then
110 + cxxabi=libcxxrt
111 + cxxabi_incs="${EPREFIX}/usr/include/libcxxrt"
112 + else
113 + local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)"
114 + cxxabi=libsupc++
115 + cxxabi_incs="${gcc_inc};${gcc_inc}/${CHOST}"
116 + fi
117 +
118 + # we want -lgcc_s for unwinder, and for compiler runtime when using
119 + # gcc, clang with gcc runtime (or any unknown compiler)
120 + local extra_libs=() want_gcc_s=ON
121 + if use libunwind; then
122 + # work-around missing -lunwind upstream
123 + extra_libs+=( -lunwind )
124 + # if we're using libunwind and clang with compiler-rt, we want
125 + # to link to compiler-rt instead of -lgcc_s
126 + if tc-is-clang; then
127 + # get the full library list out of 'pretend mode'
128 + # and grep it for libclang_rt references
129 + local args=( $($(tc-getCC) -### -x c - 2>&1 | tail -n 1) )
130 + local i
131 + for i in "${args[@]}"; do
132 + if [[ ${i} == *libclang_rt* ]]; then
133 + want_gcc_s=OFF
134 + extra_libs+=( "${i}" )
135 + fi
136 + done
137 + fi
138 + fi
139 +
140 + local libdir=$(get_libdir)
141 + local mycmakeargs=(
142 + -DLIBCXX_LIBDIR_SUFFIX=${libdir#lib}
143 + -DLIBCXX_ENABLE_SHARED=ON
144 + -DLIBCXX_ENABLE_STATIC=$(usex static-libs)
145 + -DLIBCXX_CXX_ABI=${cxxabi}
146 + -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi_incs}
147 + # we're using our own mechanism for generating linker scripts
148 + -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
149 + -DLIBCXX_HAS_MUSL_LIBC=$(usex elibc_musl)
150 + -DLIBCXX_HAS_GCC_S_LIB=${want_gcc_s}
151 + -DLIBCXX_INCLUDE_TESTS=$(usex test)
152 + -DCMAKE_SHARED_LINKER_FLAGS="${extra_libs[*]} ${LDFLAGS}"
153 + )
154 +
155 + if use test; then
156 + mycmakeargs+=(
157 + # this can be any directory, it just needs to exist...
158 + # FIXME: remove this once https://reviews.llvm.org/D25093 is merged
159 + -DLLVM_MAIN_SRC_DIR="${T}"
160 + -DLIT_COMMAND="${EPREFIX}"/usr/bin/lit
161 + )
162 + fi
163 + cmake-utils_src_configure
164 +}
165 +
166 +multilib_src_test() {
167 + local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 2>/dev/null)
168 +
169 + [[ -n ${clang_path} ]] || die "Unable to find ${CHOST}-clang for tests"
170 + sed -i -e "/cxx_under_test/s^\".*\"^\"${clang_path}\"^" test/lit.site.cfg || die
171 +
172 + cmake-utils_src_make check-libcxx
173 +}
174 +
175 +# Usage: deps
176 +gen_ldscript() {
177 + local output_format
178 + output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
179 + [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
180 +
181 + cat <<-END_LDSCRIPT
182 +/* GNU ld script
183 + Include missing dependencies
184 +*/
185 +${output_format}
186 +GROUP ( $@ )
187 +END_LDSCRIPT
188 +}
189 +
190 +gen_static_ldscript() {
191 + local libdir=$(get_libdir)
192 + local cxxabi_lib=$(usex libcxxabi "libc++abi.a" "$(usex libcxxrt "libcxxrt.a" "libsupc++.a")")
193 +
194 + # Move it first.
195 + mv "${ED}/usr/${libdir}/libc++.a" "${ED}/usr/${libdir}/libc++_static.a" || die
196 + # Generate libc++.a ldscript for inclusion of its dependencies so that
197 + # clang++ -stdlib=libc++ -static works out of the box.
198 + local deps="libc++_static.a ${cxxabi_lib} $(usex libunwind libunwind.a libgcc_eh.a)"
199 + # On Linux/glibc it does not link without libpthread or libdl. It is
200 + # fine on FreeBSD.
201 + use elibc_glibc && deps+=" libpthread.a libdl.a"
202 +
203 + gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.a" || die
204 +}
205 +
206 +gen_shared_ldscript() {
207 + local libdir=$(get_libdir)
208 + # libsupc++ doesn't have a shared version
209 + local cxxabi_lib=$(usex libcxxabi "libc++abi.so" "$(usex libcxxrt "libcxxrt.so" "libsupc++.a")")
210 +
211 + mv "${ED}/usr/${libdir}/libc++.so" "${ED}/usr/${libdir}/libc++_shared.so" || die
212 + local deps="libc++_shared.so ${cxxabi_lib} $(usex libunwind libunwind.so libgcc_s.so)"
213 +
214 + gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.so" || die
215 +}
216 +
217 +multilib_src_install() {
218 + cmake-utils_src_install
219 + gen_shared_ldscript
220 + use static-libs && gen_static_ldscript
221 +}
222 +
223 +pkg_postinst() {
224 + elog "This package (${PN}) is mainly intended as a replacement for the C++"
225 + elog "standard library when using clang."
226 + elog "To use it, instead of libstdc++, use:"
227 + elog " clang++ -stdlib=libc++"
228 + elog "to compile your C++ programs."
229 +}