rpm-build/scripts/brp-strip-lto.in
Vitaly Chikunov 715065e999 brp: Add brp-strip-lto script
Strip LTO sections and symbols from objects and archives (static
libraries). %brp_strip_none macro is respected.

Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
2021-08-24 00:52:22 +03:00

40 lines
1.2 KiB
Bash
Executable File

#!/bin/sh -efu
#
# brp-strip-lto - Strip LTO sections and symbols from object files
#
# LTO bytecode needs to be stripped for distributions, because it's
# GCC version dependent:
# "The bytecode files are versioned and there is a strict version
# check, so bytecode files generated in one version of GCC do not
# work with an older or newer version of GCC." -- gcc(1).
#
# Based on brp-strip-lto (Fedora) and brp-debuginfo.
# Copyright (c) 2021 Vitaly Chikunov <vt@altlinux.org>.
# License: GPLv2+.
# Implementation notes:
# - xargs -Px -nx to start parallelizing sooner.
# - %brp_strip_none is respected.
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
cd "$RPM_BUILD_ROOT"
mkdir -p .tmp
# They skip /usr/lib/debug from the search, but why. There aren't
# such objects nor meaning to skip stripping them.
# Only skip internal temporary workspace.
find -path './.*' -prune -o -name '*.[ao]' -type f -print | \
while read -r f; do
for pat in ${RPM_BRP_STRIP_NONE-}; do
if [ -z "${f##.$pat}" ]; then
f=
continue
fi
done
[ -n "$f" ] && printf "%s\0" "$f"
done | \
eu-elfclassify --not-program --not-library --not-linux-kernel-module --stdin0 --print0 | \
xargs -0 -r -P$(nproc) -n$(nproc) @RPMCONFIGDIR@/process-lto