From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1380420-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 79EE215808B
	for <garchives@archives.gentoo.org>; Mon, 28 Mar 2022 06:20:58 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 73E48E0966;
	Mon, 28 Mar 2022 06:20:57 +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) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id EF32EE0966
	for <gentoo-commits@lists.gentoo.org>; Mon, 28 Mar 2022 06:20:56 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id B6C00340E2C
	for <gentoo-commits@lists.gentoo.org>; Mon, 28 Mar 2022 06:20:55 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 02570177
	for <gentoo-commits@lists.gentoo.org>; Mon, 28 Mar 2022 06:20:54 +0000 (UTC)
From: "Sam James" <sam@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, "Sam James" <sam@gentoo.org>
Message-ID: <1648448445.bb88e766897f5e7e0b0a10c48cf99a04edb73a40.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/estrip bin/misc-functions.sh
X-VCS-Directories: bin/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: bb88e766897f5e7e0b0a10c48cf99a04edb73a40
X-VCS-Branch: master
Date: Mon, 28 Mar 2022 06:20:54 +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: 17a32877-2ced-4da7-ab50-717b678bb6ee
X-Archives-Hash: 76c742962d0210c3899bfad2455a0b1c

commit:     bb88e766897f5e7e0b0a10c48cf99a04edb73a40
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  5 05:32:45 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Mar 28 06:20:45 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=bb88e766

estrip: avoid calling scanelf twice

We can use the previous scanelf data to not call it again to find
all of the dynamically linked executables/libraries which need stripping.

Bug: https://bugs.gentoo.org/749624
Closes: https://github.com/gentoo/portage/pull/794
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/estrip            |  3 ++-
 bin/misc-functions.sh | 29 +++++++++++++++--------------
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/bin/estrip b/bin/estrip
index cdad58c31..686afb763 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -410,8 +410,9 @@ while read -r x ; do
 done < <(
 	# Use sort -u to eliminate duplicates for bug #445336.
 	(
-		scanelf -yqRBF '#k%F' -k '.symtab' "$@"
 		find "$@" -type f ! -type l -name '*.a'
+		cut -d ' ' -f1 < "${PORTAGE_BUILDDIR}"/build-info/NEEDED \
+			| sed -e "s:^:${ED}:"
 	) | LC_ALL=C sort -u
 )
 else

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index ccb07075f..0e1791937 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -151,20 +151,6 @@ install_qa_check() {
 		"${PORTAGE_BIN_PATH}"/ecompress --dequeue
 	fi
 
-	# If binpkg-dostrip is enabled, apply stripping before creating
-	# the binary package.
-	# Note: disabling it won't help with packages calling prepstrip directly.
-	if has binpkg-dostrip ${FEATURES}; then
-		export STRIP_MASK
-		if ___eapi_has_dostrip; then
-			"${PORTAGE_BIN_PATH}"/estrip --queue "${PORTAGE_DOSTRIP[@]}"
-			"${PORTAGE_BIN_PATH}"/estrip --ignore "${PORTAGE_DOSTRIP_SKIP[@]}"
-			"${PORTAGE_BIN_PATH}"/estrip --dequeue
-		else
-			prepallstrip
-		fi
-	fi
-
 	if has chflags $FEATURES ; then
 		# Restore all the file flags that were saved earlier on.
 		mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
@@ -249,6 +235,21 @@ install_qa_check() {
 		fi
 	fi
 
+	# If binpkg-dostrip is enabled, apply stripping before creating
+	# the binary package.
+	# Note: disabling it won't help with packages calling prepstrip directly.
+	# We do this after the scanelf bits so that we can reuse the data. bug #749624.
+	if has binpkg-dostrip ${FEATURES}; then
+		export STRIP_MASK
+		if ___eapi_has_dostrip; then
+			"${PORTAGE_BIN_PATH}"/estrip --queue "${PORTAGE_DOSTRIP[@]}"
+			"${PORTAGE_BIN_PATH}"/estrip --ignore "${PORTAGE_DOSTRIP_SKIP[@]}"
+			"${PORTAGE_BIN_PATH}"/estrip --dequeue
+		else
+			prepallstrip
+		fi
+	fi
+
 	# Portage regenerates this on the installed system.
 	rm -f "${ED%/}"/usr/share/info/dir{,.gz,.bz2} || die "rm failed!"
 }