commit: c2846b5abad0679a5e800c48999a78f4bc475648 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Thu Oct 12 11:28:56 2023 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Thu Oct 12 12:04:59 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c2846b5a
app-arch/xz-utils: add USE=pgo Binary gets a bit smaller: 91K->83K. For decompression times, it's really within noise, <5%. I didn't poke at compress times. The times at https://forum.openmandriva.org/t/pgo-xz/2543 are a bit better than what I saw (I tried with linux-6.5.tar.xz, chromium-118.0.5993.70.tar.xz). opensuse is also doing pgo w/ xz. Signed-off-by: Sam James <sam <AT> gentoo.org> app-arch/xz-utils/metadata.xml | 1 + app-arch/xz-utils/xz-utils-5.4.4.ebuild | 23 +++++++++++++++++++++-- app-arch/xz-utils/xz-utils-9999.ebuild | 25 ++++++++++++++++++++----- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/app-arch/xz-utils/metadata.xml b/app-arch/xz-utils/metadata.xml index 89d8ff67986f..3b217f332fdd 100644 --- a/app-arch/xz-utils/metadata.xml +++ b/app-arch/xz-utils/metadata.xml @@ -9,6 +9,7 @@ <flag name="extra-filters">Build additional filters that are not used in any of the default xz presets. This includes delta and BCJ coders, additional match finders and SHA256 checks.</flag> + <flag name="pgo">Optimize the build using Profile Guided Optimization (PGO)</flag> </use> <upstream> <remote-id type="cpe">cpe:/a:tukaani:xz</remote-id> diff --git a/app-arch/xz-utils/xz-utils-5.4.4.ebuild b/app-arch/xz-utils/xz-utils-5.4.4.ebuild index 11ddc15f918b..b51831556293 100644 --- a/app-arch/xz-utils/xz-utils-5.4.4.ebuild +++ b/app-arch/xz-utils/xz-utils-5.4.4.ebuild @@ -6,7 +6,7 @@ EAPI=8 -inherit libtool multilib multilib-minimal preserve-libs usr-ldscript +inherit flag-o-matic libtool multilib multilib-minimal preserve-libs usr-ldscript if [[ ${PV} == 9999 ]] ; then # Per tukaani.org, git.tukaani.org is a mirror of github and @@ -47,7 +47,7 @@ HOMEPAGE="https://tukaani.org/xz/" # See top-level COPYING file as it outlines the various pieces and their licenses. LICENSE="public-domain LGPL-2.1+ GPL-2+" SLOT="0" -IUSE="doc +extra-filters nls static-libs" +IUSE="doc +extra-filters pgo nls static-libs" if [[ ${PV} != 9999 ]] ; then BDEPEND+=" verify-sig? ( sec-keys/openpgp-keys-jiatan )" @@ -103,6 +103,25 @@ multilib_src_configure() { ECONF_SOURCE="${S}" econf "${myconf[@]}" } +multilib_src_compile() { + # -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}/${ABI}-pgo -fprofile-generate=${T}/${ABI}-pgo $(test-flags-CC -fprofile-partial-training)") + + emake CFLAGS="${CFLAGS} ${pgo_generate_flags}" + + if use pgo ; then + emake CFLAGS="${CFLAGS} ${pgo_generate_flags}" -k check + + if tc-is-clang; then + llvm-profdata merge "${T}"/${ABI}-pgo --output="${T}"/${ABI}-pgo/default.profdata || die + fi + + emake clean + emake CFLAGS="${CFLAGS} -fprofile-use=${T}/${ABI}-pgo -fprofile-dir=${T}/${ABI}-pgo" + fi +} + multilib_src_install() { default diff --git a/app-arch/xz-utils/xz-utils-9999.ebuild b/app-arch/xz-utils/xz-utils-9999.ebuild index 1ab617815a91..b51831556293 100644 --- a/app-arch/xz-utils/xz-utils-9999.ebuild +++ b/app-arch/xz-utils/xz-utils-9999.ebuild @@ -47,7 +47,7 @@ HOMEPAGE="https://tukaani.org/xz/" # See top-level COPYING file as it outlines the various pieces and their licenses. LICENSE="public-domain LGPL-2.1+ GPL-2+" SLOT="0" -IUSE="doc +extra-filters nls static-libs" +IUSE="doc +extra-filters pgo nls static-libs" if [[ ${PV} != 9999 ]] ; then BDEPEND+=" verify-sig? ( sec-keys/openpgp-keys-jiatan )" @@ -100,13 +100,28 @@ multilib_src_configure() { myconf+=( --disable-path-for-script ) fi - # ifunc is incompatible w/ asan - # https://github.com/tukaani-project/xz/issues/62#issuecomment-1719489932 - is-flagq -fsanitize=address && myconf+=( --disable-ifunc ) - ECONF_SOURCE="${S}" econf "${myconf[@]}" } +multilib_src_compile() { + # -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}/${ABI}-pgo -fprofile-generate=${T}/${ABI}-pgo $(test-flags-CC -fprofile-partial-training)") + + emake CFLAGS="${CFLAGS} ${pgo_generate_flags}" + + if use pgo ; then + emake CFLAGS="${CFLAGS} ${pgo_generate_flags}" -k check + + if tc-is-clang; then + llvm-profdata merge "${T}"/${ABI}-pgo --output="${T}"/${ABI}-pgo/default.profdata || die + fi + + emake clean + emake CFLAGS="${CFLAGS} -fprofile-use=${T}/${ABI}-pgo -fprofile-dir=${T}/${ABI}-pgo" + fi +} + multilib_src_install() { default
