Skip to content

Commit

Permalink
build: Set the ABI version properly
Browse files Browse the repository at this point in the history
Rational (from: https://gitlab.freedesktop.org/wayland/wayland/-/issues/175):

The ABI of a shared library on Linux is given by a major version, which
is part of the SONAME and is incremented (rarely) on incompatible changes,
and a minor version, which is part of the basename of the regular file to
which the SONAME provides a symlink. It's conventional to manage the ABI
version in the style of semantic versioning (major.minor.micro where the
major version goes up for incompatible changes, the minor version goes up
for new ABI, or the micro version goes up for internal fixes), although
this is not strictly required.

The minor version is used by `ldconfig(8)` and by some projects to choose
which of potentially several copies of a library is the newest; keeping
it the same means we can't tell, and will potentially choose an outdated
version.

---

In xkbcommon we did not have an API break for a long time, so in order
to avoid an unnecessary SONAME bump, let’s keep the major version version
at 0, e.g. xkbcommon 1.x.y produces `libxkbcommon.so.0.x.y`.

The same goes for `libxkbcommon-x11` and `libxkbregistry`.

Note: each library has its own handling of the major version, although
right now it is identical.
  • Loading branch information
wismill committed Jul 30, 2024
1 parent e83d08d commit a115cb8
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ project(
],
meson_version : '>= 0.58.0', # Released on May 2021
)
xkbcommon_project_version = meson.project_version().split('.')
pkgconfig = import('pkgconfig')
cc = meson.get_compiler('c')

Expand Down Expand Up @@ -254,14 +255,27 @@ elif cc.get_argument_syntax() == 'msvc'
libxkbcommon_link_deps += libxkbcommon_def
libxkbcommon_link_args += '/DEF:' + libxkbcommon_def.full_path()
endif
if xkbcommon_project_version[0] != '1'
# The versioning used for the shared libraries assumes that the major
# version of xkbcommon as a whole will increase to 2 if and only if there
# is an ABI break, at which point we should probably bump the SONAME of
# all libraries to .so.2.
error('We probably need to bump the SONAME of libxkbcommon')
else
# To avoid an unnecessary SONAME bump, xkbcommon 1.x.y produces
# libxkbcommon.so.0.x.y.
libxkbcommon_version = '.'.join(
['0', xkbcommon_project_version[1], xkbcommon_project_version[2]]
)
endif
libxkbcommon = library(
'xkbcommon',
'include/xkbcommon/xkbcommon.h',
libxkbcommon_sources,
link_args: libxkbcommon_link_args,
link_depends: libxkbcommon_link_deps,
gnu_symbol_visibility: 'hidden',
version: '0.0.0',
version: libxkbcommon_version,
install: true,
include_directories: include_directories('src', 'include'),
)
Expand Down Expand Up @@ -323,14 +337,27 @@ You can disable X11 support with -Denable-x11=false.''')
libxkbcommon_x11_link_deps += libxkbcommon_x11_def
libxkbcommon_x11_link_args += '/DEF:' + libxkbcommon_x11_def.full_path()
endif
if xkbcommon_project_version[0] != '1'
# The versioning used for the shared libraries assumes that the major
# version of xkbcommon as a whole will increase to 2 if and only if there
# is an ABI break, at which point we should probably bump the SONAME of
# all libraries to .so.2.
error('We probably need to bump the SONAME of libxkbcommon-x11')
else
# To avoid an unnecessary SONAME bump, xkbcommon 1.x.y produces
# libxkbcommon-x11.so.0.x.y.
libxkbcommon_x11_version = '.'.join(
['0', xkbcommon_project_version[1], xkbcommon_project_version[2]]
)
endif
libxkbcommon_x11 = library(
'xkbcommon-x11',
'include/xkbcommon/xkbcommon-x11.h',
libxkbcommon_x11_sources,
link_args: libxkbcommon_x11_link_args,
link_depends: libxkbcommon_x11_link_deps,
gnu_symbol_visibility: 'hidden',
version: '0.0.0',
version: libxkbcommon_x11_version,
install: true,
include_directories: include_directories('src', 'include'),
link_with: libxkbcommon,
Expand Down Expand Up @@ -385,6 +412,19 @@ if get_option('enable-xkbregistry')
libxkbregistry_link_deps += libxkbregistry_def
libxkbregistry_link_args += '/DEF:' + libxkbregistry_def.full_path()
endif
if xkbcommon_project_version[0] != '1'
# The versioning used for the shared libraries assumes that the major
# version of xkbcommon as a whole will increase to 2 if and only if there
# is an ABI break, at which point we should probably bump the SONAME of
# all libraries to .so.2.
error('We probably need to bump the SONAME of libxkbregistry')
else
# To avoid an unnecessary SONAME bump, xkbcommon 1.x.y produces
# libxkbregistry.so.0.x.y.
libxkbregistry_version = '.'.join(
['0', xkbcommon_project_version[1], xkbcommon_project_version[2]]
)
endif
libxkbregistry = library(
'xkbregistry',
'include/xkbcommon/xkbregistry.h',
Expand All @@ -393,7 +433,7 @@ if get_option('enable-xkbregistry')
link_depends: libxkbregistry_link_deps,
gnu_symbol_visibility: 'hidden',
dependencies: deps_libxkbregistry,
version: '0.0.0',
version: libxkbregistry_version,
install: true,
include_directories: include_directories('src', 'include'),
)
Expand Down

0 comments on commit a115cb8

Please sign in to comment.