Subject: bug#8765: Incorrect library versioning on *BSDs

From: Lasse Collin <[email-masked]>
Date: Mon, 30 May 2011 11:46:56 +0300

(Please CC replies to me, I'm not subscribed to the list.)

It seems that libtool does library versioning wrong on FreeBSD, NetBSD, 
OpenBSD, MirOS BSD (based on OpenBSD), and probably also DragonFly BSD 
(based on FreeBSD). I'm not an expert with *BSDs, but I have understood 
that the versioning should be similar to version_type=linux:

    GNU/Linux:  libfoo.so.$major.$age.$revision
    FreeBSD:    libfoo.so.$major  (It's ELF. a.out is dead.)
    NetBSD:     libfoo.so.$major.$age
    OpenBSD:    libfoo.so.$major.$age

That is, it shouldn't be libfoo.so.$current or 
libfoo.so.$current.$revision. Should this be fixed? The hard part is 
dealing with the (temporary) breakage that the fix would cause. It is 
problematic especially because the version numbers will get smaller 
(current vs. current-age) and thus may conflict with older versions of 
the library that have been built with older libtool versions.

There are some operating system specific hacks that fix the incorrect 
versioning used by unpatched GNU libtool. At least some packages in the 
FreeBSD ports use FreeBSD-specific "ltverhack". I don't know if it is 
used with all ports that use libtool.

On OpenBSD it's packager's job to handle library versioning, so upstream 
versioning is overriden. Also, most packages needing libtool get built 
using OpenBSD's own libtool (a Perl script) instead of GNU libtool.

MirOS BSD has a patched libtool which does the versioning correctly.

GNU libtool in NetBSD's pkgsrc has patches that change library 
versioning for multiple operating systems, including the *BSDs mentioned 
above.

If GNU libtool is fixed to use correct versioning on *BSDs, the 
existence of the OS-specific hacks might mean that many libraries won't 
be affected at all because the old libraries have already been built 
with corrected versioning. On the other hand, some libs might not have 
used those hacks so some breakage may still happen. Fixing the 
versioning in GNU libtool might also break the hacks that have been in 
use for many years.

Below are some references I happened to find.

FreeBSD:

  From FreeBSD Developer's Handbook:
    http://www.freebsd.org/doc/en/books/developers-handbook/policies-shlib.html

  Look for "ltverhack" on this page:
    http://www.freebsd.org/gnome/docs/gnome_porting.html

  Something more about ltverhack:
    http://freebsd.monkey.org/freebsd-multimedia/200702/msg00146.html
    http://people.freebsd.org/~mezz/libtool.txt

NetBSD:

  Patches in pkgsrc, see especially manual-libtool.m4:
    http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/devel/libtool/patches/

OpenBSD:

  Library versioning:
    http://www.openbsd.org/faq/ports/specialtopics.html

  OpenBSD libtool:
    http://www.openbsd.org/cgi-bin/cvsweb/ports/infrastructure/bin/libtool

MirOS BSD:

  A recent request to get MirOS BSD support into GNU libtool:
    http://lists.gnu.org/archive/html/libtool-patches/2011-02/msg00008.html

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode