From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1114210-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id DB148138334
	for <garchives@archives.gentoo.org>; Wed,  2 Oct 2019 20:27:43 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 26AE7E08AC;
	Wed,  2 Oct 2019 20:27:43 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 0285AE08AC
	for <gentoo-commits@lists.gentoo.org>; Wed,  2 Oct 2019 20:27:42 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id E6A6134B7BD
	for <gentoo-commits@lists.gentoo.org>; Wed,  2 Oct 2019 20:27:40 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 331B4771
	for <gentoo-commits@lists.gentoo.org>; Wed,  2 Oct 2019 20:27:38 +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: <1570048054.22a57fe378193e3fff45dac0d668eaeecc3aee9f.mgorny@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/llvm/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-devel/llvm/llvm-10.0.0.9999.ebuild
X-VCS-Directories: sys-devel/llvm/
X-VCS-Committer: mgorny
X-VCS-Committer-Name: Michał Górny
X-VCS-Revision: 22a57fe378193e3fff45dac0d668eaeecc3aee9f
X-VCS-Branch: master
Date: Wed,  2 Oct 2019 20:27:38 +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: 905a4079-99f9-404f-b798-f340f0b76800
X-Archives-Hash: bb729ae76f79decd94882ae70862b4a2

commit:     22a57fe378193e3fff45dac0d668eaeecc3aee9f
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 10 11:52:29 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Oct  2 20:27:34 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=22a57fe3

sys-devel/llvm: Switch 10+ to dylib build

Build and install the single dylib instead of split shared libs in 10+.

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

 sys-devel/llvm/llvm-10.0.0.9999.ebuild | 182 ++++++++++++++++++++++++++++++++-
 1 file changed, 180 insertions(+), 2 deletions(-)

diff --git a/sys-devel/llvm/llvm-10.0.0.9999.ebuild b/sys-devel/llvm/llvm-10.0.0.9999.ebuild
index 92a9c5ae1c1..eccfd8a533b 100644
--- a/sys-devel/llvm/llvm-10.0.0.9999.ebuild
+++ b/sys-devel/llvm/llvm-10.0.0.9999.ebuild
@@ -122,6 +122,62 @@ check_live_ebuild() {
 	fi
 }
 
