Debian Codegraph @

cmake/README.DebianABIManager

raw
1 Glossary
2 --------
3
4 * BC - Binary Compatibility.
5
6 * BIC - Binary InCompatible.
7
8 * Undefined (UNDEF) symbol - a symbol reference. It will be resolved to
9 the implementation/definition in the external shared library by dynamic
10 linker.
11
12 * Unstable-BC library - a library which is prone to break BC without SONAME
13 change.
14
15 Background
16 ----------
17
18 1) Unstable-BC libraries should get all symbols versioned from the beginning.
19 That's because undefined unversioned symbols may bind to any symbol of the
20 same name in any library which dynamic linker (recursively) loaded [1]:
21
22 | In case only the object file with the reference does not use versioning
23 | but the object with the definition does, then the reference only matches
24 | the base definition. [ ...] If there is no symbol definition with such an
25 | version index and there is exactly one version for which this symbol is
26 | defined, then this version is accepted.
27
28 It does not matter if a real symbol in the library is versioned or not. The
29 first same-name real symbol seen by dynamic linker will be bound to the
30 unversioned UNDEF. It means that developers basically have no control over
31 this process UNDEF symbol is unversioned.
32
33 2) Unlike unversioned (Base) symbols, versioned UNDEF symbols have version
34 and originating library information assigned to them. According to [1]:
35
36 | The last case is if the object with the references uses symbol
37 | versions but the object with the definitions has none. In this case a
38 | matching symbol is accepted unless the object's name matches the one
39 | in the Elfxx_Verneed entry. In the latter case this is a fatal error.
40
41 However, I determined that this is not the case since middle 1999 [2]. This
42 situation is not a fatal error but merely a warning [3]. However, I'm pretty
43 sure that it's a bug in the dynamic linker which may get fixed one day.
44 Respective assert() is in place [4] but it does not fire in release builds.
45
46 3) Versioned symbols cannot be easily "moved" from one library to another down
47 the library dependency tree without breakage (as it was done e.g. with
48 "libkutils4 -> libkcmutils4 libkemoticons4 libkidletime4 libkprintutils4"
49 split). But this should be a non-issue for unstable-BC libraries.
50
51 Having in mind the points 1 and 2 above, all symbols in the unstable-BC
52 libraries should get a unique-per-ABI version. As soon as upstream breaks BC
53 without bumping SOVERSION, SONAME should be bumped package name should be
54 changed. However, initially, it is better to keep original upstream SONAME.
55 This strategy allows to preserve some compatibility with the rest of the world
56 as long as upstream does not break BC without bumping SOVERSION (i.e. plays
57 nice). In particular:
58
59 a) external binaries (which supposedly have unversioned UNDEF symbols as
60 pushed by upstream, see point 1) will work with unstable-BC libraries as
61 packaged by Debian;
62
63 b) binaries with versioned UNDEF symbols (i.e. linked against our unstable-
64 BC libraries) will work with unstable-BC libraries as built from upstream
65 sources (kdesrc-build) or packaged by other distros which do not use
66 incompatible symbol versioning. That's because of point 2 and as long as
67 the linker bug is not fixed.
68
69 BC handling with DebianABIManager
70 ---------------------------------
71
72 In order to minimize patching of upstream sources, tasks of SONAME (SOVERSION)
73 bumping and symbol versioning (as described above) are handled by
74 DebianABIManager.cmake script [5] on-the-fly.
75
76 DebianABIManager is capable of managing only a single library per binary
77 package. Morever, the package must be properly named according to Debian
78 library naming standards (as enforced by lintian). DebianABIManager is
79 configured via a couple of custom debian/control fields.
80
81 * X-Debian-ABI - specifies a custom ABI sequence number to be assigned for the
82 library in question. Its presence tells DebianABIManager to process the
83 package so all unstable-BC library packages must have it. The value must be a
84 non-negative integer. Whenever a new unstable-BC library is introduced or
85 upstream changes SONAME of the existing one, the value of this field should
86 be set to 0. In that case, the script won't change SONAME but only version
87 symbols of the library. Whenever the library breaks BC without changing
88 SONAME, bump this value. Then the script will change both SONAME and symbol
89 versions of the library.
90
91 * X-CMake-Target - typically DebianABIManager should be able to guess CMake
92 target of the library from the package name. However, sometimes it may fail
93 to do so (e.g. when upstream changed OUTPUT_NAME of the target or package
94 name is non-standard). Then speficy this field and set it to the proper CMake
95 target name for the library.
96
97 In order to use DebianABIManager in the source package, add the following line
98 near the bottom of the main CMakeLists.txt (recommended patch name -
99 enable_debianabimanager.diff) and pass -DCMAKE_BUILD_TYPE=Debian to cmake
100 (the latter is implicit for KDE packages in Debian). Otherwise,
101 DebianABIManager won't have any effect.
102
103 include(/usr/share/pkg-kde-tools/cmake/DebianABIManager.cmake)
104
105 Internally, the script sets "ABI_<upstream SOVERSION>_<X-Debian-ABI>" version
106 for all symbols of the library (via --version-script linker option). In addition,
107 if X-Debian-ABI value is greater than 0, SOVERSION and VERSION properties of the
108 library target will be modified by appending strings "abi<X-Debian-ABI>" and
109 ".abi<X-Debian-ABI>" respectively to them. As this effectively changes the
110 SONAME and filename of the library, make sure to adjust package name and
111 install file accordingly.
112
113 Examples
114 --------
115
116 1) debian/control:
117
118 Package: libfoo4
119 X-Debian-ABI: 0
120
121 Symbols of the library (CMake target "foo") with SONAME "libfoo.so.4" will be
122 versioned as "ABI_4_0". SONAME and library filename are kept unchanged from
123 original.
124
125 2) debian/control:
126
127 Package: libbar5abi1
128 X-Debian-ABI: 1
129
130 SONAME of the library (CMake target "bar") will be changed from "libbar.so.5"
131 to "libbar.so.5abi1". Original library filename will get ".abi1" suffix due to
132 modified VERSION property. Symbols will be versioned as "ABI_5_1".
133
134 3) debian/control:
135
136 Package: libfoobaz2abi10
137 X-Debian-ABI: 10
138 X-CMake-Target: foobazlib
139
140 SONAME of the library (CMake target "foobazlib") will be changed from
141 "libfoobaz.so.2" to "libfoobaz.so.2abi10". Original library filename will get
142 ".abi10" suffix due to modified VERSION property. Symbols will be versioned as
143 "ABI_2_10".
144
145 KDE Software Compiliation 4.6
146 -----------------------------
147
148 DebianABIManager is used for KDE SC packaging since 4.6. Therefore, all
149 unstable-BC library packages that kept BC throughout 4.4 -> 4.6 cycle should
150 be assigned "X-Debian-ABI: 0" field. Otherwise, if the library broke BC but
151 kept the SONAME, X-Debian-ABI should be set to 1 and packages should be renamed
152 by appending "abi1" to their name (discarding previous [a-f] suffixes if any).
153
154 As 4.6 is a transitional release from unversioned to versioned symbols, it
155 might make sense to add "Breaks" against old libs (<< 4:4.6) to all future
156 "abi1" packages. That's to avoid weird crashes if both old unversioned and new
157 versioned BIC libraries end up getting loaded in the same process space. While
158 it's possible, it's also highly unlikely because unstable-BC libs are not very
159 popular. So let's not do this "Breaks" stuff for first release.
160
161 [1] http://www.akkadia.org/drepper/symbol-versioning
162 [2] http://sourceware.org/git/?p=glibc.git;a=commit;h=9a8fcca0b33c26759134a545ac45251df53418a3
163 [3] <apppath>: <libpath>: no version information available (required by <apppath>)
164 [4] http://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-lookup.c;hb=glibc-2.13#l168
165 [5] /usr/share/pkg-kde-tools/cmake/DebianABIManager.cmake
166
167 -- Modestas Vainius <[email protected]> Wed, 30 Mar 2011 16:24:17 +0300