I'd like to hear some feedback on this. It's quite hackish, but I think
the complexity is reduced compared to what we had before.
I asked about the macro rewrite on the devel list:
<
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.o...
My position on the static archives is that if we want debugging
information for them, that should be a distribution-wide change
(which I proposed a few years ago, but it was rejected).
Thanks,
Florian
8<------------------------------------------------------------------8<
This needs a wrapper script around find-debuginfo.sh, so that
ld.so is not stripped. Overall size for glibc.rpm with and without
this change is reduced on x86_64:
Before: 16146907
After: 14396635
This commit resolves debuginfo file conflicts (#1886295) because
the ldconfig debuginfo file now includes the architecture name.
All debugging information is preserved in ld.so (#1905611). With
the distribution defaults, we strip all binaries again (#1661510).
---
glibc.spec | 190 ++++---------------------------------------------
wrap-find-debuginfo.sh | 63 ++++++++++++++++
2 files changed, 78 insertions(+), 175 deletions(-)
diff --git a/glibc.spec b/glibc.spec
index 0ece4ac..c2ebefa 100644
--- a/glibc.spec
+++ b/glibc.spec
@@ -84,12 +84,6 @@
%define need_headers_package 0
%endif
-##############################################################################
-# If the debug information is split into two packages, the core debuginfo
-# package and the common debuginfo package then the arch should be listed
-# here. If the arch is not listed here then a single core debuginfo package
-# will be created for the architecture.
-%define debuginfocommonarches %{biarcharches} alpha alphaev6
##############################################################################
# %%package glibc - The GNU C Library (glibc) core package.
##############################################################################
@@ -130,10 +124,25 @@ Source0: %{?glibc_release_url}%{glibcsrcdir}.tar.xz
Source1: nscd.conf
Source2: bench.mk
Source3: glibc-bench-compare
+Source10: wrap-find-debuginfo.sh
Source11: parse-SUPPORTED.py
# Include in the source RPM for reference.
Source12: ChangeLog.old
+######################################################################
+# Activate the wrapper script for debuginfo generation, by rewriting
+# the definition of __debug_install_post.
+%{lua:
+local wrapper = rpm.expand("%{SOURCE10}")
+local ldso = rpm.expand("%{glibc_sysroot}/%{_lib}/ld-%{VERSION}.so")
+local original = rpm.expand("%{macrobody:__debug_install_post}")
+-- Strip leading newline. It confuses the macro redefinition.
+-- Avoid embedded newlines that confuse the macro definition.
+original = original:match("^%s*(.-)%s*$"):gsub("\\\n", "")
+rpm.define("__debug_install_post bash " .. wrapper
+ .. " " .. ldso .. " " .. original)
+}
+
##############################################################################
# Patches:
# - See each individual patch file for origin and upstream status.
@@ -911,59 +920,6 @@ which can be helpful during program debugging.
If unsure if you need this, don't install this package.
-##############################################################################
-# glibc core "debuginfo" sub-package
-##############################################################################
-%if 0%{?_enable_debug_packages}
-%define debug_package %{nil}
-%define __debug_install_post %{nil}
-%global __debug_package 1
-# Disable thew new features that glibc packages don't use.
-%undefine _debugsource_packages
-%undefine _debuginfo_subpackages
-%undefine _unique_debug_names
-%undefine _unique_debug_srcs
-
-%package debuginfo
-Summary: Debug information for package %{name}
-AutoReqProv: no
-%ifarch %{debuginfocommonarches}
-Requires: glibc-debuginfo-common = %{version}-%{release}
-%else
-%ifarch %{ix86} %{sparc}
-Obsoletes: glibc-debuginfo-common
-%endif
-%endif
-
-%description debuginfo
-This package provides debug information for package %{name}.
-Debug information is useful when developing applications that use this
-package or when debugging this package.
-
-This package also contains static standard C libraries with
-debugging information. You need this only if you want to step into
-C library routines during debugging programs statically linked against
-one or more of the standard C libraries.
-To use this debugging information, you need to link binaries
-with -static -L%{_prefix}/lib/debug%{_libdir} compiler options.
-
-##############################################################################
-# glibc common "debuginfo-common" sub-package
-##############################################################################
-%ifarch %{debuginfocommonarches}
-
-%package debuginfo-common
-Summary: Debug information for package %{name}
-AutoReqProv: no
-
-%description debuginfo-common
-This package provides debug information for package %{name}.
-Debug information is useful when developing applications that use this
-package or when debugging this package.
-
-%endif
-%endif
-
%if %{with benchtests}
%package benchtests
Summary: Benchmarking binaries and scripts for %{name}
@@ -1401,15 +1357,6 @@ chmod 644 %{glibc_sysroot}%{_libdir}/gconv/gconv-modules.cache
# archives we might have added.
##############################################################################
-# If we are building a debug package then copy all of the static archives
-# into the debug directory to keep them as unstripped copies.
-%if 0%{?_enable_debug_packages}
-mkdir -p %{glibc_sysroot}%{_prefix}/lib/debug%{_libdir}
-cp -a %{glibc_sysroot}%{_libdir}/*.a \
- %{glibc_sysroot}%{_prefix}/lib/debug%{_libdir}/
-rm -f %{glibc_sysroot}%{_prefix}/lib/debug%{_libdir}/*_p.a
-%endif
-
# Remove any zoneinfo files; they are maintained by tzdata.
rm -rf %{glibc_sysroot}%{_prefix}/share/zoneinfo
@@ -1545,11 +1492,6 @@ ar cr %{glibc_sysroot}%{_prefix}/%{_lib}/libpthread_nonshared.a
# - File list with the .so symbolic links for NSS packages.
# * compat-libpthread-nonshared.filelist.
# - File list for compat-libpthread-nonshared subpackage.
-# * debuginfo.filelist
-# - Files for the glibc debuginfo package.
-# * debuginfocommon.filelist
-# - Files for the glibc common debuginfo package.
-#
# Create the main file lists. This way we can append to any one of them later
# wihtout having to create it. Note these are removed at the start of the
@@ -1568,8 +1510,6 @@ touch nss_db.filelist
touch nss_hesiod.filelist
touch nss-devel.filelist
touch compat-libpthread-nonshared.filelist
-touch debuginfo.filelist
-touch debuginfocommon.filelist
###############################################################################
# Master file list, excluding a few things.
@@ -1832,99 +1772,6 @@ echo
"%{_prefix}/libexec/glibc-benchtests/validate_benchout.py*" >>
benchtests.f
###############################################################################
echo "%{_libdir}/libpthread_nonshared.a" >>
compat-libpthread-nonshared.filelist
-###############################################################################
-# glibc-debuginfocommon, and glibc-debuginfo
-###############################################################################
-
-%if 0%{?_enable_debug_packages}
-find_debuginfo_args='--strict-build-id -g -i'
-%ifarch %{debuginfocommonarches}
-find_debuginfo_args="$find_debuginfo_args \
- -l common.filelist \
- -l utils.filelist \
- -l nscd.filelist \
- -p '.*/(sbin|libexec)/.*' \
- -o debuginfocommon.filelist \
- -l nss_db.filelist -l nss_hesiod.filelist \
- -l libnsl.filelist -l glibc.filelist \
-%if %{with benchtests}
- -l benchtests.filelist
-%endif
- "
-%endif
-
-/usr/lib/rpm/find-debuginfo.sh $find_debuginfo_args -o debuginfo.filelist
-
-# List all of the *.a archives in the debug directory.
-list_debug_archives()
-{
- local dir=%{_prefix}/lib/debug%{_libdir}
- find %{glibc_sysroot}$dir -name "*.a" -printf "$dir/%%P\n"
-}
-
-%ifarch %{debuginfocommonarches}
-
-# Remove the source files from the common package debuginfo.
-sed -i '\#^%{glibc_sysroot}%{_prefix}/src/debug/#d' debuginfocommon.filelist
-
-# Create a list of all of the source files we copied to the debug directory.
-find %{glibc_sysroot}%{_prefix}/src/debug \
- \( -type d -printf '%%%%dir ' \) , \
- -printf '%{_prefix}/src/debug/%%P\n' > debuginfocommon.sources
-
-%ifarch %{biarcharches}
-
-# Add the source files to the core debuginfo package.
-cat debuginfocommon.sources >> debuginfo.filelist
-
-%else
-
-%ifarch %{ix86}
-%define basearch i686
-%endif
-%ifarch sparc sparcv9
-%define basearch sparc
-%endif
-
-# The auxarches get only these few source files.
-auxarches_debugsources=\
-'/(generic|linux|%{basearch}|nptl(_db)?)/|/%{glibcsrcdir}/build|/dl-osinfo\.h'
-
-# Place the source files into the core debuginfo pakcage.
-egrep "$auxarches_debugsources" debuginfocommon.sources >>
debuginfo.filelist
-
-# Remove the source files from the common debuginfo package.
-egrep -v "$auxarches_debugsources" \
- debuginfocommon.sources >> debuginfocommon.filelist
-
-%endif
-
-# Add the list of *.a archives in the debug directory to
-# the common debuginfo package.
-list_debug_archives >> debuginfocommon.filelist
-
-%endif
-
-# Remove some common directories from the common package debuginfo so that we
-# don't end up owning them.
-exclude_common_dirs()
-{
- exclude_dirs="%{_prefix}/src/debug"
- exclude_dirs="$exclude_dirs $(echo
%{_prefix}/lib/debug{,/%{_lib},/bin,/sbin})"
- exclude_dirs="$exclude_dirs $(echo
%{_prefix}/lib/debug%{_prefix}{,/%{_lib},/libexec,/bin,/sbin})"
-
- for d in $(echo $exclude_dirs | sed 's/ /\n/g'); do
- sed -i "\|^%%dir $d/\?$|d" $1
- done
-}
-
-%ifarch %{debuginfocommonarches}
-exclude_common_dirs debuginfocommon.filelist
-%endif
-exclude_common_dirs debuginfo.filelist
-
-%endif
-
##############################################################################
# Run the glibc testsuite
##############################################################################
@@ -2286,13 +2133,6 @@ fi
%files -f libnsl.filelist -n libnsl
/%{_lib}/libnsl.so.1
-%if 0%{?_enable_debug_packages}
-%files debuginfo -f debuginfo.filelist
-%ifarch %{debuginfocommonarches}
-%files debuginfo-common -f debuginfocommon.filelist
-%endif
-%endif
-
%if %{with benchtests}
%files benchtests -f benchtests.filelist
%endif
diff --git a/wrap-find-debuginfo.sh b/wrap-find-debuginfo.sh
new file mode 100644
index 0000000..5ace7e6
--- /dev/null
+++ b/wrap-find-debuginfo.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+# Wrapper script for find-debuginfo.sh
+#
+# Usage:
+# wrap-find-debuginfo.sh LDSO-PATH SCRIPT-PATH SCRIPT-ARGS...
+#
+# The wrapper saves the original versions of the file at LDSO-PATH,
+# invokes SCRIPT-PATH with SCRIPT-ARGS, and then restores the
+# LDSO-PATH file. As a result, LDSO-PATH has unchanged debuginfo even
+# after debuginfo extraction.
+
+set -ex
+
+ldso_tmp="$(mktemp)"
+
+cleanup () {
+ rm -f "$ldso_tmp"
+}
+trap cleanup 0
+
+ldso_path="$1"
+shift
+script_path="$1"
+shift
+
+# Preserve the original file.
+cp "$ldso_path" "$ldso_tmp"
+
+# Run the debuginfo extraction.
+"$script_path" "$@"
+
+# Restore the original file.
+cp "$ldso_tmp" "$ldso_path"
+
+# Reduce the size of notes. Primarily for annobin.
+objcopy --merge-notes "$ldso_path"
+
+# Rewrite the source file paths to match the extracted locations.
+# First compute the arguments for invoking debugedit. See
+# find-debuginfo.sh.
+debug_dest_name="/usr/src/debug"
+last_arg=
+while true ; do
+ arg="$1"
+ shift || break
+ case "$arg" in
+ (--unique-debug-src-base)
+ debug_dest_name="/usr/src/debug/$1"
+ shift
+ ;;
+ (-*)
+ ;;
+ (*)
+ last_arg="$arg"
+ ;;
+ esac
+done
+debug_base_name=${last_arg:-$RPM_BUILD_ROOT}
+/usr/lib/rpm/debugedit -b "$debug_base_name" -d "$debug_dest_name" -n
\
+ $ldso_path
+
+# Apply single-file DWARF optimization.
+dwz $ldso_path