+check_distribution_components() {
+	if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]]; then
+		local all_targets=() my_targets=() l
+		cd "${BUILD_DIR}" || die
+
+		while read -r l; do
+			if [[ ${l} == install-*-stripped:* ]]; then
+				l=${l#install-}
+				l=${l%%-stripped*}
+
+				case ${l} in
+					# shared libs
+					LLVM|LLVMgold)
+						;;
+					# TableGen lib + deps
+					LLVMDemangle|LLVMSupport|LLVMTableGen)
+						;;
+					# static libs
+					LLVM*)
+						continue
+						;;
+					# meta-targets
+					distribution|llvm-libraries)
+						continue
+						;;
+				esac
+
+				all_targets+=( "${l}" )
+			fi
+		done < <(ninja -t targets all)
+
+		while read -r l; do
+			my_targets+=( "${l}" )
+		done < <(get_distribution_components $"\n")
+
+		local add=() remove=()
+		for l in "${all_targets[@]}"; do
+			if ! has "${l}" "${my_targets[@]}"; then
+				add+=( "${l}" )
+			fi
+		done
+		for l in "${my_targets[@]}"; do
+			if ! has "${l}" "${all_targets[@]}"; then
+				remove+=( "${l}" )
+			fi
+		done
+
+		if [[ ${#add[@]} -gt 0 || ${#remove[@]} -gt 0 ]]; then
+			eqawarn "get_distribution_components() is outdated!"
+			eqawarn "   Add: ${add[*]}"
+			eqawarn "Remove: ${remove[*]}"
+		fi
+		cd - >/dev/null || die
+	fi
+}
+
 src_prepare() {
 	# Fix llvm-config for shared linking and sane flags
 	# https://bugs.gentoo.org/show_bug.cgi?id=565358
@@ -149,6 +205,122 @@ is_libcxx_linked() {
 	[[ ${out} == *HAVE_LIBCXX* ]]
 }
 
+get_distribution_components() {
+	local sep=${1-;}
+
+	local out=(
+		# shared libs
+		LLVM
+		LTO
+		Remarks
+
+		# tools
+		llvm-config
+
+		# common stuff
+		cmake-exports
+		llvm-headers
+
+		# libraries needed for clang-tblgen
+		LLVMDemangle
+		LLVMSupport
+		LLVMTableGen
+	)
+
+	if multilib_is_native_abi; then
+		out+=(
+			# utilities
+			llvm-tblgen
+			FileCheck
+			llvm-PerfectShuffle
+			count
+			not
+			yaml-bench
+
+			# tools
+			bugpoint
+			dsymutil
+			llc
+			lli
+			lli-child-target
+			llvm-addr2line
+			llvm-ar
+			llvm-as
+			llvm-bcanalyzer
+			llvm-c-test
+			llvm-cat
+			llvm-cfi-verify
+			llvm-config
+			llvm-cov
+			llvm-cvtres
+			llvm-cxxdump
+			llvm-cxxfilt
+			llvm-cxxmap
+			llvm-diff
+			llvm-dis
+			llvm-dlltool
+			llvm-dwarfdump
+			llvm-dwp
+			llvm-elfabi
+			llvm-exegesis
+			llvm-extract
+			llvm-ifs
+			llvm-jitlink
+			llvm-lib
+			llvm-link
+			llvm-lipo
+			llvm-lto
+			llvm-lto2
+			llvm-mc
+			llvm-mca
+			llvm-modextract
+			llvm-mt
+			llvm-nm
+			llvm-objcopy
+			llvm-objdump
+			llvm-opt-report
+			llvm-pdbutil
+			llvm-profdata
+			llvm-ranlib
+			llvm-rc
+			llvm-readelf
+			llvm-readobj
+			llvm-reduce
+			llvm-rtdyld
+			llvm-size
+			llvm-split
+			llvm-stress
+			llvm-strings
+			llvm-strip
+			llvm-symbolizer
+			llvm-undname
+			llvm-xray
+			obj2yaml
+			opt
+			sancov
+			sanstats
+			verify-uselistorder
+			yaml2obj
+
+			# python modules
+			opt-viewer
+		)
+
+		use doc && out+=(
+			docs-dsymutil-man
+			docs-llvm-dwarfdump-man
+			docs-llvm-man
+			docs-llvm-html
+		)
+
+		use gold && out+=(
+			LLVMgold
+		)
+	fi
+
+	printf "%s${sep}" "${out[@]}"
+}
+
 multilib_src_configure() {
 	local ffi_cflags ffi_ldflags
 	if use libffi; then
@@ -164,7 +336,11 @@ multilib_src_configure() {
 		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}"
 		-DLLVM_LIBDIR_SUFFIX=${libdir#lib}
 
-		-DBUILD_SHARED_LIBS=ON
+		-DBUILD_SHARED_LIBS=OFF
+		-DLLVM_BUILD_LLVM_DYLIB=ON
+		-DLLVM_LINK_LLVM_DYLIB=ON
+		-DLLVM_DISTRIBUTION_COMPONENTS=$(get_distribution_components)
+
 		# cheap hack: LLVM combines both anyway, and the only difference
 		# is that the former list is explicitly verified at cmake time
 		-DLLVM_TARGETS_TO_BUILD=""
@@ -256,6 +432,8 @@ multilib_src_configure() {
 	# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
 	use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
 	cmake-utils_src_configure
+
+	multilib_is_native_abi && check_distribution_components
 }
 
 multilib_src_compile() {
@@ -295,7 +473,7 @@ src_install() {
 }
 
 multilib_src_install() {
-	cmake-utils_src_install
+	DESTDIR=${D} cmake-utils_src_make install-distribution
 
 	# move headers to /usr/include for wrapping
 	rm -rf "${ED}"/usr/include || die