From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1562129-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 163EE158089
	for <garchives@archives.gentoo.org>; Thu, 12 Oct 2023 12:05:36 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 2F4822BC01B;
	Thu, 12 Oct 2023 12:05:35 +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 9FBBD2BC01B
	for <gentoo-commits@lists.gentoo.org>; Thu, 12 Oct 2023 12:05:34 +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 7C2C4335C20
	for <gentoo-commits@lists.gentoo.org>; Thu, 12 Oct 2023 12:05:33 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 0A015ECB
	for <gentoo-commits@lists.gentoo.org>; Thu, 12 Oct 2023 12:05:32 +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: <1697112300.1d98516e65fb3dc0f1e0effc851216e1b827b9d4.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/
X-VCS-Repository: repo/gentoo
X-VCS-Files: app-shells/bash/bash-5.2_p15-r7.ebuild app-shells/bash/bash-9999.ebuild
X-VCS-Directories: app-shells/bash/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 1d98516e65fb3dc0f1e0effc851216e1b827b9d4
X-VCS-Branch: master
Date: Thu, 12 Oct 2023 12:05:32 +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: 5cfadc04-0adf-4f5d-a892-920191e28195
X-Archives-Hash: 470962dc51c18af95ae6bae488719ca2

commit:     1d98516e65fb3dc0f1e0effc851216e1b827b9d4
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 12 12:01:54 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 12 12:05:00 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1d98516e

app-shells/bash: cleanup USE=pgo logic a bit, use -fprofile-partial-training if available

-fprofile-partial-training helps not to pessimise other paths if no data
is available.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../{bash-9999.ebuild => bash-5.2_p15-r7.ebuild}   | 28 ++++++++++++----------
 app-shells/bash/bash-9999.ebuild                   | 25 +++++++++----------
 2 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/app-shells/bash/bash-9999.ebuild b/app-shells/bash/bash-5.2_p15-r7.ebuild
similarity index 90%
copy from app-shells/bash/bash-9999.ebuild
copy to app-shells/bash/bash-5.2_p15-r7.ebuild
index eeff3e0b3023..af96b44e4a86 100644
--- a/app-shells/bash/bash-9999.ebuild
+++ b/app-shells/bash/bash-5.2_p15-r7.ebuild
@@ -1,7 +1,7 @@
 # Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
 VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/chetramey.asc
 inherit flag-o-matic toolchain-funcs prefix verify-sig
