Deliberate deduplication of -rpath arguments in ld.bfd and ld.gold?

Michael Matz matz@suse.de
Wed Jul 6 11:32:29 GMT 2022


Hello,

On Wed, 6 Jul 2022, Stephan Bergmann via Binutils wrote:

> Over in the comments at <https://reviews.llvm.org/D129142> "[LLD][ELF] Drop
> duplicates from rpath" we wonder what the rationale might be that both ld.bfd
> and ld.gold apparently deliberately drop duplicated -rpath arguments with
> identical paths

The rationale would be "avoid waste in the real world".  If you don't do 
that then you will find that when building certain software it will end up 
with hundreds of copies of things like "RUNPATH 
/usr/lib/my-strange-module-path/" because its build-system is strange, and 
blindly collects linker arguments from e.g. pkg-config files, but doesn't 
remove duplicates itself.  As the runtime linker doesn't do duplicate 
removal either (speed!) it would then end up looking into loading the same 
non-existing file that same hundred times.

Instead of fixing all these build systems, something simply has to remove 
the duplicates and the linker is the most sensible choice.


Ciao,
Michael.


More information about the Binutils mailing list