Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1453429 Details for
Bug 1586159
find-debuginfo.sh needs to be faster (sometimes takes hours on our kernel builds)
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to add to rhel-7.4 package
rpm-4.14.x-find-debuginfo-jNUM.patch (text/plain), 12.29 KB, created by
Denys Vlasenko
on 2018-06-21 11:47:47 UTC
(
hide
)
Description:
Patch to add to rhel-7.4 package
Filename:
MIME Type:
Creator:
Denys Vlasenko
Created:
2018-06-21 11:47:47 UTC
Size:
12.29 KB
patch
obsolete
>diff -urpN rpm-4.11.3.orig/scripts/find-debuginfo.sh rpm-4.11.3/scripts/find-debuginfo.sh >--- rpm-4.11.3.orig/scripts/find-debuginfo.sh 2018-06-21 13:07:32.397224386 +0200 >+++ rpm-4.11.3/scripts/find-debuginfo.sh 2018-06-21 12:29:17.000000000 +0200 >@@ -2,17 +2,19 @@ > #find-debuginfo.sh - automagically generate debug info and file list > #for inclusion in an rpm spec file. > # >-# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] >+# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] > # [-o debugfiles.list] > # [--run-dwz] [--dwz-low-mem-die-limit N] > # [--dwz-max-die-limit N] > # [[-l filelist]... [-p 'pattern'] -o debuginfo.list] > # [builddir] > # >-# The -g flag says to use strip -g instead of full strip on DSOs. >+# The -g flag says to use strip -g instead of full strip on DSOs or EXEs. > # The --strict-build-id flag says to exit with failure status if > # any ELF binary processed fails to contain a build-id note. > # The -r flag says to use eu-strip --reloc-debug-sections. >+# The -m flag says to include a .gnu_debugdata section in the main binary. >+# The -i flag says to include a .gdb_index section in the .debug file. > # > # A single -o switch before any -l or -p switches simply renames > # the primary output file from debugfiles.list to something else. >@@ -29,7 +31,10 @@ > # All file names in switches are relative to builddir (. if not given). > # > >-# With -g arg, pass it to strip on libraries. >+# Figure out where we are installed so we can call other helper scripts. >+lib_rpm_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" >+ >+# With -g arg, pass it to strip on libraries or executables. > strip_g=false > > # with -r arg, pass --reloc-debug-sections to eu-strip. >@@ -38,6 +43,9 @@ strip_r=false > # with -m arg, add minimal debuginfo to binary. > include_minidebug=false > >+# with -i arg, add GDB index to .debug file. >+include_gdb_index=false >+ > # Barf on missing build IDs. > strict=false > >@@ -46,6 +54,9 @@ run_dwz=false > dwz_low_mem_die_limit= > dwz_max_die_limit= > >+# Number of parallel jobs to spawn >+n_jobs=1 >+ > BUILDDIR=. > out=debugfiles.list > nout=0 >@@ -71,6 +82,9 @@ while [ $# -gt 0 ]; do > -m) > include_minidebug=true > ;; >+ -i) >+ include_gdb_index=true >+ ;; > -o) > if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then > out=$2 >@@ -91,6 +105,17 @@ while [ $# -gt 0 ]; do > -r) > strip_r=true > ;; >+ -j) >+ n_jobs=$2 >+ shift >+ ;; >+ -j*) >+ n_jobs=${1#-j} >+ ;; >+ --jobs) >+ n_jobs=$2 >+ shift >+ ;; > *) > BUILDDIR=$1 > shift >@@ -130,6 +155,8 @@ strip_to_debug() > $strip_r && r=--reloc-debug-sections > $strip_g && case "$(file -bi "$2")" in > application/x-sharedlib*) g=-g ;; >+ application/x-executable*) g=-g ;; >+ application/x-pie-executable*) g=-g ;; > esac > eu-strip --remove-comment $r $g -f "$1" "$2" || exit > chmod 444 "$1" || exit >@@ -145,6 +172,18 @@ add_minidebug() > local keep_symbols=`mktemp` > local mini_debuginfo=`mktemp` > >+ # In the minisymtab we don't need the .debug_ sections (already removed >+ # by -S) but also not other non-allocated PROGBITS, NOTE or NOBITS sections. >+ # List and remove them explicitly. We do want to keep the allocated, >+ # symbol and NOBITS sections so cannot use --keep-only because that is >+ # too agressive. Field $2 is the section name, $3 is the section type >+ # and $8 are the section flags. >+ local remove_sections=`readelf -W -S "$debuginfo" \ >+ | awk '{ if (index($2,".debug_") != 1 \ >+ && ($3 == "PROGBITS" || $3 == "NOTE" || $3 == "NOBITS") \ >+ && index($8,"A") == 0) \ >+ printf "--remove-section "$2" " }'` >+ > # Extract the dynamic symbols from the main binary, there is no need to also have these > # in the normal symbol table > nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms" >@@ -156,7 +195,7 @@ add_minidebug() > # Keep all the function symbols not already in the dynamic symbol table > comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols" > # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections >- objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null >+ objcopy -S $remove_sections --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null > #Inject the compressed data into the .gnu_debugdata section of the original binary > xz "$mini_debuginfo" > mini_debuginfo="${mini_debuginfo}.xz" >@@ -260,54 +299,61 @@ set -o pipefail > strict_error=ERROR > $strict || strict_error=WARNING > >-# Strip ELF binaries >+temp=$(mktemp -d ${TMPDIR:-/tmp}/find-debuginfo.XXXXXX) >+trap 'rm -rf "$temp"' EXIT >+ >+# Build a list of unstripped ELF files and their hardlinks >+touch "$temp/primary" > find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \ > \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \ > -print | > file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped.*/\1/p' | >-xargs --no-run-if-empty stat -c '%h %D_%i %n' | >+xargs --no-run-if-empty stat -c '%h %D_%i %n' | sort -k3 | > while read nlinks inum f; do >- get_debugfn "$f" >- [ -f "${debugfn}" ] && continue >- >- # If this file has multiple links, keep track and make >- # the corresponding .debug files all links to one file too. > if [ $nlinks -gt 1 ]; then >- eval linked=\$linked_$inum >- if [ -n "$linked" ]; then >- eval id=\$linkedid_$inum >- make_id_dup_link "$id" "$dn/$(basename $f)" >- make_id_dup_link "$id" "/usr/lib/debug$dn/$bn" .debug >- link=$debugfn >- get_debugfn "$linked" >- echo "hard linked $link to $debugfn" >- mkdir -p "$(dirname "$link")" && ln -nf "$debugfn" "$link" >+ var=seen_$inum >+ if test -n "${!var}"; then >+ echo "$inum $f" >>"$temp/linked" > continue > else >- eval linked_$inum=\$f >- echo "file $f has $[$nlinks - 1] other hard links" >+ read "$var" < <(echo 1) > fi > fi >+ echo "$nlinks $inum $f" >>"$temp/primary" >+done >+ >+# Strip ELF binaries >+do_file() >+{ >+ local nlinks=$1 inum=$2 f=$3 id link linked >+ >+ get_debugfn "$f" >+ [ -f "${debugfn}" ] && return > > echo "extracting debug info from $f" >- id=$(/usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \ >+ id=$(${lib_rpm_dir}/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug \ > -i -l "$SOURCEFILE" "$f") || exit >- if [ $nlinks -gt 1 ]; then >- eval linkedid_$inum=\$id >- fi > if [ -z "$id" ]; then > echo >&2 "*** ${strict_error}: No build ID note found in $f" > $strict && exit 2 > fi > >- [ -x /usr/bin/gdb-add-index ] && /usr/bin/gdb-add-index "$f" > /dev/null 2>&1 >+ # Add .gdb_index if requested. >+ if $include_gdb_index; then >+ if type gdb-add-index >/dev/null 2>&1; then >+ gdb-add-index "$f" >+ else >+ echo >&2 "*** ERROR: GDB index requested, but no gdb-add-index installed" >+ exit 2 >+ fi >+ fi > > # A binary already copied into /usr/lib/debug doesn't get stripped, > # just has its file names collected and adjusted. > case "$dn" in > /usr/lib/debug/*) > [ -z "$id" ] || make_id_link "$id" "$dn/$(basename $f)" >- continue ;; >+ return ;; > esac > > mkdir -p "${debugdn}" >@@ -319,7 +365,17 @@ while read nlinks inum f; do > chmod u-w "$f" > fi > >- $include_minidebug && add_minidebug "${debugfn}" "$f" >+ # strip -g implies we have full symtab, don't add mini symtab in that case. >+ # It only makes sense to add a minisymtab for executables and shared >+ # libraries. Other executable ELF files (like kernel modules) don't need it. >+ if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then >+ skip_mini=true >+ case "$(file -bi "$f")" in >+ application/x-sharedlib*) skip_mini=false ;; >+ application/x-executable*) skip_mini=false ;; >+ esac >+ $skip_mini || add_minidebug "${debugfn}" "$f" >+ fi > > echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE" > >@@ -327,13 +383,77 @@ while read nlinks inum f; do > make_id_link "$id" "$dn/$(basename $f)" > make_id_link "$id" "/usr/lib/debug$dn/$bn" .debug > fi >-done || exit >+ >+ # If this file has multiple links, make the corresponding .debug files >+ # all links to one file too. >+ if [ $nlinks -gt 1 ]; then >+ grep "^$inum " "$temp/linked" | while read inum linked; do >+ make_id_dup_link "$id" "$dn/$(basename $f)" >+ make_id_dup_link "$id" "/usr/lib/debug$dn/$bn" .debug >+ link=$debugfn >+ get_debugfn "$linked" >+ echo "hard linked $link to $debugfn" >+ mkdir -p "$(dirname "$debugfn")" && ln -nf "$link" "$debugfn" >+ done >+ fi >+} >+ >+# 16^6 - 1 or about 16 milion files >+FILENUM_DIGITS=6 >+run_job() >+{ >+ local jobid=$1 filenum >+ local SOURCEFILE=$temp/debugsources.$jobid ELFBINSFILE=$temp/elfbins.$jobid >+ >+ >"$SOURCEFILE" >+ >"$ELFBINSFILE" >+ # can't use read -n <n>, because it reads bytes one by one, allowing for >+ # races >+ while :; do >+ filenum=$(dd bs=$(( FILENUM_DIGITS + 1 )) count=1 status=none) >+ if test -z "$filenum"; then >+ break >+ fi >+ do_file $(sed -n "$(( 0x$filenum )) p" "$temp/primary") >+ done >+ echo 0 >"$temp/res.$jobid" >+} >+ >+n_files=$(wc -l <"$temp/primary") >+if [ $n_jobs -gt $n_files ]; then >+ n_jobs=$n_files >+fi >+if [ $n_jobs -le 1 ]; then >+ while read nlinks inum f; do >+ do_file "$nlinks" "$inum" "$f" >+ done <"$temp/primary" >+else >+ for ((i = 1; i <= n_files; i++)); do >+ printf "%0${FILENUM_DIGITS}x\\n" $i >+ done | ( >+ exec 3<&0 >+ for ((i = 0; i < n_jobs; i++)); do >+ # The shell redirects stdin to /dev/null for background jobs. Work >+ # around this by duplicating fd 0 >+ run_job $i <&3 & >+ done >+ wait >+ ) >+ for f in "$temp"/res.*; do >+ res=$(< "$f") >+ if [ "$res" != "0" ]; then >+ exit 1 >+ fi >+ done >+ cat "$temp"/debugsources.* >"$SOURCEFILE" >+ cat "$temp"/elfbins.* >"$ELFBINSFILE" >+fi > > # Invoke the DWARF Compressor utility. >-if $run_dwz && type dwz >/dev/null 2>&1 \ >+if $run_dwz \ > && [ -d "${RPM_BUILD_ROOT}/usr/lib/debug" ]; then >- dwz_files="`cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug`" >- if [ -n "${dwz_files}" ]; then >+ readarray dwz_files < <(cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug) >+ if [ ${#dwz_files[@]} -gt 0 ]; then > dwz_multifile_name="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}.${RPM_ARCH}" > dwz_multifile_suffix= > dwz_multifile_idx=0 >@@ -342,13 +462,20 @@ if $run_dwz && type dwz >/dev/null 2>&1 > dwz_multifile_suffix=".${dwz_multifile_idx}" > done > dwz_multfile_name="${dwz_multifile_name}${dwz_multifile_suffix}" >- dwz_opts="-h -q -r -m .dwz/${dwz_multifile_name}" >+ dwz_opts="-h -q -r" >+ [ ${#dwz_files[@]} -gt 1 ] \ >+ && dwz_opts="${dwz_opts} -m .dwz/${dwz_multifile_name}" > mkdir -p "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz" > [ -n "${dwz_low_mem_die_limit}" ] \ > && dwz_opts="${dwz_opts} -l ${dwz_low_mem_die_limit}" > [ -n "${dwz_max_die_limit}" ] \ > && dwz_opts="${dwz_opts} -L ${dwz_max_die_limit}" >- ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files ) >+ if type dwz >/dev/null 2>&1; then >+ ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts ${dwz_files[@]} ) >+ else >+ echo >&2 "*** ERROR: DWARF compression requested, but no dwz installed" >+ exit 2 >+ fi > # Remove .dwz directory if empty > rmdir "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz" 2>/dev/null > if [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" ]; then >@@ -380,11 +507,16 @@ done > > if [ -s "$SOURCEFILE" ]; then > mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug" >- LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(<internal>|<built-in>)$' | >+ # Filter out anything compiler generated which isn't a source file. >+ # e.g. <internal>, <built-in>, <__thread_local_inner macros>. >+ # Some compilers generate them as if they are part of the working >+ # directory (which is why we match against ^ or /). >+ LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(^|/)<[a-z _-]+>$' | > (cd "$RPM_BUILD_DIR"; cpio -pd0mL "${RPM_BUILD_ROOT}/usr/src/debug") >- # stupid cpio creates new directories in mode 0700, fixup >+ # stupid cpio creates new directories in mode 0700, >+ # and non-standard modes may be inherented from original directories, fixup > find "${RPM_BUILD_ROOT}/usr/src/debug" -type d -print0 | >- xargs --no-run-if-empty -0 chmod a+rx >+ xargs --no-run-if-empty -0 chmod 0755 > fi > > if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1586159
:
1447908
|
1447909
|
1447910
|
1451564
| 1453429 |
1546491