[cairo] Cairo should version its symbols

Nicholas Miell nmiell at gmail.com
Sat Nov 6 20:55:00 PDT 2010

The ELF object format allows you to attach version information to
individual symbols exported from a shared library.

Doing this has a number of benefits:

1) it allows package managers to automatically infer the version of a
shared library needed by a binary, decreasing the maintenance burden of
anybody who maintains a package that uses the library and reducing the
possibility of incorrect package metadata

2) the dynamic linker gives slightly more useful error messages when it
cannot find a required symbol in the library (e.g. "./check-link:
relocation error: ./check-link: symbol cairo_test_symbol, version
CAIRO_1.12 not defined in file libcairo.so.2 with link time reference")

3) it gives the software developer a better picture of what the binary
actually needs to run

A basic implementation of this is fairly painless, as evidenced by the
attached patch. I've only tested it on Linux. It should also work on
other ELF-based systems that use the GNU toolchain (i.e the BSDs).

AFAIK, Solaris is the only other ELF-based OS that supports versioned
symbols. If it is decided that cairo should version its symbols, support
for the Solaris toolchain will need to be merged in at (roughly) the
same time as the GNU toolchain support, otherwise two different sets of
symbol versions would need to be kept.

(Cairo already exports a large number of unversioned symbols as its
existing ABI. These symbols must remain unversioned even in the presence
of versioned symbols in order to maintain that ABI. If GNU toolchain
support is added in cairo version N and Solaris toolchain support is
added in version N+1, the set of unversioned symbols on Solaris will be
larger than those on Linux/*BSD and require different version scripts.)

Somebody familiar with development on Solaris would have to take an
interest, otherwise the symbol versioning would be unnecessarily

If we don't care about ever versioning symbols on Solaris at all, the
linker script wouldn't be necessary; GNU as supports a .symver directive
that can be embedded in C files via an asm("") directive.

It would be good if cairo's ABI was checked as a part of the build
process. The list of exported symbols and their versions could be
checked against an ABI checklist. This would prevent the inadvertent
addition of unversioned symbols or the accidental exposure of private
internal functions or even the removal of existing parts of the cairo ABI.

Questions? Comments? Any Solaris devs in the house?

More information about the cairo mailing list