Re: Avoid -Wl,--whole-archive

Tim Rühsen <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
On 5/16/19 5:00 PM, Bob Friesenhahn wrote:
> On Thu, 16 May 2019, Tim Rühsen wrote:
> 
>> Hi,
>>
>> at GNU Wget2 we are just splitting a (shared) library into several
>> smaller ones, grouped by functionality.
>>
>> We depend on gnulib and have a single libgnu.a. Each of the shared
>> libraries just need a certain set of functions from libgnu.a.
>>
>> To avoid adding everything from libgnu.a to each of the libraries, we
>> would like to avoid "-Wl,--whole-archive ../lib/.libs/libgnu.a
>> -Wl,--no-whole-archive".
> 
> There is no requirement to use "convenience" libraries.  People who do
> things due to "convenience" are often classified as "lazy". :-)

Of course I am lazy - that's why I am developer ;-) Building things to
make my life easier...

> If you have time to re-do your build structure, then I recommend using a
> non-recursive build and explicitly listing the objects which are needed
> by each library in the single Makefile.  Objects common to multiple
> libraries will then be built just once and supplied to the linker as a
> list of object files rather than fed to libtool like an "archive" file
> which is then split into object files actually supplied to the linker.
> 
> 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.

I couldn't see any speed penalty so far. Indeed, enumerating the object
files (.lo in this case) was my first approach. But we are talking about
gnulib - the number of object files is different in each environment and
also change over time. I immediately ran into issues when I pushed that
code to our CI. The exact enumeration of objects is simply not
foreseeable and thus not portable.

Your are right for projects with a deterministic number of objects...
But for projects that use gnulib *and* build more than one shared
library a '-no-whole-archive' flag would great.

> If your project is already fully built, then typing 'make' again should
> return almost immediately without doing any work at all.  If your
> project does any work at all due to typing 'make' a second time, then it
> is defective.

A second 'make' always immediately returns - if not I would change my
build recipe.

Regards, Tim

_______________________________________________
https://lists.gnu.org/mailman/listinfo/libtool
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEHLJ9vJhhSy1YQWRtCDAttqJnBCgFAlzdgYgACgkQCDAttqJn
BCjUaA//ZbIDhakvmyj+mLBKSdE8qqqFDSfMUJc7z6xqE8SkhOWGz6l085S4vUJH
QWWfRXJhYRAtAj6K8RmpQnP0Q4M55li96DVK5YMHEvrQbjUMqqBN9GBJqwHBS0yU
+0d7/1W84MCEijksHqF8x2sDENBLdPGzylOLpf6cc+xKQb//6O5LAghNuE4E0P2q
I5vuvIeObgh16EWOioyZux99uw9f7LeZB97198+/K5WnHuhkszIL7rzqLCn/YqH0
Re0+o/QPac6rzVB5Q48jwx44/FQYfFr5OSvLCifUzpvp6wV2dFsMI44K31dARMSE
EPS2jgI3d8rGqyEhJC4kc624kfKAqxWjlfZsWobgzA1j0t+F0hu99k1n7gWi5J0e
zgWKVdXinb9hjOVNgOHZnIye4I9OVBBi7TkFfwIFP2rLDgtWeJHqu9gMvEe1LoaK
w5z7nDJs8MwcMShmOXcZQsvpNGfEjKDFIZLm68nnelT66GDEPmLJ8gDjWSXJQCLw
8hiU7f869KSAJNaJ38Pbuwm3qEsWKZ+H8gnS6w7NTxcWw6pJBQinfPr+kOguo/UH
4W+8Z6v7MnyBVbZ/bGoYQY01vo4vtKq48ZfMFmtzQZar8ZmmksUBSYS67tdlKZ2Q
Fm1fE7NW8h72dh9+mPd9OifjML5lIF4ZSbCH5za/ZlhycfGmNGM=
=FKaE
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.