Carrying on from https://bugs.gentoo.org/906368#c1.
for context, rpm uses https://sourceware.org/cgit/debugedit/tree/scripts/find-debuginfo.in there are outstanding patches to make it less rpm-specific: https://inbox.sourceware.org/debugedit/20220611212217.4297-1-adrianvovk@gmail.com/ and there's upstream interest in making it generic, so I suspect that we *could* use it (and imo that'd be nice)
So I had a closer look at this (sorry a bunch of IRL stuffs was going on that took priority). The reason multifile mode is so troublesome is that, to my knowledge, the dwz needs to be invoked just once for all ELFs of a package, instead of one invocation per ELF. This interferes with the strip logic with compressdebug, because dwz will not operate on ELFs that have compressed debug sections [1]. I took a look at the rpm script and it does not seem to have objcopy invocation where we add "--compress-debug-sections", so I can't tell how they workaround this dwz limitation, or that their debug sections aren't actually compressed at all. The way I see this potentially working is to separate the estrip process_elf into more stages, where first stage is only save_elf_sources for every ELFs, second stage collect all the ELF inodes, third stage perform the dwz multifile outside the loop, fourth stage splitdebug, compressdebug, strip. This looks complicated and needs some refactoring of the bash script logic, so I want to confirm if this makes sense before I attempt to tackle this. [1] https://sourceware.org/git/?p=dwz.git;a=blob;f=dwz.c;h=3bc6038e35a553e7474e1457cdbee658261be0eb;hb=HEAD#l13587
(In reply to YiFei Zhu from comment #2) > The way I see this potentially working is to separate the estrip process_elf > into more stages, where first stage is only save_elf_sources for every ELFs, > second stage collect all the ELF inodes, third stage perform the dwz > multifile outside the loop, fourth stage splitdebug, compressdebug, strip. > This looks complicated and needs some refactoring of the bash script logic, > so I want to confirm if this makes sense before I attempt to tackle this. Please go ahead and refactor it into these stages. In order support multifile mode for dedupdebug, it's perfectly logical to batch everything into a single dwz invocation.