commit:     21f52fa7265f10d9d62df5b9d4194b772e81795b
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 15 23:46:12 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 15 23:46:22 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=21f52fa7

sys-devel/bpf-toolchain: fix stripping like dev-util/mingw64-toolchain does

(Revbumped in previous commit.)

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

 sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r2.ebuild | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r2.ebuild 
b/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r2.ebuild
index 093dcc4f54dd..ddd76d00070c 100644
--- a/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r2.ebuild
+++ b/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r2.ebuild
@@ -41,8 +41,7 @@ LICENSE="
 "
 SLOT="0"
 KEYWORDS="-* ~amd64"
-# TODO: USE=strip from dev-util/mingw64-toolchain?
-IUSE="+bin-symlinks custom-cflags"
+IUSE="+bin-symlinks custom-cflags +strip"
 
 RDEPEND="
        dev-libs/gmp:=
@@ -194,6 +193,17 @@ src_compile() {
        # which does not make use of cross-library dependencies: the libdep.a
        # for the native binutils will do.
        rm -f ${sysroot}/lib/bfd-plugins/libdep.a || die
+
+       # portage doesn't know the right strip executable to use for CTARGET
+       # and it can lead to .a mangling, notably with 32bit (breaks toolchain)
+       dostrip -x ${bpftdir}/{${CTARGET}/lib{,32},lib/gcc/${CTARGET}}
+
+       # ... and instead do it here given this saves ~60MB
+       if use strip; then
+               einfo "Stripping ${CTARGET} static libraries ..."
+               find "${sysroot}"/{,lib/gcc/}${CTARGET} -type f -name '*.a' \
+                       -exec ${CTARGET}-strip --strip-unneeded {} + || die
+       fi
 }
 
 src_install() {

Reply via email to