commit: e8f0e06784549fc4c8a06e0a43ff946d6a895683
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 1 01:44:02 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 6 21:00:28 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e8f0e067
estrip: apply scanelf optimisation to EAPI 7+ / dostrip
(No need to do ${D%/} etc here as dostrip is in EAPI 7+ only.)
See: bb88e766897f5e7e0b0a10c48cf99a04edb73a40
Bug: https://bugs.gentoo.org/749624
Bug: https://bugs.gentoo.org/862606
Signed-off-by: Sam James <sam <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/879
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/estrip | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/bin/estrip b/bin/estrip
index 0ed35111d..68ce8bd4d 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -64,12 +64,51 @@ while [[ $# -gt 0 ]] ; do
done
if [[ ${find_paths[@]} ]]; then
+ # We can avoid scanelf calls for binaries we already
+ # checked in install_qa_check (where we generate
+ # NEEDED for everything installed).
+ #
+ # EAPI 7+ has controlled stripping (dostrip) though
+ # which is why estrip has the queue/dequeue logic,
+ # so we need to take the intersection of:
+ # 1. files scanned earlier (all ELF installed)
+ # (note that this should be a superset of 2., so we
don't
+ # need to worry about unknown files appearing)
+ #
+ # 2. the files we're interested in right now
+ scanelf_results=()
+ if [[ -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED ]] ;
then
+ # The arguments may not be exact files
(probably aren't), but search paths/directories
+ # which should then be searched recursively.
+ while IFS= read -r needed_entry ; do
+ for find_path in "${find_paths[@]}" ; do
+ # NEEDED has a bunch of entries
like:
+ # /usr/lib64/libfoo.so libc.so
+ #
+ # find_path entries may be
exact paths (like /usr/lib64/libfoo.so)
+ # or instead /usr/lib64, or
${ED}/usr, etc.
+ #
+ # We check if the beginning
(i.e. first entry) of the NEEDED line
+ # matches the path given
+ # e.g. find_path="/usr/lib64"
will match needed_entry="/usr/lib64/libfoo.so libc.so".
+
needed_entry_file="${needed_entry% *}"
+ if [[ "${needed_entry_file}" =~
^${find_path##${D}} ]] ; then
+ scanelf_results+=(
"${D}${needed_entry_file}" )
+ fi
+ done
+ done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED
+ else
+ scanelf_results=$(scanelf -yqRBF '#k%F' -k
'.symtab' "${find_paths[@]}")
+ fi
+
while IFS= read -r path; do
>> "${path}.estrip" || die
done < <(
- scanelf -yqRBF '#k%F' -k '.symtab'
"${find_paths[@]}"
+ printf "%s\n" "${scanelf_results[@]}"
find "${find_paths[@]}" -type f ! -type l -name
'*.a'
)
+
+ unset scanelf_results needed_entry needed_entry_file
find_path
fi
exit 0