1 |
commit: d338d09e318e203afcf49fbd6e9668836b062b79 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jul 30 11:16:42 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jul 30 18:13:59 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d338d09e |
7 |
|
8 |
sys-libs/libcxx: Bump live to 14* |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
sys-libs/libcxx/libcxx-14.0.0.9999.ebuild | 212 ++++++++++++++++++++++++++++++ |
13 |
1 file changed, 212 insertions(+) |
14 |
|
15 |
diff --git a/sys-libs/libcxx/libcxx-14.0.0.9999.ebuild b/sys-libs/libcxx/libcxx-14.0.0.9999.ebuild |
16 |
new file mode 100644 |
17 |
index 00000000000..db5b489c505 |
18 |
--- /dev/null |
19 |
+++ b/sys-libs/libcxx/libcxx-14.0.0.9999.ebuild |
20 |
@@ -0,0 +1,212 @@ |
21 |
+# Copyright 1999-2021 Gentoo Authors |
22 |
+# Distributed under the terms of the GNU General Public License v2 |
23 |
+ |
24 |
+EAPI=7 |
25 |
+ |
26 |
+CMAKE_ECLASS=cmake |
27 |
+PYTHON_COMPAT=( python3_{8..10} ) |
28 |
+inherit cmake-multilib llvm llvm.org python-any-r1 toolchain-funcs |
29 |
+ |
30 |
+DESCRIPTION="New implementation of the C++ standard library, targeting C++11" |
31 |
+HOMEPAGE="https://libcxx.llvm.org/" |
32 |
+ |
33 |
+LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )" |
34 |
+SLOT="0" |
35 |
+KEYWORDS="" |
36 |
+IUSE="elibc_glibc elibc_musl +libcxxabi +libunwind static-libs test" |
37 |
+REQUIRED_USE="libunwind? ( libcxxabi )" |
38 |
+RESTRICT="!test? ( test )" |
39 |
+ |
40 |
+RDEPEND=" |
41 |
+ libcxxabi? ( ~sys-libs/libcxxabi-${PV}[libunwind=,static-libs?,${MULTILIB_USEDEP}] ) |
42 |
+ !libcxxabi? ( >=sys-devel/gcc-4.7:=[cxx] )" |
43 |
+# llvm-6 for new lit options |
44 |
+# clang-3.9.0 installs necessary target symlinks unconditionally |
45 |
+# which removes the need for MULTILIB_USEDEP |
46 |
+DEPEND="${RDEPEND} |
47 |
+ >=sys-devel/llvm-6" |
48 |
+BDEPEND=" |
49 |
+ test? ( |
50 |
+ >=dev-util/cmake-3.16 |
51 |
+ >=sys-devel/clang-3.9.0 |
52 |
+ $(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]') |
53 |
+ )" |
54 |
+ |
55 |
+DOCS=( CREDITS.TXT ) |
56 |
+ |
57 |
+LLVM_COMPONENTS=( libcxx{,abi} llvm/{cmake/modules,utils/llvm-lit} ) |
58 |
+LLVM_PATCHSET=9999-1 |
59 |
+llvm.org_set_globals |
60 |
+ |
61 |
+python_check_deps() { |
62 |
+ has_version "dev-python/lit[${PYTHON_USEDEP}]" |
63 |
+} |
64 |
+ |
65 |
+pkg_setup() { |
66 |
+ # Darwin Prefix builds do not have llvm installed yet, so rely on |
67 |
+ # bootstrap-prefix to set the appropriate path vars to LLVM instead |
68 |
+ # of using llvm_pkg_setup. |
69 |
+ if [[ ${CHOST} != *-darwin* ]] || has_version dev-lang/llvm; then |
70 |
+ llvm_pkg_setup |
71 |
+ fi |
72 |
+ use test && python-any-r1_pkg_setup |
73 |
+ |
74 |
+ if ! use libcxxabi && ! tc-is-gcc ; then |
75 |
+ eerror "To build ${PN} against libsupc++, you have to use gcc. Other" |
76 |
+ eerror "compilers are not supported. Please set CC=gcc and CXX=g++" |
77 |
+ eerror "and try again." |
78 |
+ die |
79 |
+ fi |
80 |
+} |
81 |
+ |
82 |
+test_compiler() { |
83 |
+ $(tc-getCXX) ${CXXFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c++ - \ |
84 |
+ <<<'int main() { return 0; }' &>/dev/null |
85 |
+} |
86 |
+ |
87 |
+src_configure() { |
88 |
+ # note: we need to do this before multilib kicks in since it will |
89 |
+ # alter the CHOST |
90 |
+ local cxxabi cxxabi_incs |
91 |
+ if use libcxxabi; then |
92 |
+ cxxabi=libcxxabi |
93 |
+ cxxabi_incs="${EPREFIX}/usr/include/libcxxabi" |
94 |
+ else |
95 |
+ local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)" |
96 |
+ cxxabi=libsupc++ |
97 |
+ cxxabi_incs="${gcc_inc};${gcc_inc}/${CHOST}" |
98 |
+ fi |
99 |
+ |
100 |
+ multilib-minimal_src_configure |
101 |
+} |
102 |
+ |
103 |
+multilib_src_configure() { |
104 |
+ # we want -lgcc_s for unwinder, and for compiler runtime when using |
105 |
+ # gcc, clang with gcc runtime (or any unknown compiler) |
106 |
+ local extra_libs=() want_gcc_s=ON want_compiler_rt=OFF |
107 |
+ if use libunwind; then |
108 |
+ # work-around missing -lunwind upstream |
109 |
+ extra_libs+=( -lunwind ) |
110 |
+ # if we're using libunwind and clang with compiler-rt, we want |
111 |
+ # to link to compiler-rt instead of -lgcc_s |
112 |
+ if tc-is-clang; then |
113 |
+ local compiler_rt=$($(tc-getCC) ${CFLAGS} ${CPPFLAGS} \ |
114 |
+ ${LDFLAGS} -print-libgcc-file-name) |
115 |
+ if [[ ${compiler_rt} == *libclang_rt* ]]; then |
116 |
+ want_gcc_s=OFF |
117 |
+ want_compiler_rt=ON |
118 |
+ extra_libs+=( "${compiler_rt}" ) |
119 |
+ fi |
120 |
+ fi |
121 |
+ elif [[ ${CHOST} == *-darwin* ]] && tc-is-clang; then |
122 |
+ # clang-based darwin prefix disables libunwind useflag during |
123 |
+ # bootstrap, because libunwind is not in the prefix yet. |
124 |
+ # override the default, though, because clang based libcxx |
125 |
+ # should never use gcc_s on Darwin. |
126 |
+ want_gcc_s=OFF |
127 |
+ # compiler_rt is not available in EPREFIX during bootstrap, |
128 |
+ # so we cannot link to it yet anyway, so keep the defaults |
129 |
+ # of want_compiler_rt=OFF and extra_libs=() |
130 |
+ fi |
131 |
+ |
132 |
+ # bootstrap: cmake is unhappy if compiler can't link to stdlib |
133 |
+ local nolib_flags=( -nodefaultlibs -lc ) |
134 |
+ if ! test_compiler; then |
135 |
+ if test_compiler "${nolib_flags[@]}"; then |
136 |
+ local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" |
137 |
+ ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}" |
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 |
+ -DLIBCXX_USE_COMPILER_RT=${want_compiler_rt} |
154 |
+ -DLIBCXX_HAS_ATOMIC_LIB=${want_gcc_s} |
155 |
+ -DCMAKE_SHARED_LINKER_FLAGS="${extra_libs[*]} ${LDFLAGS}" |
156 |
+ ) |
157 |
+ |
158 |
+ if use test; then |
159 |
+ local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 2>/dev/null) |
160 |
+ [[ -n ${clang_path} ]] || die "Unable to find ${CHOST}-clang for tests" |
161 |
+ |
162 |
+ mycmakeargs+=( |
163 |
+ -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit" |
164 |
+ -DLLVM_LIT_ARGS="$(get_lit_flags);--param=cxx_under_test=${clang_path}" |
165 |
+ -DPython3_EXECUTABLE="${PYTHON}" |
166 |
+ ) |
167 |
+ fi |
168 |
+ cmake_src_configure |
169 |
+} |
170 |
+ |
171 |
+multilib_src_test() { |
172 |
+ local -x LIT_PRESERVES_TMP=1 |
173 |
+ cmake_build check-cxx |
174 |
+} |
175 |
+ |
176 |
+# Usage: deps |
177 |
+gen_ldscript() { |
178 |
+ local output_format |
179 |
+ output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p') |
180 |
+ [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )" |
181 |
+ |
182 |
+ cat <<-END_LDSCRIPT |
183 |
+/* GNU ld script |
184 |
+ Include missing dependencies |
185 |
+*/ |
186 |
+${output_format} |
187 |
+GROUP ( $@ ) |
188 |
+END_LDSCRIPT |
189 |
+} |
190 |
+ |
191 |
+gen_static_ldscript() { |
192 |
+ local libdir=$(get_libdir) |
193 |
+ local cxxabi_lib=$(usex libcxxabi "libc++abi.a" "libsupc++.a") |
194 |
+ |
195 |
+ # Move it first. |
196 |
+ mv "${ED}/usr/${libdir}/libc++.a" "${ED}/usr/${libdir}/libc++_static.a" || die |
197 |
+ # Generate libc++.a ldscript for inclusion of its dependencies so that |
198 |
+ # clang++ -stdlib=libc++ -static works out of the box. |
199 |
+ local deps="libc++_static.a ${cxxabi_lib} $(usex libunwind libunwind.a libgcc_eh.a)" |
200 |
+ # On Linux/glibc it does not link without libpthread or libdl. It is |
201 |
+ # fine on FreeBSD. |
202 |
+ use elibc_glibc && deps+=" libpthread.a libdl.a" |
203 |
+ |
204 |
+ gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.a" || die |
205 |
+} |
206 |
+ |
207 |
+gen_shared_ldscript() { |
208 |
+ local libdir=$(get_libdir) |
209 |
+ # libsupc++ doesn't have a shared version |
210 |
+ local cxxabi_lib=$(usex libcxxabi "libc++abi.so" "libsupc++.a") |
211 |
+ |
212 |
+ mv "${ED}/usr/${libdir}/libc++.so" "${ED}/usr/${libdir}/libc++_shared.so" || die |
213 |
+ local deps="libc++_shared.so ${cxxabi_lib} $(usex libunwind libunwind.so libgcc_s.so)" |
214 |
+ |
215 |
+ gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.so" || die |
216 |
+} |
217 |
+ |
218 |
+multilib_src_install() { |
219 |
+ cmake_src_install |
220 |
+ if [[ ${CHOST} != *-darwin* ]] ; then |
221 |
+ gen_shared_ldscript |
222 |
+ use static-libs && gen_static_ldscript |
223 |
+ fi |
224 |
+} |
225 |
+ |
226 |
+pkg_postinst() { |
227 |
+ elog "This package (${PN}) is mainly intended as a replacement for the C++" |
228 |
+ elog "standard library when using clang." |
229 |
+ elog "To use it, instead of libstdc++, use:" |
230 |
+ elog " clang++ -stdlib=libc++" |
231 |
+ elog "to compile your C++ programs." |
232 |
+} |