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