[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoid -Wl,--whole-archive

From: Bob Friesenhahn
Subject: Re: Avoid -Wl,--whole-archive
Date: Tue, 21 May 2019 09:51:42 -0500 (CDT)
User-agent: Alpine 2.20 (GSO 67 2015-01-07)

On Tue, 21 May 2019, Thomas Jahns wrote:

On 5/16/19 5:00 PM, Bob Friesenhahn wrote:
Convenience libraries are evil.  Convenience libraries slow down your build process dramatically and they cause 'make' not to be aware of the actual underlying dependencies, so that it does much more work than is required each type you invoke 'make'.  If you can enumerate the actual dependencies in the Makefile and avoid needless intermediate product generation, then you will achive a maximally parallel build which builds much faster on modern systems.

Except when they don't actually slow you down: ar and ranlib provide for a lookup table that in my experience is beneficial to build times, especially when you have a network filesystem, where access to individual file system objects can be more expensive.

These features are not used by convenience libraries. The fact that convenience libraries store object files in an archive file is just an artifact of its implementation. An alternative would have been to use pax or tar, but these require creating the whole file from scratch and are not as portably available (for compilation) as 'ar'. When a convenience library is linked with a shared library, all of its contained object files may be first extracted, and then the list of object files is supplied to the linker. This happens when -Wl,--whole-archive is not available.

Given that convenience libraries do use the 'ar' format and are compiled as PIC when building shared libraries (if needed), an alternative way of referencing the archive file from the Makefile would likely avoid the -Wl,--whole-archive problem.

Bob Friesenhahn
GraphicsMagick Maintainer,
Public Key,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]