[PATCH v2] [RFC] libdep plugin: fix bugs in parser and drop escaping
Harmen Stoppels
me@harmenstoppels.nl
Fri Jun 21 08:06:05 GMT 2024
To me it seems that the current implementation of libdep.so is flawed, it's just
not comparable to how dynamic libraries are resolved, even though it claims to
make static linking behave similar to dynamic linking w.r.t. resolving
dependencies.
The relevant -L flags should have been local search paths at highest priority
scoped to the current static library (maybe inherited like rpaths). That's not
something that can be expressed easily in a bfd plugin:
- The gold linker gets it right to some extent, except that it only supports a
single -L flag per -l library, making it hard to use. Every new -L flag
overrides the previous one.
- The bfd linker adds a *global* search path at lowest priority, which results
in two issues: the dependency is often located in system directories instead
of the provided -L path, and the -L path affects locating of other libraries
specified on the command line.
Fixing those issues would require how registration of paths is done in bfd and
gold, which would potentially break other user plugins that rely on the current
behavior.
Further, the double escaping issues (that always persist with quotes) could've
been avoided by using a better API in ar, like one of the following:
ar cr --libdep-arg=-L/foo --libdep-arg=-L/bar --libdep-arg=-lbaz
ar cr --libdep-path=/foo --libdep-path=/bar --libdep-lib=baz
Those arguments can be stored as consecutive C-strings in the __.LIBDEP member.
No escaping needed, and it mimics `cc -Wl,-rpath`. But I'm afraid that ship has
sailed.
More information about the Binutils
mailing list