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: Tue, 14 Mar 2023 19:43:52
Message-Id: 1678823016.b239d26e2722fc41bcf6437eef284426da2029d4.mgorny@gentoo
1 commit: b239d26e2722fc41bcf6437eef284426da2029d4
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Mar 14 14:51:35 2023 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Mar 14 19:43:36 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b239d26e
7
8 sys-libs/libcxx: Add 17.0.0_pre20230314 snapshot
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 sys-libs/libcxx/Manifest | 1 +
13 sys-libs/libcxx/libcxx-17.0.0_pre20230314.ebuild | 204 +++++++++++++++++++++++
14 2 files changed, 205 insertions(+)
15
16 diff --git a/sys-libs/libcxx/Manifest b/sys-libs/libcxx/Manifest
17 index cd18bd7e61ad..95b92f88cd6a 100644
18 --- a/sys-libs/libcxx/Manifest
19 +++ b/sys-libs/libcxx/Manifest
20 @@ -9,3 +9,4 @@ DIST llvm-project-16.0.0rc3.src.tar.xz.sig 566 BLAKE2B 43683d2d7b266a847516f7141
21 DIST llvm-project-16.0.0rc4.src.tar.xz 117930024 BLAKE2B 55cf032ad3ba52d2af0942fe1c627319ae95b466122d04b24a917c33e29139fae546d92c375715600190c02426b798803ead0ab7a97d86960cf98fca80e8815c SHA512 8d628205c5b93fe6683b67b97b5c7f98bae945bd87cccebcdac00ddd4362108bd171f077a5196242be0fb909c795592b34bfa1c96c50a744fb68f287fd9781cc
22 DIST llvm-project-16.0.0rc4.src.tar.xz.sig 566 BLAKE2B bfcf39070f32e16cfeae699d95d06f184b1331c3af403340c31cc5a973a3bb1faec0b6342445176cebed5819ddf68e4abfdaa8542ec425b1c822fc8c03c03349 SHA512 2af72e3d771e2361873007a944dcccfe81fbdbc3025a2101e03cbc15f1a173d39ceb94c4ae8966b1d7564bf004ee9a5ffa032e2334c0cf7154aea1090d04b00f
23 DIST llvm-project-2708869801ae00f4681f6b2d9d69b25b3fce26b6.tar.gz 180523586 BLAKE2B cf918d1e23f922d201a44531c9765b7d8ec2b3b8499ea7954845abcd5fa2687e85b3a34819a583c4f4a6d6e1baa49dbac0b4450cd6b9b322b0f13c88cd7da93c SHA512 18cb00e93d819993a925ae0467d382bc952d82c1eb92dbbb5bb3cdf87043269948670713734ddc3ea4ec50544e54dd11b6747496f7eaa02479374ab9ad075aa5
24 +DIST llvm-project-4bf004e07e2b9d6e04e3f33e1b02628c679de664.tar.gz 180304467 BLAKE2B 6750855453b575eb8fcc861d5b24b144497bba62df9b9292ac586cf340e04b2b58290fe9df6d89142f29b56aa37ddeb3bd11cc3337e4dc985a4487954d1e2ffa SHA512 d8a87064ba0f92967df019e9345222b87cda81852a9599902cedc4a49ec7d9e2175c972b7fa6d19920489c1d309822f9c31c23bdce0376a8d40c71d57bcd5068
25
26 diff --git a/sys-libs/libcxx/libcxx-17.0.0_pre20230314.ebuild b/sys-libs/libcxx/libcxx-17.0.0_pre20230314.ebuild
27 new file mode 100644
28 index 000000000000..4eeb65e55e83
29 --- /dev/null
30 +++ b/sys-libs/libcxx/libcxx-17.0.0_pre20230314.ebuild
31 @@ -0,0 +1,204 @@
32 +# Copyright 1999-2023 Gentoo Authors
33 +# Distributed under the terms of the GNU General Public License v2
34 +
35 +EAPI=8
36 +
37 +PYTHON_COMPAT=( python3_{9..11} )
38 +inherit cmake-multilib flag-o-matic llvm llvm.org python-any-r1 \
39 + 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=""
47 +IUSE="+clang +libcxxabi static-libs test"
48 +REQUIRED_USE="test? ( clang )"
49 +RESTRICT="!test? ( test )"
50 +
51 +RDEPEND="
52 + libcxxabi? (
53 + ~sys-libs/libcxxabi-${PV}[static-libs?,${MULTILIB_USEDEP}]
54 + )
55 + !libcxxabi? ( >=sys-devel/gcc-4.7:=[cxx] )
56 +"
57 +DEPEND="
58 + ${RDEPEND}
59 + sys-devel/llvm:${LLVM_MAJOR}
60 +"
61 +BDEPEND="
62 + clang? (
63 + sys-devel/clang:${LLVM_MAJOR}
64 + )
65 + !test? (
66 + ${PYTHON_DEPS}
67 + )
68 + test? (
69 + >=dev-util/cmake-3.16
70 + sys-devel/gdb[python]
71 + $(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]')
72 + )
73 +"
74 +
75 +LLVM_COMPONENTS=( runtimes libcxx{,abi} llvm/{cmake,utils/llvm-lit} cmake )
76 +llvm.org_set_globals
77 +
78 +python_check_deps() {
79 + use test || return 0
80 + python_has_version "dev-python/lit[${PYTHON_USEDEP}]"
81 +}
82 +
83 +pkg_setup() {
84 + # Darwin Prefix builds do not have llvm installed yet, so rely on
85 + # bootstrap-prefix to set the appropriate path vars to LLVM instead
86 + # of using llvm_pkg_setup.
87 + if [[ ${CHOST} != *-darwin* ]] || has_version dev-lang/llvm; then
88 + LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup
89 + fi
90 + python-any-r1_pkg_setup
91 +
92 + if ! use libcxxabi && ! tc-is-gcc ; then
93 + eerror "To build ${PN} against libsupc++, you have to use gcc. Other"
94 + eerror "compilers are not supported. Please set CC=gcc and CXX=g++"
95 + eerror "and try again."
96 + die
97 + fi
98 +}
99 +
100 +test_compiler() {
101 + $(tc-getCXX) ${CXXFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c++ - \
102 + <<<'int main() { return 0; }' &>/dev/null
103 +}
104 +
105 +src_configure() {
106 + # note: we need to do this before multilib kicks in since it will
107 + # alter the CHOST
108 + local cxxabi cxxabi_incs
109 + if use libcxxabi; then
110 + cxxabi=system-libcxxabi
111 + cxxabi_incs="${EPREFIX}/usr/include/c++/v1"
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 + multilib-minimal_src_configure
119 +}
120 +
121 +multilib_src_configure() {
122 + if use clang; then
123 + local -x CC=${CHOST}-clang
124 + local -x CXX=${CHOST}-clang++
125 + strip-unsupported-flags
126 + fi
127 +
128 + # link to compiler-rt
129 + local use_compiler_rt=OFF
130 + [[ $(tc-get-c-rtlib) == compiler-rt ]] && use_compiler_rt=ON
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 + -DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
144 + -DPython3_EXECUTABLE="${PYTHON}"
145 + -DLLVM_ENABLE_RUNTIMES=libcxx
146 + -DLLVM_INCLUDE_TESTS=OFF
147 + -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
148 +
149 + -DLIBCXX_ENABLE_SHARED=ON
150 + -DLIBCXX_ENABLE_STATIC=$(usex static-libs)
151 + -DLIBCXX_CXX_ABI=${cxxabi}
152 + -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi_incs}
153 + # we're using our own mechanism for generating linker scripts
154 + -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
155 + -DLIBCXX_HAS_MUSL_LIBC=$(usex elibc_musl)
156 + -DLIBCXX_INCLUDE_BENCHMARKS=OFF
157 + -DLIBCXX_INCLUDE_TESTS=$(usex test)
158 + -DLIBCXX_USE_COMPILER_RT=${use_compiler_rt}
159 + )
160 +
161 + if use test; then
162 + mycmakeargs+=(
163 + -DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
164 + -DLLVM_LIT_ARGS="$(get_lit_flags)"
165 + -DPython3_EXECUTABLE="${PYTHON}"
166 + )
167 + fi
168 + cmake_src_configure
169 +}
170 +
171 +multilib_src_compile() {
172 + cmake_src_compile
173 + if [[ ${CHOST} != *-darwin* ]] ; then
174 + gen_shared_ldscript
175 + use static-libs && gen_static_ldscript
176 + fi
177 +}
178 +
179 +multilib_src_test() {
180 + local -x LIT_PRESERVES_TMP=1
181 + cmake_build check-cxx
182 +}
183 +
184 +multilib_src_install() {
185 + cmake_src_install
186 + # since we've replaced libc++.{a,so} with ldscripts, now we have to
187 + # install the extra symlinks
188 + if [[ ${CHOST} != *-darwin* ]] ; then
189 + dolib.so lib/libc++_shared.so
190 + use static-libs && dolib.a lib/libc++_static.a
191 + fi
192 +}
193 +
194 +# Usage: deps
195 +gen_ldscript() {
196 + local output_format
197 + output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
198 + [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
199 +
200 + cat <<-END_LDSCRIPT
201 +/* GNU ld script
202 + Include missing dependencies
203 +*/
204 +${output_format}
205 +GROUP ( $@ )
206 +END_LDSCRIPT
207 +}
208 +
209 +gen_static_ldscript() {
210 + # Move it first.
211 + mv lib/libc++{,_static}.a || die
212 + # Generate libc++.a ldscript for inclusion of its dependencies so that
213 + # clang++ -stdlib=libc++ -static works out of the box.
214 + local deps=(
215 + libc++_static.a
216 + $(usex libcxxabi libc++abi.a libsupc++.a)
217 + )
218 + # On Linux/glibc it does not link without libpthread or libdl. It is
219 + # fine on FreeBSD.
220 + use elibc_glibc && deps+=( libpthread.a libdl.a )
221 +
222 + gen_ldscript "${deps[*]}" > lib/libc++.a || die
223 +}
224 +
225 +gen_shared_ldscript() {
226 + # Move it first.
227 + mv lib/libc++{,_shared}.so || die
228 + local deps=(
229 + libc++_shared.so
230 + # libsupc++ doesn't have a shared version
231 + $(usex libcxxabi libc++abi.so libsupc++.a)
232 + )
233 +
234 + gen_ldscript "${deps[*]}" > lib/libc++.so || die
235 +}