@@ -115,6 +115,9 @@ PATCHES=(
 
 	# Patches from Chet sent to bash-bug ml
 	"${FILESDIR}"/${PN}-5.0-syslog-history-extern.patch
+	"${FILESDIR}"/${PN}-5.2_p15-random-ub.patch
+	"${FILESDIR}"/${PN}-5.2_p15-configure-clang16.patch
+	"${FILESDIR}"/${PN}-5.2_p15-shell-parser-reset-issue.patch
 )
 
 pkg_setup() {
@@ -254,14 +257,20 @@ src_configure() {
 }
 
 src_compile() {
-	if use pgo ; then
-		# Build Bash and run its tests to generate profiles.
-		emake CFLAGS="${CFLAGS} -fprofile-generate=${T}/pgo -fprofile-dir=${T}/pgo"
+	# -fprofile-partial-training because upstream note the test suite isn't super comprehensive
+	# See https://documentation.suse.com/sbp/all/html/SBP-GCC-10/index.html#sec-gcc10-pgo
+	local pgo_generate_flags=$(usev pgo "-fprofile-update=atomic -fprofile-dir=${T}/pgo -fprofile-generate=${T}/pgo $(test-flags-CC -fprofile-partial-training)")
+	local pgo_use_flags=$(usev pgo "-fprofile-use=${T}/pgo -fprofile-dir=${T}/pgo")
+
+	emake CFLAGS="${CFLAGS} ${pgo_generate_flags}"
+	use plugins && emake -C examples/loadables CFLAGS="${CFLAGS} ${pgo_generate_flags}" all others
 
+	# Build Bash and run its tests to generate profiles.
+	if use pgo ; then
 		# Used in test suite.
 		unset A
 
-		emake CFLAGS="${CFLAGS} -fprofile-generate=${T}/pgo -fprofile-dir=${T}/pgo" -k check
+		emake CFLAGS="${CFLAGS} ${pgo_generate_flags}" -k check
 
 		if tc-is-clang; then
 			llvm-profdata merge "${T}"/pgo --output="${T}"/pgo/default.profdata || die
@@ -269,13 +278,8 @@ src_compile() {
 
 		# Rebuild Bash using the profiling data we just generated.
 		emake clean
-		emake CFLAGS="${CFLAGS} -fprofile-use=${T}/pgo -fprofile-dir=${T}/pgo"
-
-		use plugins && emake -C examples/loadables CFLAGS="${CFLAGS} -fprofile-use=${T}/pgo -fprofile-dir=${T}/pgo" all others
-	else
-		emake
-
-		use plugins && emake -C examples/loadables all others
+		emake CFLAGS="${CFLAGS} ${pgo_use_flags}"
+		use plugins && emake -C examples/loadables CFLAGS="${CFLAGS} ${pgo_use_flags}" all others
 	fi
 }
 

diff --git a/app-shells/bash/bash-9999.ebuild b/app-shells/bash/bash-9999.ebuild
index eeff3e0b3023..e2a0d09d841b 100644
--- a/app-shells/bash/bash-9999.ebuild
+++ b/app-shells/bash/bash-9999.ebuild
@@ -1,7 +1,7 @@
 # Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
 VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/chetramey.asc
 inherit flag-o-matic toolchain-funcs prefix verify-sig
@@ -254,14 +254,20 @@ src_configure() {
 }
 
 src_compile() {
-	if use pgo ; then
-		# Build Bash and run its tests to generate profiles.
-		emake CFLAGS="${CFLAGS} -fprofile-generate=${T}/pgo -fprofile-dir=${T}/pgo"
+	# -fprofile-partial-training because upstream note the test suite isn't super comprehensive
+	# See https://documentation.suse.com/sbp/all/html/SBP-GCC-10/index.html#sec-gcc10-pgo
+	local pgo_generate_flags=$(usev pgo "-fprofile-update=atomic -fprofile-dir=${T}/pgo -fprofile-generate=${T}/pgo $(test-flags-CC -fprofile-partial-training)")
+	local pgo_use_flags=$(usev pgo "-fprofile-use=${T}/pgo -fprofile-dir=${T}/pgo")
+
+	emake CFLAGS="${CFLAGS} ${pgo_generate_flags}"
+	use plugins && emake -C examples/loadables CFLAGS="${CFLAGS} ${pgo_generate_flags}" all others
 
+	# Build Bash and run its tests to generate profiles.
+	if use pgo ; then
 		# Used in test suite.
 		unset A
 
-		emake CFLAGS="${CFLAGS} -fprofile-generate=${T}/pgo -fprofile-dir=${T}/pgo" -k check
+		emake CFLAGS="${CFLAGS} ${pgo_generate_flags}" -k check
 
 		if tc-is-clang; then
 			llvm-profdata merge "${T}"/pgo --output="${T}"/pgo/default.profdata || die
@@ -269,13 +275,8 @@ src_compile() {
 
 		# Rebuild Bash using the profiling data we just generated.
 		emake clean
-		emake CFLAGS="${CFLAGS} -fprofile-use=${T}/pgo -fprofile-dir=${T}/pgo"
-
-		use plugins && emake -C examples/loadables CFLAGS="${CFLAGS} -fprofile-use=${T}/pgo -fprofile-dir=${T}/pgo" all others
-	else
-		emake
-
-		use plugins && emake -C examples/loadables all others
+		emake CFLAGS="${CFLAGS} ${pgo_use_flags}"
+		use plugins && emake -C examples/loadables CFLAGS="${CFLAGS} ${pgo_use_flags}" all others
 	fi
 }