Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 652382

Summary: sys-apps/portage: preserve-libs dependency cycles prevent elimination of preserved libraries
Product: Portage Development Reporter: Matt Turner <mattst88>
Component: CoreAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: normal CC: bog, bugzilla, esigra, flow, gentoo, nathandu, sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=243030
https://bugs.gentoo.org/show_bug.cgi?id=766779
https://bugs.gentoo.org/show_bug.cgi?id=641094
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 240323    
Attachments: dep.pdf, showing dependency graph of the listed shared objects
preserved_libs_registry

Description Matt Turner gentoo-dev 2018-04-04 00:19:32 UTC
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.
Comment 1 Matt Turner gentoo-dev 2019-02-27 22:05:43 UTC
FWIW, this is easy to reproduce by transitioning from a multilib profile to a non-multilib profile.
Comment 2 Matt Turner gentoo-dev 2020-10-31 21:23:53 UTC
Created attachment 669503 [details]
preserved_libs_registry
Comment 3 Zac Medico gentoo-dev 2020-10-31 22:14:26 UTC
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.
Comment 4 Zac Medico gentoo-dev 2020-10-31 22:21:10 UTC
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
Comment 5 Zac Medico gentoo-dev 2020-10-31 22:28:33 UTC
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.