From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1661873-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 71DFA15852A
	for <garchives@archives.gentoo.org>; Thu, 15 Aug 2024 20:01:54 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 3DC0A2BC025;
	Thu, 15 Aug 2024 20:01:52 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 1FA392BC025
	for <gentoo-commits@lists.gentoo.org>; Thu, 15 Aug 2024 20:01:52 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 1F2EA3430AF
	for <gentoo-commits@lists.gentoo.org>; Thu, 15 Aug 2024 20:01:51 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 6D9701EFD
	for <gentoo-commits@lists.gentoo.org>; Thu, 15 Aug 2024 20:01:48 +0000 (UTC)
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Message-ID: <1723752101.9ec6556ddc916065e0d867a0622da4dd1abe05df.mgorny@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/libcxx/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-libs/libcxx/Manifest sys-libs/libcxx/libcxx-20.0.0_pre20240815.ebuild
X-VCS-Directories: sys-libs/libcxx/
X-VCS-Committer: mgorny
X-VCS-Committer-Name: Michał Górny
X-VCS-Revision: 9ec6556ddc916065e0d867a0622da4dd1abe05df
X-VCS-Branch: master
Date: Thu, 15 Aug 2024 20:01:48 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 64cb7bc7-1071-4a46-b8bf-a861517aea0d
X-Archives-Hash: 0257f747c03bfa7a0b35d1b1140c2bdc

commit:     9ec6556ddc916065e0d867a0622da4dd1abe05df
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 15 19:16:44 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 15 20:01:41 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9ec6556d

sys-libs/libcxx: Add 20.0.0_pre20240815 snapshot

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 sys-libs/libcxx/Manifest                         |   1 +
 sys-libs/libcxx/libcxx-20.0.0_pre20240815.ebuild | 201 +++++++++++++++++++++++
 2 files changed, 202 insertions(+)

diff --git a/sys-libs/libcxx/Manifest b/sys-libs/libcxx/Manifest
index a46d4de3c205..c77b759dbeb5 100644
--- a/sys-libs/libcxx/Manifest
+++ b/sys-libs/libcxx/Manifest
@@ -10,4 +10,5 @@ DIST llvm-project-18.1.8.src.tar.xz 132067260 BLAKE2B a950492f1dbfb874dff63b1ffe
 DIST llvm-project-18.1.8.src.tar.xz.sig 566 BLAKE2B 6ab0efc5b38d4483f4e32e8b85774b2edd5d88fdf29f23b88eb0b5130a7a7f0e80549612b025f927e92de4a08ff7c292cff224dbda91a5d598244e98f7ad0fbd SHA512 ddfd1e8a06756759af6cbe488c82a6d6a62ba91f3e8a0eb4cece561321824f5d165b08ed91010588790b76e19790931d2651b24dba8567e3b151d3cb43bec25b
 DIST llvm-project-19.1.0-rc2.src.tar.xz 141264388 BLAKE2B 690b4912d9e4a8019b7990934dd6486362337ccb303dca119c0e75aa1063ad452222be1ee965e43b160dfcea20e491a20c289344152666b618712a1d76dc4780 SHA512 508a401e8433b1ac9a399246eb1a3c18faed7c3d41d8c118e77cefbb64cc6d6e171bd41a3e5584f6c84df141ba6819f1a1cce75b5c1ef33e3d2ac239e662d07c
 DIST llvm-project-19.1.0-rc2.src.tar.xz.sig 438 BLAKE2B 1eaf10a1419ecf009c033a8f6ecb6eec86107d81621d5b4665c8d929b05f4845ce0c432017343d7b06f33e6ff6384df9e1d8fc7b9c6efe7f10ef69798891b7e5 SHA512 b46e9a1d40f891c5f3544d8cc6295900bff5dda9a4a526b8db55a42a37ae90deb216b316d2117984e82f4e918d15343e75b3b9e6d6c773866707c3398e032826
