Strip LTO sections/symbols from installed .o/.a files

This commit is contained in:
Jeff Law 2020-01-08 11:25:43 -07:00 committed by Igor Raits
parent 9ce99265fd
commit 20749d9857
No known key found for this signature in database
GPG Key ID: 695714BD1BBC5F4C
3 changed files with 25 additions and 1 deletions

18
brp-strip-lto Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/sh
# If using normal root, avoid changing anything.
if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then
exit 0
fi
STRIP=${1:-strip}
case `uname -a` in
Darwin*) exit 0 ;;
*) ;;
esac
# Strip ELF binaries
for f in `find "$RPM_BUILD_ROOT" -type f -name \*.[ao] -print | \
grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"`; do
$STRIP -p -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1 "$f" || :
done

2
macros
View File

@ -146,6 +146,7 @@ print(result)
%__brp_ldconfig /usr/lib/rpm/redhat/brp-ldconfig
%__brp_compress /usr/lib/rpm/brp-compress
%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
%__brp_strip_lto /usr/lib/rpm/redhat/brp-strip-lto %{__strip}
%__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
%__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip}
%__brp_python_bytecompile /usr/lib/rpm/redhat/brp-python-bytecompile "%{__python}" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}"
@ -163,6 +164,7 @@ print(result)
%{?__brp_strip} \
%{?__brp_strip_comment_note} \
} \
%{?__brp_strip_lto} \
%{?__brp_strip_static_archive} \
%{?py_auto_byte_compile:%{?__brp_python_bytecompile}} \
%{?__brp_python_hardlink} \

View File

@ -6,7 +6,7 @@
Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config
Version: 149
Version: 150
Release: 1%{?dist}
# No version specified.
License: GPL+
@ -78,6 +78,7 @@ Source602: libsymlink.attr
# BRPs
Source700: brp-ldconfig
Source701: brp-strip-lto
# Convenience lua functions
Source800: common.lua
@ -207,6 +208,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
%{_rpmconfigdir}/macros.d/macros.kmp
%changelog
* Fri Feb 14 2019 Jeff Law <law@redhat.com> - 150-1
- Strip LTO sections/symbols from installed .o/.a files
* Thu Jan 23 2020 Jeff Law <law@redhat.com> - 149-1
- Allow conditionally adding -fcommon to CFLAGS by defining %%_legacy_common_support