From 33056c4e55b76cfdcee02c206acbfd770d7ae378 Mon Sep 17 00:00:00 2001 From: Sam James Date: Sat, 9 Mar 2024 02:51:47 +0000 Subject: [PATCH] sys-devel/binutils: rework LTO handling Get tests passing when LTO is used and rework USE=pgo handling while at it, as it's interlinked with LTO b/c of the upstream infra for it. This follows on from: * 1764651a4f7daf8d622db7fddeea891809cab2fb * f900949be85e2b2b21cd68b7f5163208d0429028 * f900949be85e2b2b21cd68b7f5163208d0429028 where I kept hitting misc issues where the build for the live ebuild failed with LTO or otherwise. With this, I only needed one patch to libctf's tests [0] which I've now pinged upstream. (I also had an odd single gprofng failure I haven't looked at yet.) * For LTO + (tests || pgo), always filter '-Wa,*'. This is an unfortunate one, but the bootstrap test fails with it. * USE=pgo no longer implies LTO. If -flto is being used, then we pass --enable-pgo-build=lto. If not, we pass --enable-pgo-build=yes. * For USE=pgo, filter out LTO after we applied the build system configuration, because otherwise there's a risk we're going to break the tests used for profiling. * In src_test, use a subshell to localise the filtering of flags we do. * For tests, pass {C,CXX,LD}FLAGS_FOR_TARGET to make, as otherwise it'll use what it found from configure (and e.g. pick up LTO again -> many tests fail as they're not intended to be used with it). [0] https://inbox.sourceware.org/binutils/87sf2evr35.fsf@esperi.org.uk/ Signed-off-by: Sam James --- sys-devel/binutils/binutils-9999.ebuild | 32 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/sys-devel/binutils/binutils-9999.ebuild b/sys-devel/binutils/binutils-9999.ebuild index 9169e3ca712c5..9b30843ce94fa 100644 --- a/sys-devel/binutils/binutils-9999.ebuild +++ b/sys-devel/binutils/binutils-9999.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() {