From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1609086-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 C3AA7158041
	for <garchives@archives.gentoo.org>; Sat,  9 Mar 2024 21:55:34 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 06658E2A42;
	Sat,  9 Mar 2024 21:55:34 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.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 E0BA4E2A42
	for <gentoo-commits@lists.gentoo.org>; Sat,  9 Mar 2024 21:55:33 +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 2994933BF3B
	for <gentoo-commits@lists.gentoo.org>; Sat,  9 Mar 2024 21:55:33 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id AE3121108
	for <gentoo-commits@lists.gentoo.org>; Sat,  9 Mar 2024 21:55:31 +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: <1710021318.68466c8b5bda1cbf82e364763c42c7c9df1dfff0.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/binutils/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-devel/binutils/binutils-2.42-r1.ebuild
X-VCS-Directories: sys-devel/binutils/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 68466c8b5bda1cbf82e364763c42c7c9df1dfff0
X-VCS-Branch: master
Date: Sat,  9 Mar 2024 21:55:31 +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: 5e7198b5-227e-4f93-92d0-912413fd609c
X-Archives-Hash: 38d9f016490106c73e1ebfb4cbf29d66

commit:     68466c8b5bda1cbf82e364763c42c7c9df1dfff0
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  9 21:54:27 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Mar  9 21:55:18 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=68466c8b

sys-devel/binutils: backport LTO fixes to 2.42-r1

>From 33056c4e55b76cfdcee02c206acbfd770d7ae378.

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

 sys-devel/binutils/binutils-2.42-r1.ebuild | 32 ++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/sys-devel/binutils/binutils-2.42-r1.ebuild b/sys-devel/binutils/binutils-2.42-r1.ebuild
index 247aaaa1fa03..a7bca7df85af 100644
--- a/sys-devel/binutils/binutils-2.42-r1.ebuild
+++ b/sys-devel/binutils/binutils-2.42-r1.ebuild
@@ -333,10 +333,20 @@ src_configure() {
 		)
 	fi
 
+	if use test || { use pgo && tc-is-lto ; } ; then
+		# -Wa,* needs to be consistent everywhere or lto-wrapper will complain
+		filter-flags '-Wa,*'
+	fi
+
 	if ! is_cross ; then
-		myconf+=( $(use_enable pgo pgo-build lto) )
+		myconf+=( $(use_enable pgo pgo-build $(tc-is-lto && echo "lto" || echo "yes")) )
 
 		if use pgo ; then
+			# We let configure handle it for us because it has to run
+			# the testsuite later on for profiling, and LTO isn't compatible
+			# with the testsuite.
+			filter-lto
+
 			export BUILD_CFLAGS="${CFLAGS}"
 		fi
 	fi
@@ -378,10 +388,24 @@ src_test() {
 	local -x XZ_OPT="-T1"
 	local -x XZ_DEFAULTS="-T1"
 
-	# bug #637066
-	filter-flags -Wall -Wreturn-type
+	(
+		# Tests don't expect LTO
+		filter-lto
 
-	emake -k check
+		# lto-wrapper warnings which confuse tests
+		filter-flags '-Wa,*'
+
+		# bug #637066
+		filter-flags -Wall -Wreturn-type
+
+		emake -k check \
+			CFLAGS_FOR_TARGET="${CFLAGS_FOR_TARGET:-${CFLAGS}}" \
+			CXXFLAGS_FOR_TARGET="${CXXFLAGS_FOR_TARGET:-${CXXFLAGS}}" \
+			LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET:-${LDFLAGS}}" \
+			CFLAGS="${CFLAGS}" \
+			CXXFLAGS="${CXXFLAGS}" \
+			LDFLAGS="${LDFLAGS}"
+	)
 }
 
 src_install() {