]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
wafsamba: the symbol version string of private libraries should be based on the tople...
authorStefan Metzmacher <metze@samba.org>
Thu, 1 Jul 2021 13:29:46 +0000 (15:29 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 30 Nov 2021 15:53:34 +0000 (15:53 +0000)
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>
buildtools/wafsamba/samba_abi.py
buildtools/wafsamba/wafsamba.py
buildtools/wafsamba/wscript

index bf82fc5fe1fc806c1996e179a2682ca769109bb0..b0a8b02cf2152b9737240cf4d2fbb494799d56a2 100644 (file)
@@ -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
index f6ed3a7394717753cace5d30316f69f4aac872a7..a07b07890c04b9ae74ce9061728dd1e22b9df4f0 100644 (file)
@@ -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
index 12999c0622c27477b0745ed17f8ceff51f7919e4..62b63fef1458049497925e1378b1b1c0f4f55f91 100644 (file)
@@ -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