From 35134214ae819ad26ec388fa44dd37b24d72d3c4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Dec 2010 14:52:43 +1100 Subject: [PATCH] waf: use -Wl,--version-script if available This enables symbol version on our libraries, if the system supports it If the library is a public library, then set the symbol version based on the major number. If it is a private library then set it based on the full version number (which will include the git hash if available). This ensures that applications using our libraries don't use symbols from other libraries that they may be linked to. It also ensures we only use the right version of any private libraries. Note that the linker ends up generating both a version and unversioned symbol for all symbols. This means existing users of our public libraries will continue to work, with symbols resolved to the unversioned symbol. When applications are re-linked they will bind to the specific symbol version. Pair-Programmed-With: Andrew Bartlett Pair-Programmed-With: Jelmer Vernooij --- buildtools/wafsamba/samba_deps.py | 3 ++- buildtools/wafsamba/wafsamba.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py index 91737d58735..0ea966033cf 100644 --- a/buildtools/wafsamba/samba_deps.py +++ b/buildtools/wafsamba/samba_deps.py @@ -952,7 +952,8 @@ def show_object_duplicates(bld, tgt_list): ###################################################################### # this provides a way to save our dependency calculations between runs savedeps_version = 3 -savedeps_inputs = ['samba_deps', 'samba_includes', 'local_include', 'local_include_first', 'samba_cflags', 'source', 'grouping_library'] +savedeps_inputs = ['samba_deps', 'samba_includes', 'local_include', 'local_include_first', 'samba_cflags', + 'source', 'grouping_library', 'ldflags'] savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 'ccflags', 'ldflags', 'samba_deps_extended'] savedeps_outenv = ['INC_PATHS'] savedeps_envvars = ['NONSHARED_BINARIES', 'GLOBAL_DEPENDENCIES', 'EXTRA_CFLAGS', 'EXTRA_LDFLAGS' ] diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index 10b7dfe0f48..fc75def98dc 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -103,6 +103,7 @@ def SAMBA_LIBRARY(bld, libname, source, vnum=None, soname=None, cflags='', + ldflags='', external_library=False, realname=None, autoproto=None, @@ -188,11 +189,24 @@ def SAMBA_LIBRARY(bld, libname, source, else: bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library) + ldflags = TO_LIST(ldflags) + if private_library: if vnum: Logs.error("vnum is invalid for private libraries") sys.exit(1) - vnum = Utils.g_module.VERSION[0] + vnum = Utils.g_module.VERSION.split(".")[0] + version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION) + else: + version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION.split(".")[0]) + + if bld.env.HAVE_LD_VERSION_SCRIPT: + vscript = "%s.vscript" % libname + bld.SAMBA_GENERATOR(vscript, + rule="echo %s \{ global: \*\; \}\; > ${TGT}" % version.replace("-","_").upper(), + group='vscripts', + target=vscript) + ldflags.append("-Wl,--version-script=%s/%s" % (bld.path.abspath(bld.env), vscript)) features = 'cc cshlib symlink_lib install_lib' if target_type == 'PYTHON': @@ -213,6 +227,7 @@ def SAMBA_LIBRARY(bld, libname, source, source = [], target = bundled_name, depends_on = depends_on, + ldflags = ldflags, samba_deps = deps, samba_includes = includes, local_include = local_include, @@ -525,6 +540,7 @@ def SETUP_BUILD_GROUPS(bld): bld.env['USING_BUILD_GROUPS'] = True bld.add_group('setup') bld.add_group('build_compiler_source') + bld.add_group('vscripts') bld.add_group('base_libraries') bld.add_group('generators') bld.add_group('compiler_prototypes') -- 2.34.1