[PATCH] dependency list for static libraries

Howard Chu hyc@symas.com
Tue Sep 22 17:55:11 GMT 2020


Fangrui Song wrote:
> Did the thread start at
> https://sourceware.org/legacy-ml/binutils/2017-09/msg00158.html ?

Yes.
> 
> If all dependencies are specified on the command line but there are
> "backward references", we can step back and think about loosing the
> requirement like some other binary formats:
> https://sourceware.org/pipermail/binutils/2020-September/113194.html "Memoryless" archive processing of ld

Seems unrelated.

> If some archives want system libraries (e.g. -lm -lpthread), MSVC style
> #pragma comment(lib, "pthread")
> may be convenient. clang supports the syntax for ELF and the syntax has
> been used in several places in libc++. LLD supports .deplibs (
> http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html
> http://llvm.1065342.n5.nabble.com/llvm-dev-RFC-ELF-Autolinking-td126998.html )

This seems misguided and wasteful, IMO. You'll have redundant info embedded in
each of the object files that are built for a library, but you only need these
dependencies to be specified once - at the library level itself.

This problem is already solved for shared libraries. They have their dependencies
listed in their dynamic section, and it's specified once at library build time.
That's the correct approach. My aim here is to make static libraries behave the
same as shared libraries, in this respect.

Embedding dependent library info in source files is just wrong, particularly when
you write code that's cross-platform. It makes sense that Microsoft would latch
on to an idea like this, since in their worldview they are the sole provider of
useful libraries for their systems. But it doesn't make sense for portable
cross-platform code.

-- 
  -- 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