+DIST llvm-project-db8ef6188cbbe2125e6d60bdef77a535105772df.tar.gz 218416682 BLAKE2B 691e3881e4a60c008c6b766b51ecc856122de1f40242ff1d91ebaa12682fea0a22f84783eb930c42d196f50ba0d3b2010f9010ed73ee7e292fe78c93d6e3f324 SHA512 2dc16a603b60607cc3daee2de0126a567a78c4fff72b2fbcb94c82472bc5ec64ac354ba8592b9a643248a5bfd43b34e2a60f2751a0c9e9e28b7f895fc50a5e9d
 DIST llvm-project-fd7d7882e7fa5a38d4bfde426120d4663718beb4.tar.gz 218217769 BLAKE2B a6c2aa012c342e31527b7e9f85e8fea3549d52530d8f87cd699e094a0aa768d099f9fd2631161ff7f53b4a5011937ed6d1f52b8fa1d23aa34183be1f487d4277 SHA512 c4863fab1a3c03f7f9c42f3501d3a75cebb491343515d77d30b26e5cbd720fc3fd628052099d87ed638e8c424bcbe7a1d066ed857f73da6f243d3d5a76b0e6c5

diff --git a/sys-libs/libcxx/libcxx-20.0.0_pre20240815.ebuild b/sys-libs/libcxx/libcxx-20.0.0_pre20240815.ebuild
new file mode 100644
index 000000000000..a0d07e1507f4
--- /dev/null
+++ b/sys-libs/libcxx/libcxx-20.0.0_pre20240815.ebuild
@@ -0,0 +1,201 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..13} )
+inherit cmake-multilib flag-o-matic llvm.org llvm-utils python-any-r1
+inherit toolchain-funcs
+
+DESCRIPTION="New implementation of the C++ standard library, targeting C++11"
+HOMEPAGE="https://libcxx.llvm.org/"
+
+LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
+SLOT="0"
+IUSE="+clang +libcxxabi +static-libs test"
+REQUIRED_USE="test? ( clang )"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	libcxxabi? (
+		~sys-libs/libcxxabi-${PV}[static-libs?,${MULTILIB_USEDEP}]
+	)
+	!libcxxabi? ( >=sys-devel/gcc-4.7:=[cxx] )
+"
+DEPEND="
+	${RDEPEND}
+	sys-devel/llvm:${LLVM_MAJOR}
+"
+BDEPEND="
+	clang? (
+		sys-devel/clang:${LLVM_MAJOR}
+	)
+	!test? (
+		${PYTHON_DEPS}
+	)
+	test? (
+		dev-debug/gdb[python]
+		$(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]')
+	)
+"
+
+LLVM_COMPONENTS=( runtimes libcxx{,abi} llvm/{cmake,utils/llvm-lit} cmake )
+llvm.org_set_globals
+
+python_check_deps() {
+	use test || return 0
+	python_has_version "dev-python/lit[${PYTHON_USEDEP}]"
+}
+
+pkg_setup() {
+	python-any-r1_pkg_setup
+
+	if ! use libcxxabi && ! tc-is-gcc ; then
+		eerror "To build ${PN} against libsupc++, you have to use gcc. Other"
+		eerror "compilers are not supported. Please set CC=gcc and CXX=g++"
+		eerror "and try again."
+		die
+	fi
+}
+
+test_compiler() {
+	$(tc-getCXX) ${CXXFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c++ - \
+		<<<'int main() { return 0; }' &>/dev/null
+}
+
+src_configure() {
+	llvm_prepend_path "${LLVM_MAJOR}"
+
+	# note: we need to do this before multilib kicks in since it will
+	# alter the CHOST
+	local cxxabi cxxabi_incs
+	if use libcxxabi; then
+		cxxabi=system-libcxxabi
+		cxxabi_incs="${EPREFIX}/usr/include/c++/v1"
+	else
+		local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)"
+		cxxabi=libsupc++
+		cxxabi_incs="${gcc_inc};${gcc_inc}/${CHOST}"
+	fi
+
+	multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+	if use clang; then
+		local -x CC=${CHOST}-clang
+		local -x CXX=${CHOST}-clang++
+		strip-unsupported-flags
+	fi
+
+	# link to compiler-rt
+	local use_compiler_rt=OFF
+	[[ $(tc-get-c-rtlib) == compiler-rt ]] && use_compiler_rt=ON
+
+	# bootstrap: cmake is unhappy if compiler can't link to stdlib
+	local nolib_flags=( -nodefaultlibs -lc )
+	if ! test_compiler; then
+		if test_compiler "${nolib_flags[@]}"; then
+			local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
+			ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
+		fi
+	fi
+
+	local libdir=$(get_libdir)
+	local mycmakeargs=(
+		-DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+		-DPython3_EXECUTABLE="${PYTHON}"
+		-DLLVM_ENABLE_RUNTIMES=libcxx
+		-DLLVM_INCLUDE_TESTS=OFF
+		-DLLVM_LIBDIR_SUFFIX=${libdir#lib}
+
+		-DLIBCXX_ENABLE_SHARED=ON
+		-DLIBCXX_ENABLE_STATIC=$(usex static-libs)
+		-DLIBCXX_CXX_ABI=${cxxabi}
+		-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi_incs}
+		# we're using our own mechanism for generating linker scripts
+		-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
+		-DLIBCXX_HAS_MUSL_LIBC=$(usex elibc_musl)
+		-DLIBCXX_INCLUDE_BENCHMARKS=OFF
+		-DLIBCXX_INCLUDE_TESTS=$(usex test)
+		-DLIBCXX_INSTALL_MODULES=ON
+		-DLIBCXX_USE_COMPILER_RT=${use_compiler_rt}
+		# this is broken with standalone builds, and also meaningless
+		-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
+	)
+
+	if use test; then
+		mycmakeargs+=(
+			-DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
+			-DLLVM_LIT_ARGS="$(get_lit_flags)"
+			-DPython3_EXECUTABLE="${PYTHON}"
+		)
+	fi
+	cmake_src_configure
+}
+
+multilib_src_compile() {
+	cmake_src_compile
+	if [[ ${CHOST} != *-darwin* ]] ; then
+		gen_shared_ldscript
+		use static-libs && gen_static_ldscript
+	fi
+}
+
+multilib_src_test() {
+	local -x LIT_PRESERVES_TMP=1
+	cmake_build check-cxx
+}
+
+multilib_src_install() {
+	cmake_src_install
+	# since we've replaced libc++.{a,so} with ldscripts, now we have to
+	# install the extra symlinks
+	if [[ ${CHOST} != *-darwin* ]] ; then
+		dolib.so lib/libc++_shared.so
+		use static-libs && dolib.a lib/libc++_static.a
+	fi
+}
+
+# Usage: deps
+gen_ldscript() {
+	local output_format
+	output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
+	[[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
+
+	cat <<-END_LDSCRIPT
+/* GNU ld script
+   Include missing dependencies
+*/
+${output_format}
+GROUP ( $@ )
+END_LDSCRIPT
+}
+
+gen_static_ldscript() {
+	# Move it first.
+	mv lib/libc++{,_static}.a || die
+	# Generate libc++.a ldscript for inclusion of its dependencies so that
+	# clang++ -stdlib=libc++ -static works out of the box.
+	local deps=(
+		libc++_static.a
+		$(usex libcxxabi libc++abi.a libsupc++.a)
+	)
+	# On Linux/glibc it does not link without libpthread or libdl. It is
+	# fine on FreeBSD.
+	use elibc_glibc && deps+=( libpthread.a libdl.a )
+
+	gen_ldscript "${deps[*]}" > lib/libc++.a || die
+}
+
+gen_shared_ldscript() {
+	# Move it first.
+	mv lib/libc++{,_shared}.so || die
+	local deps=(
+		libc++_shared.so
+		# libsupc++ doesn't have a shared version
+		$(usex libcxxabi libc++abi.so libsupc++.a)
+	)
+
+	gen_ldscript "${deps[*]}" > lib/libc++.so || die
+}