The PROVIDES_EXCLUDE and REQUIRES_EXCLUDE variables currently only apply to soname dependencies. However, it would be useful if we also applied them to preserve-libs logic.
Since REQUIRES and PROVIDES metadata are already filtered with the corresponding _EXCLUDE variables, we can simply filter NEEDED.ELF.2 data by intersection with REQUIRES or PROVIDES where appropriate.
There's a patch in the following branch: https://github.com/zmedico/portage/tree/bug_565792 I've posted it for review here: https://archives.gentoo.org/gentoo-portage-dev/message/751007648406097e3228f25d2d680ddf
(In reply to Zac Medico from comment #2) > There's a patch in the following branch: > > https://github.com/zmedico/portage/tree/bug_565792 I've just realized that intersection with REQUIRES is flawed, because REQUIRES automatically excludes all sonames that are in PROVIDES. So, as is, the patch will prevent LinkageMapELF from accounting for soname dependencies between files from the same package. The result would be that a library could get preserved without also preserving other libraries that said library requires from the same package. So, I'll have to re-write the patch to use REQUIRES_EXCLUDE and PROVIDES_EXCLUDE directly.
(In reply to Zac Medico from comment #3) > So, I'll have to re-write the patch to use REQUIRES_EXCLUDE and > PROVIDES_EXCLUDE directly. Actually, it looks like we can still use REQUIRES and PROVIDES to simplify things. The key is to intersect with REQUIRES and PROVIDES only when evaluating relationships between files originating from separate packages. When evaluating relationships between files originating from the same package, REQUIRES and PROVIDES should simply not be used (which is the current status quo), since they do not account for the relationships which exist between files originating from the same package.