#1470 Looking for feedback on static-library-debuginfo preservation style
Closed: fixed by fche. Opened by fche.

The following proposed fedora-change involves disabling the current %__brp_strip_static_archive step in /usr/lib/rpm/redhat/macros. I'm looking for guidance as to what syntax / macro style you might suggest for retaining the status quo for packages that want to force debuginfo-stripping anyway. Is there a naming convention or rpm with-macro convention for giving package .spec files the power to opt-into optional build steps?

https://fedoraproject.org/wiki/Changes/StaticLibraryPreserveDebuginfo

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/C5KPC7DIMC3GIFQ5MXBHSHDBSJUOC5C7/


We talked about this a lot during this weeks meeting ... there was concern about people turning this off too quickly, when it doesn't add functionality but "just" optimisation. But the general feeling seemed to be that like build flags, it'd be fine if there was a sane rpm macro knob that people could switch and we'd try to trust packagers to do the right thing.

Metadata Update from @james:
- Issue priority set to: Waiting For Reporter (was: Needs Review)

Do you have a suggestion as to a sane macro name? The "null hypothesis" is asking packagers who want to strip debuginfo would be to include this in their .spec:

%__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive  %{__strip}

(that's the current definition in /usr/lib/rpm/redhat/macros), but I wonder if there's a more compact way. Maybe a new

%_enable_static_debug

defaulting to 1?

Yes, usually macros that start with two underscores are not intended to be set in spec files.

The suggestion I made during the meeting was something like %global _strip_static_debuginfo 1 with it defaulting to 0, IIRC. This would match other flags documented in the build flags documentation.

maybe like this (untested)?

diff --git a/macros b/macros
index 2d19acd822a6..fd0ba003c87c 100644
--- a/macros
+++ b/macros
@@ -27,6 +27,7 @@
 %_include_gdb_index      1
 %_debugsource_packages   1
 %_debuginfo_subpackages  1
+%_strip_static_debuginfo 0
 # GCC toolchain
 %__cc_gcc gcc
@@ -266,7 +267,7 @@ for k,_ in pairs(stripped_flags) do print(k .. " ") end
 %__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_strip_static_archive %{expr:0%{_strip_static_debuginfo} ? "/usr/lib/rpm/brp-strip-static-archive %{__strip}" : ""}
 %__brp_check_rpaths /usr/lib/rpm/check-rpaths
 # __brp_mangle_shebangs_exclude - shebangs to exclude
 # __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude

Going by the pattern of other knobs in buildflags.md, seems like the %undefine polarity to override a default is more popular. So how about this in /usr/lib/rpm/redhat/macros:

%_preserve_static_debuginfo 1
%__brp_strip_static_archive %{expr:0%{_preserve_static_debuginfo} ? "" : "/usr/lib/rpm/brp-strip-static-archive %{__strip}"}          

and document this in buildflags.md:

%undefine _preserve_static_debuginfo

This is the version that was found to work when actually tested against some -static- carrying packages. Thanks for the advice and your time!

https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/338

Metadata Update from @fche:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata