From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1444152-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 508E9158094
	for <garchives@archives.gentoo.org>; Thu,  6 Oct 2022 22:19:12 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 183A2E09BE;
	Thu,  6 Oct 2022 22:19:11 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(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 F1BBDE09BE
	for <gentoo-commits@lists.gentoo.org>; Thu,  6 Oct 2022 22:19:10 +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 1B10F340FD8
	for <gentoo-commits@lists.gentoo.org>; Thu,  6 Oct 2022 22:19:10 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 779F255B
	for <gentoo-commits@lists.gentoo.org>; Thu,  6 Oct 2022 22:19:08 +0000 (UTC)
From: "Georgy Yakovlev" <gyakovlev@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, "Georgy Yakovlev" <gyakovlev@gentoo.org>
Message-ID: <1665094715.33f9d1b26716280ef7b8644c7c86e0e67ed9d17c.gyakovlev@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/
X-VCS-Repository: repo/gentoo
X-VCS-Files: dev-lang/rust/rust-1.62.1.ebuild dev-lang/rust/rust-1.63.0-r1.ebuild
X-VCS-Directories: dev-lang/rust/
X-VCS-Committer: gyakovlev
X-VCS-Committer-Name: Georgy Yakovlev
X-VCS-Revision: 33f9d1b26716280ef7b8644c7c86e0e67ed9d17c
X-VCS-Branch: master
Date: Thu,  6 Oct 2022 22:19:08 +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: 862b21cf-4ad4-4240-bcf3-f1b18567e4f1
X-Archives-Hash: 86a7e890efff1f79ac368f227a87ed1d

commit:     33f9d1b26716280ef7b8644c7c86e0e67ed9d17c
Author:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  6 22:18:35 2022 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Thu Oct  6 22:18:35 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=33f9d1b2

dev-lang/rust: backport is_libcxx_linked to older versions

Closes: https://bugs.gentoo.org/875563
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 dev-lang/rust/rust-1.62.1.ebuild    | 24 ++++++++++++++----------
 dev-lang/rust/rust-1.63.0-r1.ebuild | 24 ++++++++++++++----------
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/dev-lang/rust/rust-1.62.1.ebuild b/dev-lang/rust/rust-1.62.1.ebuild
index 14499d27ee4f..330a83219754 100644
--- a/dev-lang/rust/rust-1.62.1.ebuild
+++ b/dev-lang/rust/rust-1.62.1.ebuild
@@ -222,6 +222,17 @@ llvm_check_deps() {
 	has_version -r "sys-devel/llvm:${LLVM_SLOT}[${LLVM_TARGET_USEDEPS// /,}]"
 }
 
+# Is LLVM being linked against libc++?
+is_libcxx_linked() {
+	local code='#include <ciso646>
+#if defined(_LIBCPP_VERSION)
+	HAVE_LIBCXX
+#endif
+'
+	local out=$($(tc-getCXX) ${CXXFLAGS} ${CPPFLAGS} -x c++ -E -P - <<<"${code}") || return 1
+	[[ ${out} == *HAVE_LIBCXX* ]]
+}
+
 pkg_pretend() {
 	pre_build_checks
 }
@@ -258,7 +269,7 @@ src_prepare() {
 src_configure() {
 	filter-flags '-flto*' # https://bugs.gentoo.org/862109
 
-	local rust_target="" rust_targets="" arch_cflags use_libcxx="false"
+	local rust_target="" rust_targets="" arch_cflags
 
 	# Collect rust target names to compile standard libs for all ABIs.
 	for v in $(multilib_get_enabled_abi_pairs); do
@@ -307,14 +318,6 @@ src_configure() {
 
 	rust_target="$(rust_abi)"
 
-	# https://bugs.gentoo.org/732632
-	if tc-is-clang; then
-		local clang_slot="$(clang-major-version)"
-		if { has_version "sys-devel/clang:${clang_slot}[default-libcxx(-)]" || has_version "=sys-devel/clang-common-${clang_slot}*[default-libcxx(-)]" || is-flagq -stdlib=libc++; }; then
-			use_libcxx="true"
-		fi
-	fi
-
 	local cm_btype="$(usex debug DEBUG RELEASE)"
 	cat <<- _EOF_ > "${S}"/config.toml
 		changelog-seen = 2
@@ -327,7 +330,8 @@ src_configure() {
 		targets = "${LLVM_TARGETS// /;}"
 		experimental-targets = ""
 		link-shared = $(toml_usex system-llvm)
-		$(if [[ ${use_libcxx} == true ]]; then
+		$(if is_libcxx_linked; then
+			# https://bugs.gentoo.org/732632
 			echo "use-libcxx = true"
 			echo "static-libstdcpp = false"
 		fi)

diff --git a/dev-lang/rust/rust-1.63.0-r1.ebuild b/dev-lang/rust/rust-1.63.0-r1.ebuild
index 0e8a344f1bd1..d0595ed73590 100644
--- a/dev-lang/rust/rust-1.63.0-r1.ebuild
+++ b/dev-lang/rust/rust-1.63.0-r1.ebuild
@@ -232,6 +232,17 @@ llvm_check_deps() {
 	has_version -r "sys-devel/llvm:${LLVM_SLOT}[${LLVM_TARGET_USEDEPS// /,}]"
 }
 
+# Is LLVM being linked against libc++?
+is_libcxx_linked() {
+	local code='#include <ciso646>
+#if defined(_LIBCPP_VERSION)
+	HAVE_LIBCXX
+#endif
+'
+	local out=$($(tc-getCXX) ${CXXFLAGS} ${CPPFLAGS} -x c++ -E -P - <<<"${code}") || return 1
+	[[ ${out} == *HAVE_LIBCXX* ]]
+}
+
 pkg_pretend() {
 	pre_build_checks
 }
@@ -288,7 +299,7 @@ src_prepare() {
 src_configure() {
 	filter-flags '-flto*' # https://bugs.gentoo.org/862109
 
-	local rust_target="" rust_targets="" arch_cflags use_libcxx="false"
+	local rust_target="" rust_targets="" arch_cflags
 
 	# Collect rust target names to compile standard libs for all ABIs.
 	for v in $(multilib_get_enabled_abi_pairs); do
@@ -337,14 +348,6 @@ src_configure() {
 
 	rust_target="$(rust_abi)"
 
-	# https://bugs.gentoo.org/732632
-	if tc-is-clang; then
-		local clang_slot="$(clang-major-version)"
-		if { has_version "sys-devel/clang:${clang_slot}[default-libcxx(-)]" || has_version "=sys-devel/clang-common-${clang_slot}*[default-libcxx(-)]" || is-flagq -stdlib=libc++; }; then
-			use_libcxx="true"
-		fi
-	fi
-
 	local cm_btype="$(usex debug DEBUG RELEASE)"
 	cat <<- _EOF_ > "${S}"/config.toml
 		changelog-seen = 2
@@ -357,7 +360,8 @@ src_configure() {
 		targets = "${LLVM_TARGETS// /;}"
 		experimental-targets = ""
 		link-shared = $(toml_usex system-llvm)
-		$(if [[ ${use_libcxx} == true ]]; then
+		$(if is_libcxx_linked; then
+			# https://bugs.gentoo.org/732632
 			echo "use-libcxx = true"
 			echo "static-libstdcpp = false"
 		fi)