[PATCH] dependency list for static libraries

Howard Chu hyc@symas.com
Mon Sep 28 11:07:40 GMT 2020


Howard Chu wrote:
> Fangrui Song wrote:
>>   + The executable does not references B. I am still unsure why you want to move the dependency information from the
>>     object file to the archive.
> 
> The most common case is we reference a library we know about, and it has dependencies
> we don't know about. An example I currently have in mind is libzmq, which may or may
> not be built against libsodium, and may or may not have other library dependencies
> as well. The "traditional" solution to this for the past couple decades has been to
> use pkg-config or libtool .la files to propagate this information but those are both
> ugly hacks that require excessive tooling to support. The information clearly belongs
> to the archive file itself.

The libzmq/libsodium example is particularly illustrative. The symbols libzmq references
may be entirely resolved by its bundled TweetNaCl, or may be satisfied by libsodium. The
choice of which to use is made at build time and either one can be substituted in without
making any alterations to source code or other build scripts, or recompiling any sources.
As such, embedding the name of a dependency into libzmq's object files is not a solution
for this situation. The knowledge only exists at build time, chosen by whoever is packaging
the software. It would be ridiculous to require the library to be recompiled to change
this embedded dependency, when no such step was needed before.

There's another argument of perspective - there's a multi-decade expectation that object
files are passive, with no side effects. If I reference foo.o in a link command, all I
get is foo.o, nothing else. There's also an expectation that if I reference a library in
a link command, I may get arbitrarily many other components. That's a fundamental difference
between individual object files and objects collected into a library. It would be a mistake
to violate these norms.

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/


More information about the Binutils mailing list