The sheer amount of articles regarding libtool archives in my blog’s archive is probably enough to tell that I have a pretty bad relationship with them. But even though I have been quiet, lately, I haven’t stopped working on them.
In particular, my current “daily job”, or at least one of them, has among its task the one of getting more reliable cross-compilation support with Gentoo’s ebuilds, and dropping the cursed
.la files is part of the plan. With them around, often enough,
-L/usr/lib64 is added to the linking line, which causes all sorts of troubles once it’s resolved to a fully qualified path such as
/usr/lib64/libfoo.so which cannot obviously be linked against.
After a bit of doubts on how to proceed (waiting for Gentoo proper to remove all of them, given the kind of obstruction I find coming from developers, was not really an option), it was decided to try building the whole chroot used for cross-compilation, and the cross-compiled roots by removing all the
.la files with the exclusion of the one that is known to be required (
For those wondering, it was achieved with this “simple” setting in
INSTALL_MASK=" /usr/lib/lib[0-9]*.la /usr/lib/lib[a-k]*.la /usr/lib/lib[m-z]*.la /usr/lib/libl[0-9]*.la /usr/lib/libl[a-s]*.la /usr/lib/libl[u-z]*.la /usr/lib/liblt[0-9]*.la /usr/lib/liblt[a-c]*.la /usr/lib/liblt[e-z]*.la /usr/lib/libltd[0-9]*.la /usr/lib/libltd[a-k]*.la /usr/lib/libltd[m-z]*.la /usr/lib/libltdl[0-9]*.la /usr/lib/libltdl[a-z]*.la "
At this point, my opinion has always been that there would be no problem with building further packages even though the libtool archives were gone… turns out I was mostly, but not entirely, right. Indeed if the system were built using the standard GNU
ld linker, there would have been no package failure; on the other hand, all of this is built using
gold – which is much stricter about underlinking – and that makes a huge difference.
Not only the use of
libtool by itself would make it mostly pointless to use
--as-needed, but it also makes
--no-add-needed (the feature that makes the linker strict in terms of underlinking) much less effective: if you only link to
libfoo.la, which in turn lists
-lbar, and you use symbols from both, the libtool archive would provide both to the linker, hiding the fact that you didn’t express your dependencies properly.
But out of a whole operating system built without
.la files, how many packages did require fixes? The answer is two:
libsoup (which was actually already fixed in the second-to-last release, so the fix was simply updating the version used) and
tpm-tools (that, similarly to
opencryptoki has a quite bogus build system).
I’m not saying that they would be the only packages suffering from these issues, and in particular, with the fact that this system is not building anything statically, it is likely to encounter much fewer complications, but it is more than likely that with minimal effort we’d suffer fewer problems with linking, rebuilds, and dependencies if we were to drop those files entirely, and switch to fixing the few packages failing.