openSUSE:Static library packaging policy

Jump to: navigation, search
Packaging static libraries is discouraged and should be done only for very good reasons

Packages that include libraries are generally expected to exclude static libraries whenever possible. This can often be achieved by configuring the build system with the --disable-static option. The inclusion of static libraries should be limited to exceptional cases where no viable alternative exists.

Applications that link against libraries should, wherever feasible, use shared libraries instead of static ones.

Libtool Archives

Libtool archive files, typically named foo.la, should not be included in packages. When using libtool, these files are installed by default, even if the build is configured with --disable-static. As such, they may need to be explicitly removed prior to packaging.

Due to bugs in older versions of libtool, or in programs that make use of it, it is sometimes not possible to safely remove *.la files without modifying the source. In many cases, however, it is feasible to collaborate with upstream maintainers to resolve these issues.

Icon-warning.png
Warning: It is important to note that if a library package in a stable openSUSE release already includes *.la files, their removal should be treated as an API/ABI change. Removing them alters the interface that the library presents to other software and should therefore be approached with caution.

Exception

It is important to be able to track which packages use static libraries, for example, to identify which packages need to be rebuilt if a security flaw in a static library is fixed.

If you really need to package static libraries, you must adhere to the following guideline.

Static libraries must be placed in a *-devel-static subpackage, which must Requires the corresponding *-devel subpackage. This separation allows tracking of static library usage by identifying which packages BuildRequire the *-devel-static package. The overall intent is to encourage migration from static libraries to shared libraries wherever feasible.

When a package provides only static libraries, the Requires on the *-devel subpackage may be omitted, assuming that the *-devel-static subpackage includes the necessary header files. Packages that explicitly need to link against the static version must then include BuildRequires: foo-devel-static, enabling usage tracking.

If (and only if) a package includes shared libraries that require static libraries to function correctly, the static libraries may be included in the *-devel subpackage. In such cases, the *-devel subpackage must provide a virtual Provides: *-devel-static, and any packages depending on it must still BuildRequire the *-devel-static package.