Created attachment 526502 [details] dep.pdf, showing dependency graph of the listed shared objects If there are two shared objects that depend on each other (freetype and harfbuzz, for instance), portage will preserve both and is unable to recognize that they are not needed. For example: >>> package: sys-libs/zlib-1.2.11-r1 * - /lib32/libz.so.1 * - /lib32/libz.so.1.2.11 * used by /usr/lib32/libfreetype.so.6 (preserved) * used by /usr/lib32/libfreetype.so.6.16.0 (preserved) * used by /usr/lib32/libpng16.so.16 (preserved) * used by /usr/lib32/libpng16.so.16.34.0 (preserved) >>> package: dev-libs/glib-2.52.3 * - /usr/lib32/libglib-2.0.so.0 * - /usr/lib32/libglib-2.0.so.0.5200.3 * used by /usr/lib32/libharfbuzz.so.0 (preserved) * used by /usr/lib32/libharfbuzz.so.0.10706.0 (preserved) >>> package: media-gfx/graphite2-1.3.11 * - /usr/lib32/libgraphite2.so.3 * - /usr/lib32/libgraphite2.so.3.0.1 * used by /usr/lib32/libharfbuzz.so.0 (preserved) * used by /usr/lib32/libharfbuzz.so.0.10706.0 (preserved) >>> package: dev-libs/libpcre-8.42 * - /lib32/libpcre.so.1 * - /lib32/libpcre.so.1.2.10 * used by /usr/lib32/libglib-2.0.so.0 (preserved) * used by /usr/lib32/libglib-2.0.so.0.5200.3 (preserved) >>> package: media-libs/harfbuzz-1.7.6 * - /usr/lib32/libharfbuzz.so.0 * - /usr/lib32/libharfbuzz.so.0.10706.0 * used by /usr/lib32/libfreetype.so.6 (preserved) * used by /usr/lib32/libfreetype.so.6.16.0 (preserved) >>> package: app-arch/bzip2-1.0.6-r8 * - /lib32/libbz2.so.1 * - /lib32/libbz2.so.1.0.6 * used by /usr/lib32/libfreetype.so.6 (preserved) * used by /usr/lib32/libfreetype.so.6.16.0 (preserved) >>> package: media-libs/libpng-1.6.34 * - /usr/lib32/libpng16.so.16 * - /usr/lib32/libpng16.so.16.34.0 * used by /usr/lib32/libfreetype.so.6 (preserved) * used by /usr/lib32/libfreetype.so.6.16.0 (preserved) >>> package: media-libs/freetype-2.9 * - /usr/lib32/libfreetype.so.6 * - /usr/lib32/libfreetype.so.6.16.0 * used by /usr/lib32/libharfbuzz.so.0 (preserved) * used by /usr/lib32/libharfbuzz.so.0.10706.0 (preserved) Use emerge @preserved-rebuild to rebuild packages using these libraries There are no executables that require any of those shared objects, but libharfbuzz.so is preserved for libfreetype.so and vice versa, so none can be removed. Portage should recognize this dependency loop and remove them.
FWIW, this is easy to reproduce by transitioning from a multilib profile to a non-multilib profile.
Created attachment 669503 [details] preserved_libs_registry
The @preserved-rebuild misbehavior is a side-effect from the way that preserve-libs re-parents a preserved library to a new package in the same slot. I we should remove the re-parenting since we support parent-less preserved libs since bug 286714.
The fix for bug 243030 is supposed to prevent unnecessary @preserved-rebuild rebuilds triggered by the re-parenting: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4a78dd5f81449aebf764834d75693d2f157eb879
I think parent-less preserved libs is the way to go, since that will allow these libraries to be eliminated without touching any /var/db/pkg/*/*/CONTENTS entries.