diff options
author | Stefan Metzmacher <metze@samba.org> | 2021-07-01 15:29:46 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2021-11-30 15:53:34 +0000 |
commit | 33e6949dda83996550d126d7de09a13691ff35cc (patch) | |
tree | 25ebe14a51ad7483e7fdfdda2f6163025f734e03 /buildtools | |
parent | da7c41e26016845f0dfd78601987c075ef8711a6 (diff) | |
download | samba-33e6949dda83996550d126d7de09a13691ff35cc.tar.gz |
wafsamba: the symbol version string of private libraries should be based on the toplevel project
If we build a private library all symbols should be made private based
on a unique suffix.
When we use a unique soname and a unique symbol version suffix it's very unlikely
to hit conflicts due to inherited libraries.
For the abi checking we still use the original vnum as abi_vnum.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'buildtools')
-rw-r--r-- | buildtools/wafsamba/samba_abi.py | 23 | ||||
-rw-r--r-- | buildtools/wafsamba/wafsamba.py | 8 | ||||
-rw-r--r-- | buildtools/wafsamba/wscript | 2 |
3 files changed, 27 insertions, 6 deletions
diff --git a/buildtools/wafsamba/samba_abi.py b/buildtools/wafsamba/samba_abi.py index bf82fc5fe1f..b0a8b02cf21 100644 --- a/buildtools/wafsamba/samba_abi.py +++ b/buildtools/wafsamba/samba_abi.py @@ -142,7 +142,7 @@ def abi_check(self): abi_gen = os.path.join(topsrc, 'buildtools/scripts/abi_gen.sh') abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.version_libname, - self.vnum) + self.abi_vnum) tsk = self.create_task('abi_check', self.link_task.outputs[0]) tsk.ABI_FILE = abi_file @@ -214,21 +214,32 @@ def abi_build_vscript(task): symmap = {} versions = [] + abi_match = list(task.env.ABI_MATCH) for f in task.inputs: fname = f.abspath(task.env) basename = os.path.basename(fname) version = basename[len(task.env.LIBNAME)+1:-len(".sigs")] versions.append(version) abi_process_file(fname, version, symmap) + if task.env.PRIVATE_LIBRARY: + # For private libraries we need to inject + # each public symbol explicitly into the + # abi match array and remove all explicit + # versioning so that each exported symbol + # is tagged with the private library tag. + for s in symmap: + abi_match.append(s) + symmap = {} + versions = [] f = open(tgt, mode='w') try: abi_write_vscript(f, task.env.LIBNAME, task.env.VERSION, versions, - symmap, task.env.ABI_MATCH) + symmap, abi_match) finally: f.close() -def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None): +def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None, private_library=False): '''generate a vscript file for our public libraries''' if abi_directory: source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' % (abi_directory, libname), flat=True) @@ -238,6 +249,9 @@ def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None): else: source = '' + if private_library is None: + private_library = False + libname = os.path.basename(libname) version = os.path.basename(version) libname = libname.replace("-", "_").replace("+","_").upper() @@ -255,5 +269,6 @@ def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None): t.env.ABI_MATCH = abi_match t.env.VERSION = version t.env.LIBNAME = libname - t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH'] + t.env.PRIVATE_LIBRARY = private_library + t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH', 'PRIVATE_LIBRARY'] Build.BuildContext.ABI_VSCRIPT = ABI_VSCRIPT diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index f6ed3a73947..a07b07890c0 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -222,6 +222,8 @@ def SAMBA_LIBRARY(bld, libname, source, raise Errors.WafError("public library '%s' must have header files" % libname) + abi_vnum = vnum + if bundled_name is not None: pass elif target_type == 'PYTHON' or realname or not private_library: @@ -232,6 +234,7 @@ def SAMBA_LIBRARY(bld, libname, source, else: assert (private_library == True and realname is None) bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-')) + vnum = None ldflags = TO_LIST(ldflags) if bld.env['ENABLE_RELRO'] is True: @@ -258,7 +261,7 @@ def SAMBA_LIBRARY(bld, libname, source, vscript = None if bld.env.HAVE_LD_VERSION_SCRIPT: if private_library: - version = "%s_%s" % (Context.g_module.APPNAME, Context.g_module.VERSION) + version = bld.env.PRIVATE_VERSION elif vnum: version = "%s_%s" % (libname, vnum) else: @@ -266,7 +269,7 @@ def SAMBA_LIBRARY(bld, libname, source, if version: vscript = "%s.vscript" % libname bld.ABI_VSCRIPT(version_libname, abi_directory, version, vscript, - abi_match) + abi_match, private_library) fullname = apply_pattern(bundled_name, bld.env.cshlib_PATTERN) fullpath = bld.path.find_or_declare(fullname) vscriptpath = bld.path.find_or_declare(vscript) @@ -303,6 +306,7 @@ def SAMBA_LIBRARY(bld, libname, source, samba_install = install, abi_directory = "%s/%s" % (bld.path.abspath(), abi_directory), abi_match = abi_match, + abi_vnum = abi_vnum, private_library = private_library, grouping_library=grouping_library, allow_undefined_symbols=allow_undefined_symbols diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 12999c0622c..62b63fef145 100644 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -269,6 +269,8 @@ def configure(conf): conf.env.PRIVATE_EXTENSION = Options.options.PRIVATE_EXTENSION conf.env.PRIVATE_EXTENSION_EXCEPTION = Options.options.PRIVATE_EXTENSION_EXCEPTION.split(',') + conf.env.PRIVATE_VERSION = "%s_%s_%s" % (Context.g_module.APPNAME, + Context.g_module.VERSION, conf.env.PRIVATE_EXTENSION) conf.env.CROSS_COMPILE = Options.options.CROSS_COMPILE conf.env.CROSS_EXECUTE = Options.options.CROSS_EXECUTE |