remove .la files?

Kalev Lember kalevlember at gmail.com
Tue Jan 31 17:44:35 UTC 2012


Hello,

Currently the Fedora MinGW packaging guidelines have a special exception
which allows the packages to install .la files. For native packages,
however, they are explicitly banned, and with good reasons.

We've been talking about this for quite some time, and now I'd like to
propose that we remove the .la files from most mingw packages.


What do the .la files do?
-------------------------
They were originally designed for linking back in the time when there
were no shared libraries. Nowadays however we have dynamic libraries
(the .so and .dll files) which can already contain all the interesting
information that the .la files used to convey, making them largely useless.

Lets say we have 2 libraries and an executable:
1) libA;
2) libB, which uses a symbol from libA;
3) executable foobar, which uses a symbol from libB, but doesn't use
   any symbols from libA.

Now, if we link libB to foobar, we'll somehow also need to make sure
that the symbol that libB uses from libA gets resolved. With dynamic
linking, elf .so files have the DT_NEEDED section (and .dll files have a
similar DLL Name section), so that the dynamic linker automatically also
loads libA.so when libB.so gets loaded.

With static linking, however, it's not automatic.

The .a files -- static libraries -- are just archives, with no metadata
about other dependant libraries. And because of that, when linking
foobar executable, we'll need to explicitly specify -lA and -lB on the
linker command line.

This is one of the things that the .la files try to work around: the
dependency_libs section specifies all other libraries that this one
depends on.


Why would we want to remove the .la files?
------------------------------------------
The dependency_libs section in .la files gets way too many entries,
making updates that change DLL names very painful.

Erik and I have been discussing libpng 1.4 -> 1.5 related rebuilds, and
the .la files make it much harder to do. Without the .la files, there
would just be 8 packages to rebuild:
$ repoquery --disablerepo='*' --enablerepo=rawhide --whatrequires
mingw32-libpng | sort | uniq | wc -l
8

But when taking into account the .la files dependency_libs section, the
list quickly grows to 19:
$ grep -l -E '^dependency_libs.*libpng(14)?.la' *.la | xargs rpm -qf |
sort | uniq | wc -l
19

When libtool is used for linking and one of the libraries in a .la
file's dependency_libs section is missing, the linking fails. And this
means that a simple library upgrade can result in tons of rebuilds, just
to make the .la files happy.


Why would we NOT want to remove the .la files?
----------------------------------------------
The .la files are still useful for linking static libs.

However, most of the packages that contain .la files contain no static
libs and the .la files should be safe to remove from there.

For static libs, the pkgconfig files have a special Libs.private section
with the same purpose. Most of the packages that use libtool also tend
to use pkg-config for linking, so they get the necessary information
also from the .pc files and the .la files are hopefully not needed.


-- 
Kalev


More information about the mingw mailing list