From 8fb9c7b8623c7d04dc337a48084b912467816689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Mon, 2 Jun 2014 02:36:13 +0200 Subject: [PATCH 01/26] Remove last instances of pep8 error E712 (use 'is' rather than '==' for booleans) Signed-Off-By: Jelmer Vernooij Reviewed-by: Andrew Bartlett Change-Id: I43b394a6225b4c2049d979fda75548c82d781f67 (cherry picked from commit bd6faaf56a6237874cc84ddb8be0f09a9b742a54) --- buildtools/wafsamba/samba3.py | 4 ++-- buildtools/wafsamba/wafsamba.py | 6 +++--- source4/scripting/bin/samba_upgradeprovision | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/buildtools/wafsamba/samba3.py b/buildtools/wafsamba/samba3.py index 64cd8c7..571954d 100644 --- a/buildtools/wafsamba/samba3.py +++ b/buildtools/wafsamba/samba3.py @@ -10,9 +10,9 @@ def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True, with_name="with", without_name="without"): if default is None: default_str="auto" - elif default == True: + elif default is True: default_str="yes" - elif default == False: + elif default is False: default_str="no" else: default_str=str(default) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index e564877..128dff3 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -353,10 +353,10 @@ def SAMBA_BINARY(bld, binname, source, # only specify PIE flags for binaries pie_cflags = cflags pie_ldflags = TO_LIST(ldflags) - if bld.env['ENABLE_PIE'] == True: + if bld.env['ENABLE_PIE'] is True: pie_cflags += ' -fPIE' pie_ldflags.extend(TO_LIST('-pie')) - if bld.env['ENABLE_RELRO'] == True: + if bld.env['ENABLE_RELRO'] is True: pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now')) # first create a target for building the object files for this binary @@ -730,7 +730,7 @@ sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"]) lineno = 0 for line in source_file: newline = line - if lineno == 0 and task.env["PYTHON_SPECIFIED"] == True and line[:2] == "#!": + if lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and line[:2] == "#!": newline = replacement_shebang elif pattern in line: newline = line.replace(pattern, replacement) diff --git a/source4/scripting/bin/samba_upgradeprovision b/source4/scripting/bin/samba_upgradeprovision index c4a0f79..1893d03 100755 --- a/source4/scripting/bin/samba_upgradeprovision +++ b/source4/scripting/bin/samba_upgradeprovision @@ -1786,7 +1786,7 @@ if __name__ == '__main__': # as we are assured that on this DNs we will have differences ! # Also the check must be done in a clever way as for the moment we just # compare SDDL - if dnNotToRecalculateFound == False and (opts.debugchangesd or opts.debugall): + if dnNotToRecalculateFound is False and (opts.debugchangesd or opts.debugall): message(CHANGESD, "Checking recalculated SDs") check_updated_sd(new_ldbs.sam, ldbs.sam, names) -- 1.9.1 From f591f976876ec523595ea3c35eb85e758fd33ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Mon, 2 Jun 2014 02:53:01 +0200 Subject: [PATCH 02/26] Fix more pep8 issues in code I touched recently. Signed-Off-By: Jelmer Vernooij Reviewed-by: Andrew Bartlett Change-Id: I35f3204bdf5d00b3280d703427ded2fa2163a6f7 (similar to commit 0c2408531709eb720a2e96f72afbc2ecbfe6b06d) This only backports the buildtools/wafsamba/ changes --- buildtools/wafsamba/samba3.py | 9 +++++---- buildtools/wafsamba/wafsamba.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/buildtools/wafsamba/samba3.py b/buildtools/wafsamba/samba3.py index 571954d..ffe6784 100644 --- a/buildtools/wafsamba/samba3.py +++ b/buildtools/wafsamba/samba3.py @@ -6,16 +6,17 @@ from optparse import SUPPRESS_HELP from samba_utils import os_path_relpath, TO_LIST from samba_autoconf import library_flags + def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True, with_name="with", without_name="without"): if default is None: - default_str="auto" + default_str = "auto" elif default is True: - default_str="yes" + default_str = "yes" elif default is False: - default_str="no" + default_str = "no" else: - default_str=str(default) + default_str = str(default) if help == (): help = ("Build with %s support (default=%s)" % (option, default_str)) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index 128dff3..30fbf13 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -730,7 +730,8 @@ sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"]) lineno = 0 for line in source_file: newline = line - if lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and line[:2] == "#!": + if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and + line[:2] == "#!"): newline = replacement_shebang elif pattern in line: newline = line.replace(pattern, replacement) -- 1.9.1 From c3a9b615124be0b8c59f2a7ce38dc7c2150d21ab Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Nov 2014 16:22:30 +0000 Subject: [PATCH 03/26] Don't use a nested function when testing for visibility attribute support. Some compilers support __attribute__((visibility)), but not nested functions (e.g. http://www.cprover.org/goto-cc/) Change-Id: I01a5dd6f5f913664621c4090e2dca177527436bb Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749983 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749985 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749986 Signed-Off-By: Jelmer Vernooij Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Mon Nov 10 08:29:19 CET 2014 on sn-devel-104 (cherry picked from commit 2afc5b797826780c07e04ed153edc82f410668a2) --- lib/replace/wscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/replace/wscript b/lib/replace/wscript index 16fd50b..7bbe1d6 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -639,10 +639,10 @@ removeea setea if conf.CHECK_CFLAGS('-fvisibility=hidden'): conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden' - conf.CHECK_CODE('''void vis_foo1(void) {} + conf.CHECK_CODE('''int main(void) { return 0; } __attribute__((visibility("default"))) void vis_foo2(void) {}''', cflags=conf.env.VISIBILITY_CFLAGS, - define='HAVE_VISIBILITY_ATTR') + define='HAVE_VISIBILITY_ATTR', addmain=False) # look for a method of finding the list of network interfaces for method in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']: -- 1.9.1 From 5fe7292e72f1c7e6dbdc303b8f04bd7ff74a15da Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Fri, 26 Sep 2014 23:46:01 +0200 Subject: [PATCH 04/26] Reduce the no-op build times by 30% Change-Id: Ie68436c1e7c75c1786e9ed6b6a54d2b55abbbcea Reviewed-by: Matthieu Patou Reviewed-by: Stefan Metzmacher Autobuild-User(master): Michael Adam Autobuild-Date(master): Fri Oct 3 13:25:18 CEST 2014 on sn-devel-104 (cherry picked from commit 1c5ef289a872cf0dc78b2e9dd35b20fa99db86fb) --- buildtools/wafsamba/samba_deps.py | 6 +- buildtools/wafsamba/samba_optimisation.py | 145 ++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 3 deletions(-) diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py index c00744e..3be9956 100644 --- a/buildtools/wafsamba/samba_deps.py +++ b/buildtools/wafsamba/samba_deps.py @@ -1021,7 +1021,7 @@ def save_samba_deps(bld, tgt_list): denv.outenv[t.sname] = tdeps depsfile = os.path.join(bld.bdir, "sambadeps") - denv.store(depsfile) + denv.store_fast(depsfile) @@ -1031,12 +1031,12 @@ def load_samba_deps(bld, tgt_list): denv = Environment.Environment() try: debug('deps: checking saved dependencies') - denv.load(depsfile) + denv.load_fast(depsfile) if (denv.version != savedeps_version or denv.savedeps_inputs != savedeps_inputs or denv.savedeps_outputs != savedeps_outputs): return False - except: + except Exception: return False # check if critical files have changed diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py index f0f430d..1333f8b 100644 --- a/buildtools/wafsamba/samba_optimisation.py +++ b/buildtools/wafsamba/samba_optimisation.py @@ -6,6 +6,7 @@ # overall this makes some build tasks quite a bit faster +import Build, Utils, Node from TaskGen import feature, after import preproc, Task @@ -163,3 +164,147 @@ def suncc_wrap(cls): return oldrun(self) cls.run = run suncc_wrap(Task.TaskBase.classes['cc_link']) + + + +def hash_env_vars(self, env, vars_lst): + idx = str(id(env)) + str(vars_lst) + try: + return self.cache_sig_vars[idx] + except KeyError: + pass + + m = Utils.md5() + m.update(''.join([str(env[a]) for a in vars_lst])) + + ret = self.cache_sig_vars[idx] = m.digest() + return ret +Build.BuildContext.hash_env_vars = hash_env_vars + + +def store_fast(self, filename): + file = open(filename, 'wb') + data = self.get_merged_dict() + try: + Build.cPickle.dump(data, file, -1) + finally: + file.close() +Environment.Environment.store_fast = store_fast + +def load_fast(self, filename): + file = open(filename, 'rb') + try: + data = Build.cPickle.load(file) + finally: + file.close() + self.table.update(data) +Environment.Environment.load_fast = load_fast + +def is_this_a_static_lib(self, name): + try: + cache = self.cache_is_this_a_static_lib + except AttributeError: + cache = self.cache_is_this_a_static_lib = {} + try: + return cache[name] + except KeyError: + ret = cache[name] = 'cstaticlib' in self.bld.name_to_obj(name, self.env).features + return ret +TaskGen.task_gen.is_this_a_static_lib = is_this_a_static_lib + +def shared_ancestors(self): + try: + cache = self.cache_is_this_a_static_lib + except AttributeError: + cache = self.cache_is_this_a_static_lib = {} + try: + return cache[id(self)] + except KeyError: + + ret = [] + if 'cshlib' in self.features: # or 'cprogram' in self.features: + if getattr(self, 'uselib_local', None): + lst = self.to_list(self.uselib_local) + ret = [x for x in lst if not self.is_this_a_static_lib(x)] + cache[id(self)] = ret + return ret +TaskGen.task_gen.shared_ancestors = shared_ancestors + +@feature('cc', 'cxx') +@after('apply_link', 'init_cc', 'init_cxx', 'apply_core') +def apply_lib_vars(self): + """after apply_link because of 'link_task' + after default_cc because of the attribute 'uselib'""" + + # after 'apply_core' in case if 'cc' if there is no link + + env = self.env + app = env.append_value + seen_libpaths = set([]) + + # OPTIMIZATION 1: skip uselib variables already added (700ms) + seen_uselib = set([]) + + # 1. the case of the libs defined in the project (visit ancestors first) + # the ancestors external libraries (uselib) will be prepended + self.uselib = self.to_list(self.uselib) + names = self.to_list(self.uselib_local) + + seen = set([]) + tmp = Utils.deque(names) # consume a copy of the list of names + while tmp: + lib_name = tmp.popleft() + # visit dependencies only once + if lib_name in seen: + continue + + y = self.name_to_obj(lib_name) + if not y: + raise Utils.WafError('object %r was not found in uselib_local (required by %r)' % (lib_name, self.name)) + y.post() + seen.add(lib_name) + + # OPTIMIZATION 2: pre-compute ancestors shared libraries (100ms) + tmp.extend(y.shared_ancestors()) + + # link task and flags + if getattr(y, 'link_task', None): + + link_name = y.target[y.target.rfind('/') + 1:] + if 'cstaticlib' in y.features: + app('STATICLIB', link_name) + elif 'cshlib' in y.features or 'cprogram' in y.features: + # WARNING some linkers can link against programs + app('LIB', link_name) + + # the order + self.link_task.set_run_after(y.link_task) + + # for the recompilation + dep_nodes = getattr(self.link_task, 'dep_nodes', []) + self.link_task.dep_nodes = dep_nodes + y.link_task.outputs + + # OPTIMIZATION 3: reduce the amount of function calls + # add the link path too + par = y.link_task.outputs[0].parent + if id(par) not in seen_libpaths: + seen_libpaths.add(id(par)) + tmp_path = par.bldpath(self.env) + if not tmp_path in env['LIBPATH']: + env.prepend_value('LIBPATH', tmp_path) + + + # add ancestors uselib too - but only propagate those that have no staticlib + for v in self.to_list(y.uselib): + if v not in seen_uselib: + seen_uselib.add(v) + if not env['STATICLIB_' + v]: + if not v in self.uselib: + self.uselib.insert(0, v) + + # 2. the case of the libs defined outside + for x in self.uselib: + for v in self.p_flag_vars: + val = self.env[v + '_' + x] + if val: + self.env.append_value(v, val) -- 1.9.1 From 9fd79b61bdf5d673226715eae76791524df31755 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 7 Nov 2014 09:36:16 +0100 Subject: [PATCH 05/26] wafsamba: add -Werror=return-type for developer builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids errors like this: ../source3/utils/status.c: In function ‘print_share_mode’: ../source3/utils/status.c:126:3: error: ‘return’ with no value, in function returning non-void [-Werror=return-type] return; Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison (cherry picked from commit 6ff9388172909ce249fd6254703eee707d821731) --- buildtools/wafsamba/samba_autoconf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index f60ce9d..c193873 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -671,6 +671,8 @@ def SAMBA_CONFIG_H(conf, path=None): testflags=True) conf.ADD_CFLAGS('-Werror=declaration-after-statement -Wdeclaration-after-statement', testflags=True) + conf.ADD_CFLAGS('-Werror=return-type -Wreturn-type', + testflags=True) conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True) # This check is because for ldb_search(), a NULL format string -- 1.9.1 From f4fa0b2489676f5856fd17015f3a19c0f15f193f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 18 Dec 2014 15:05:12 +0100 Subject: [PATCH 06/26] wafsamba: fill PRIVATE_NAME() logic again We append bld.env.PRIVATE_EXTENSION to the name of private libraries again, but only unless they have a abi_directory, vnum or soname defined. This avoids naming conflicts with system libraries, e.g. libidmap.so on Solaris Bug: https://bugzilla.samba.org/show_bug.cgi?id=10112 Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett (cherry picked from commit 76fdcf5c15bd904c3686f0c2dd93d27486c61ca4) --- buildtools/wafsamba/samba_bundled.py | 16 +++++++++++++++- buildtools/wafsamba/wafsamba.py | 9 ++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/buildtools/wafsamba/samba_bundled.py b/buildtools/wafsamba/samba_bundled.py index 45946d5..515590f 100644 --- a/buildtools/wafsamba/samba_bundled.py +++ b/buildtools/wafsamba/samba_bundled.py @@ -7,11 +7,25 @@ from samba_utils import * def PRIVATE_NAME(bld, name, private_extension, private_library): '''possibly rename a library to include a bundled extension''' + if not private_library: + return name + # we now use the same private name for libraries as the public name. # see http://git.samba.org/?p=tridge/junkcode.git;a=tree;f=shlib for a # demonstration that this is the right thing to do # also see http://lists.samba.org/archive/samba-technical/2011-January/075816.html - return name + if private_extension: + return name + + extension = bld.env.PRIVATE_EXTENSION + + if extension and name.startswith('%s' % extension): + return name + + if extension and name.endswith('%s' % extension): + return name + + return "%s-%s" % (name, extension) def target_in_list(target, lst, default): diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index 30fbf13..c62b732 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -124,7 +124,7 @@ def SAMBA_LIBRARY(bld, libname, source, pyembed=False, pyext=False, target_type='LIBRARY', - bundled_extension=True, + bundled_extension=False, link_name=None, abi_directory=None, abi_match=None, @@ -218,8 +218,11 @@ def SAMBA_LIBRARY(bld, libname, source, else: bundled_name = libname.replace('_', '-') else: - bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, - private_library) + assert (private_library == True and realname is None) + if abi_directory or vnum or soname: + bundled_extension=True + bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-'), + bundled_extension, private_library) ldflags = TO_LIST(ldflags) -- 1.9.1 From 7d89a2d37d6dec902c76f494d2a4acef4db884f1 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 18 Dec 2014 06:37:28 +0100 Subject: [PATCH 07/26] wafsamba: check for rpath compiler/linker flags Older SunOS linker only support -Wl,-R,/path instead of -Wl,-rpath,/path. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10112 Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Ralph Boehme Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett (cherry picked from commit 89cc31f5cf9181f04f3ca1a5f7000ee15a74e86e) --- buildtools/wafsamba/wscript | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 1a2cfe6..1a30d2f 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -295,6 +295,10 @@ def configure(conf): headers='stdio.h', msg='Checking simple C program') + # check which compiler/linker flags are needed for rpath support + if not conf.CHECK_LDFLAGS(['-Wl,-rpath,.']) and conf.CHECK_LDFLAGS(['-Wl,-R,.']): + conf.env['RPATH_ST'] = '-Wl,-R,%s' + # check for rpath if conf.CHECK_LIBRARY_SUPPORT(rpath=True): support_rpath = True -- 1.9.1 From de1b98f157e0ee99e94741d74403335e06064375 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 09:41:02 +0100 Subject: [PATCH 08/26] wafsamba: let TO_LIST(mylist) return a copy of mylist In most cases we have TO_LIST(mystring) which returns an independent list. newlist = TO_LIST(mylist) returned just a reference to mylist. Which means newlist.append("end") would also modify mylist. TO_LIST() should always return an independent list. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit ab4b988ba2ba85ec2bfb01d7711d6870b3e0f710) --- buildtools/wafsamba/samba_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 0b0bb48..9ac1066 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -214,7 +214,8 @@ def TO_LIST(str, delimiter=None): if str is None: return [] if isinstance(str, list): - return str + # we need to return a new independent list... + return list(str) if len(str) == 0: return [] lst = str.split(delimiter) -- 1.9.1 From ec5714bda45ae435768bfed901bac05bb1f09bdc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 09:48:38 +0100 Subject: [PATCH 09/26] wafsamba: move compiler / cflags related stuff from lib/replace to wafsamba We should have this just in one central place. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit 7a3dc668528f398458851aca5d27ff789414343a) --- buildtools/wafsamba/wscript | 21 +++++++++++++++++++++ lib/replace/wscript | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 1a30d2f..917a692 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -363,6 +363,27 @@ def configure(conf): conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True) conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True) + # on Tru64 certain features are only available with _OSF_SOURCE set to 1 + # and _XOPEN_SOURCE set to 600 + if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1': + conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True) + conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True) + + # SCM_RIGHTS is only avail if _XOPEN_SOURCE iѕ defined on IRIX + if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX': + conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True) + conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True) + + # Try to find the right extra flags for C99 initialisers + for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]: + if conf.CHECK_CFLAGS([f], ''' +struct foo {int x;char y;}; +struct foo bar = { .y = 'X', .x = 1 }; +'''): + if f != "": + conf.ADD_CFLAGS(f) + break + # get the base headers we'll use for the rest of the tests conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h', add_headers=True) diff --git a/lib/replace/wscript b/lib/replace/wscript index 7bbe1d6..0f29514 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -32,27 +32,6 @@ def configure(conf): conf.DEFINE('HAVE_LIBREPLACE', 1) conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1) - # on Tru64 certain features are only available with _OSF_SOURCE set to 1 - # and _XOPEN_SOURCE set to 600 - if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1': - conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True) - conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True) - - # SCM_RIGHTS is only avail if _XOPEN_SOURCE iѕ defined on IRIX - if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX': - conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True) - conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True) - - # Try to find the right extra flags for C99 initialisers - for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]: - if conf.CHECK_CFLAGS([f], ''' -struct foo {int x;char y;}; -struct foo bar = { .y = 'X', .x = 1 }; -'''): - if f != "": - conf.ADD_CFLAGS(f) - break - if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']): conf.ADD_CFLAGS('-fstack-protector') conf.ADD_LDFLAGS('-fstack-protector') -- 1.9.1 From 6d12ebccf455f8e66afa22a9aa8761c5859470fe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 09:52:53 +0100 Subject: [PATCH 10/26] wafsamba: move WERROR_CFLAGS checks from lib/replace to wafsamba Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit 0f4ce418ae1410a294aa6e629beea68c6a16aff8) --- buildtools/wafsamba/wscript | 13 +++++++++++++ lib/replace/wscript | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 917a692..0e2afe1 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -295,6 +295,19 @@ def configure(conf): headers='stdio.h', msg='Checking simple C program') + # Try to find the right extra flags for -Werror behaviour + for f in ["-Werror", # GCC + "-errwarn=%all", # Sun Studio + "-qhalt=w", # IBM xlc + "-w2", # Tru64 + ]: + if conf.CHECK_CFLAGS([f], ''' +'''): + if not 'WERROR_CFLAGS' in conf.env: + conf.env['WERROR_CFLAGS'] = [] + conf.env['WERROR_CFLAGS'].extend([f]) + break + # check which compiler/linker flags are needed for rpath support if not conf.CHECK_LDFLAGS(['-Wl,-rpath,.']) and conf.CHECK_LDFLAGS(['-Wl,-R,.']): conf.env['RPATH_ST'] = '-Wl,-R,%s' diff --git a/lib/replace/wscript b/lib/replace/wscript index 0f29514..60b714a 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -36,19 +36,6 @@ def configure(conf): conf.ADD_CFLAGS('-fstack-protector') conf.ADD_LDFLAGS('-fstack-protector') - # Try to find the right extra flags for -Werror behaviour - for f in ["-Werror", # GCC - "-errwarn=%all", # Sun Studio - "-qhalt=w", # IBM xlc - "-w2", # Tru64 - ]: - if conf.CHECK_CFLAGS([f], ''' -'''): - if not 'WERROR_CFLAGS' in conf.env: - conf.env['WERROR_CFLAGS'] = [] - conf.env['WERROR_CFLAGS'].extend([f]) - break - conf.CHECK_HEADERS('linux/types.h crypt.h locale.h acl/libacl.h compat.h') conf.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h') conf.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h') -- 1.9.1 From 6881c8390b93339af94cb61caf69c68cb62f4dd1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 09:54:43 +0100 Subject: [PATCH 11/26] wafsamba: move '-fstack-protector' checks from lib/replace to wafsamba This moves the check to the end of the configure run, which means we no longer use this on configure checks, but only for the real build. This behavior is similar than our developer cflags. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit 208be32c6a9b275c507fb5e3334b832a3cb9578a) --- buildtools/wafsamba/samba_autoconf.py | 4 ++++ lib/replace/wscript | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index c193873..54bb313 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -646,6 +646,10 @@ def SAMBA_CONFIG_H(conf, path=None): if not IN_LAUNCH_DIR(conf): return + if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']): + conf.ADD_CFLAGS('-fstack-protector') + conf.ADD_LDFLAGS('-fstack-protector') + if Options.options.debug: conf.ADD_CFLAGS('-g', testflags=True) diff --git a/lib/replace/wscript b/lib/replace/wscript index 60b714a..4693a79 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -32,10 +32,6 @@ def configure(conf): conf.DEFINE('HAVE_LIBREPLACE', 1) conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1) - if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']): - conf.ADD_CFLAGS('-fstack-protector') - conf.ADD_LDFLAGS('-fstack-protector') - conf.CHECK_HEADERS('linux/types.h crypt.h locale.h acl/libacl.h compat.h') conf.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h') conf.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h') -- 1.9.1 From bb83c48bc69e2e323d82542487f3a3ce5923e88f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 09:56:56 +0100 Subject: [PATCH 12/26] wafsamba: move -fvisibility=hidden checks from lib/replace to wafsamba Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit 4683fc0f1dc5af3bcf81edaebfbd6c8d3b38df9e) --- buildtools/wafsamba/wscript | 7 +++++++ lib/replace/wscript | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 0e2afe1..0a1cd1c 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -341,6 +341,13 @@ def configure(conf): else: conf.env.HAVE_LD_VERSION_SCRIPT = False + if conf.CHECK_CFLAGS('-fvisibility=hidden'): + conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden' + conf.CHECK_CODE('''int main(void) { return 0; } + __attribute__((visibility("default"))) void vis_foo2(void) {}''', + cflags=conf.env.VISIBILITY_CFLAGS, + define='HAVE_VISIBILITY_ATTR', addmain=False) + if sys.platform.startswith('aix'): conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True) # Might not be needed if ALL_SOURCE is defined diff --git a/lib/replace/wscript b/lib/replace/wscript index 4693a79..4d4d182 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -599,13 +599,6 @@ removeea setea execute=True, mandatory=True) # lets see if we get a mandatory failure for this one - if conf.CHECK_CFLAGS('-fvisibility=hidden'): - conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden' - conf.CHECK_CODE('''int main(void) { return 0; } - __attribute__((visibility("default"))) void vis_foo2(void) {}''', - cflags=conf.env.VISIBILITY_CFLAGS, - define='HAVE_VISIBILITY_ATTR', addmain=False) - # look for a method of finding the list of network interfaces for method in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']: if conf.CHECK_CODE(''' -- 1.9.1 From 851bf48b8ada104899dbfe11b88b2722cc28a0c1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 09:58:38 +0100 Subject: [PATCH 13/26] wafsamba: let CURRENT_CFLAGS() use bld.env.VISIBILITY_CFLAGS This is better than a hardcoded value in multiple places. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit 52eb8854ff8535577c9282f8e4133875fbb0ed33) --- buildtools/wafsamba/samba_autoconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index 54bb313..dc76673 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -781,7 +781,7 @@ def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=True, hide_symbols=False) list = bld.env['PICKY_CFLAGS']; ret.extend(list) if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR: - ret.append('-fvisibility=hidden') + ret.append(bld.env.VISIBILITY_CFLAGS) return ret -- 1.9.1 From 7376f3917938fad78bc5709dbc3832d5b2124fa3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 09:16:57 +0100 Subject: [PATCH 14/26] wafsamba: improve -fvisibility=hidden, we should check it together this WERROR_CFLAGS GCC ignores -fvisibility=hidden with a warning instead of failing om some platforms (e.g. Solaris). Bug: https://bugzilla.samba.org/show_bug.cgi?id=11031 Based on a patch from Tom Schulz . Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit 46fdd6221e9c64b459e0d05e6d02d89deb8dafb5) --- buildtools/wafsamba/wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 0a1cd1c..c49b20e 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -341,7 +341,7 @@ def configure(conf): else: conf.env.HAVE_LD_VERSION_SCRIPT = False - if conf.CHECK_CFLAGS('-fvisibility=hidden'): + if conf.CHECK_CFLAGS(['-fvisibility=hidden'] + conf.env.WERROR_CFLAGS): conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden' conf.CHECK_CODE('''int main(void) { return 0; } __attribute__((visibility("default"))) void vis_foo2(void) {}''', -- 1.9.1 From 3fb4486fbbcfb07e76bae08bd3d80877ec0d5bfc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Jan 2015 11:13:04 +0100 Subject: [PATCH 15/26] wafsamba: make it possible to specify ADDITIONAL_{CFLAGS,LDFLAGS} as env var to ./configure CFLAGS and LDFLAGS are also used during the configure checks and might impact their results. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit d744c7c080d81121b84a592a95761e03c2a1090c) --- buildtools/wafsamba/samba_autoconf.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index dc76673..cb33630 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -703,6 +703,19 @@ int main(void) { if Options.options.pedantic: conf.ADD_CFLAGS('-W', testflags=True) + + # Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS} + # environment variables which are only used the for final build. + # + # The CFLAGS and LDFLAGS environment variables are also + # used for the configure checks which might impact their results. + conf.add_os_flags('ADDITIONAL_CFLAGS') + if conf.env.ADDITIONAL_CFLAGS and conf.CHECK_CFLAGS(conf.env['ADDITIONAL_CFLAGS']): + conf.env['EXTRA_CFLAGS'].extend(conf.env['ADDITIONAL_CFLAGS']) + conf.add_os_flags('ADDITIONAL_LDFLAGS') + if conf.env.ADDITIONAL_LDFLAGS and conf.CHECK_LDFLAGS(conf.env['ADDITIONAL_LDFLAGS']): + conf.env['EXTRA_LDFLAGS'].extend(conf.env['ADDITIONAL_LDFLAGS']) + if path is None: conf.write_config_header('config.h', top=True) else: -- 1.9.1 From 64aee9eb0b5f19aa424b3d1fda3d268459a79c3a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 18 Dec 2014 18:09:15 +0100 Subject: [PATCH 16/26] wafsamba: fix ordering problems with lib-provided and internal RPATHs When a library or system (like cups) provides an RPATH, e.g. with -Wl,-R or -Wl,-rpath, this was added by waf to the LINKFLAGS, wich was later prepended to our RPATH. But if the path by chance contains an older version of one of our internal libraries like talloc, this would lead to linking the too old talloc into our binaries. This has been observed on, e.g., FreeBSD, but it is a general problem. This patch fixes the problem by specially parsing the RPATH linker options from the pkg-config(, cups-config, ....) output and putting the paths into the RPATH_ container, which is then later correctly appended to our internal RPATH. This is a better fix than commit 64f5e24100a764ec198cab9a8d2c43fa86e7027c as it touches wafsamba only. 64f5e24100a764ec198cab9a8d2c43fa86e7027c is already in waf 1.5 upstream, but has some possible bugs, e.g. it doesn't handle -Wl,-R, (with ',' at the end) or some combinations where the path is given via an additional -Wl,/path argument. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10548 Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Michael Adam Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison (cherry picked from commit dc808a466ef835535a3d4bb87f19316eeff1c567) --- buildtools/wafsamba/samba_conftests.py | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py index ec98ba0..07dda2a 100644 --- a/buildtools/wafsamba/samba_conftests.py +++ b/buildtools/wafsamba/samba_conftests.py @@ -4,6 +4,7 @@ import os, shutil, re import Build, Configure, Utils from Configure import conf +import config_c from samba_utils import * @@ -506,3 +507,55 @@ def CHECK_XSLTPROC_MANPAGES(conf): if not conf.CONFIG_SET('XSLTPROC_MANPAGES'): print "A local copy of the docbook.xsl wasn't found on your system" \ " consider installing package like docbook-xsl" + + +waf_config_c_parse_flags = config_c.parse_flags; +def samba_config_c_parse_flags(line1, uselib, env): + # + # We do a special treatment of the rpath components + # in the linkflags line, because currently the upstream + # parse_flags function is incomplete with respect to + # treatment of the rpath. The remainder of the linkflags + # line is later passed to the original funcion. + # + lst1 = shlex.split(line1) + lst2 = [] + while lst1: + x = lst1.pop(0) + + # + # NOTE on special treatment of -Wl,-R and -Wl,-rpath: + # + # It is important to not put a library provided RPATH + # into the LINKFLAGS but in the RPATH instead, since + # the provided LINKFLAGS get prepended to our own internal + # RPATH later, and hence can potentially lead to linking + # in too old versions of our internal libs. + # + # We do this filtering here on our own because of some + # bugs in the real parse_flags() function. + # + if x == '-Wl,-rpath' or x == '-Wl,-R': + linkflags.remove(x) + x = lst1.pop(0) + if x.startswith('-Wl,'): + rpath = x[4:] + else: + rpath = x + elif x.startswith('-Wl,-R,'): + rpath = x[7:] + elif x.startswith('-Wl,-R'): + rpath = x[6:] + elif x.startswith('-Wl,-rpath,'): + rpath = x[11:] + else: + lst2.append(x) + continue + + env.append_value('RPATH_' + uselib, rpath) + + line2 = ' '.join(lst2) + waf_config_c_parse_flags(line2, uselib, env) + + return +config_c.parse_flags = samba_config_c_parse_flags -- 1.9.1 From 2cb59ed8b1821ab185c9caa0d2ce2288775eb170 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 18 Dec 2014 21:36:07 +0100 Subject: [PATCH 17/26] wafsamba: filter out standard library paths from RPATH and LIBPATH We should avoid passing them explicitly to the compiler/linker. We ask the compiler with the '-print-search-dirs' argument or fallback to [ '/usr/lib', '/usr/lib64' ]. Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Michael Adam Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison (cherry picked from commit 707dc16987c982b75c83cd5b06d4373c23e777e0) --- buildtools/wafsamba/samba_conftests.py | 29 +++++++++++++++++++++++++++++ buildtools/wafsamba/samba_optimisation.py | 25 ++++++++++++++++++++++++- buildtools/wafsamba/wscript | 2 ++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py index 07dda2a..1afc6c9 100644 --- a/buildtools/wafsamba/samba_conftests.py +++ b/buildtools/wafsamba/samba_conftests.py @@ -508,6 +508,35 @@ def CHECK_XSLTPROC_MANPAGES(conf): print "A local copy of the docbook.xsl wasn't found on your system" \ " consider installing package like docbook-xsl" +# +# Determine the standard libpath for the used compiler, +# so we can later use that to filter out these standard +# library paths when some tools like cups-config or +# python-config report standard lib paths with their +# ldflags (-L...) +# +@conf +def CHECK_STANDARD_LIBPATH(conf): + # at least gcc and clang support this: + try: + cmd = conf.env.CC + ['-print-search-dirs'] + out = Utils.cmd_output(cmd).split('\n') + except ValueError: + # option not supported by compiler - use a standard list of directories + dirlist = [ '/usr/lib', '/usr/lib64' ] + except: + raise Utils.WafError('Unexpected error running "%s"' % (cmd)) + else: + dirlist = [] + for line in out: + line = line.strip() + if line.startswith("libraries: ="): + dirliststr = line[len("libraries: ="):] + dirlist = [ os.path.normpath(x) for x in dirliststr.split(':') ] + break + + conf.env.STANDARD_LIBPATH = dirlist + waf_config_c_parse_flags = config_c.parse_flags; def samba_config_c_parse_flags(line1, uselib, env): diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py index 1333f8b..583a651 100644 --- a/buildtools/wafsamba/samba_optimisation.py +++ b/buildtools/wafsamba/samba_optimisation.py @@ -6,8 +6,9 @@ # overall this makes some build tasks quite a bit faster +import os import Build, Utils, Node -from TaskGen import feature, after +from TaskGen import feature, after, before import preproc, Task @feature('cc', 'cxx') @@ -308,3 +309,25 @@ def apply_lib_vars(self): val = self.env[v + '_' + x] if val: self.env.append_value(v, val) + +@feature('cprogram', 'cshlib', 'cstaticlib') +@after('apply_lib_vars') +@before('apply_obj_vars') +def samba_before_apply_obj_vars(self): + """before apply_obj_vars for uselib, this removes the standard pathes""" + + def is_standard_libpath(env, path): + for _path in env.STANDARD_LIBPATH: + if _path == os.path.normpath(path): + return True + return False + + v = self.env + + for i in v['RPATH']: + if is_standard_libpath(v, i): + v['RPATH'].remove(i) + + for i in v['LIBPATH']: + if is_standard_libpath(v, i): + v['LIBPATH'].remove(i) diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index c49b20e..c81a7b3 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -211,6 +211,8 @@ def configure(conf): conf.check_tool('compiler_cc') + conf.CHECK_STANDARD_LIBPATH() + # we need git for 'waf dist' conf.find_program('git', var='GIT') -- 1.9.1 From c8387a19982371b601146dfa44df01844788e67c Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 19 Dec 2014 09:05:33 +0100 Subject: [PATCH 18/26] wafsamba: flags from enviroment are put before our own internal versions Ensure user provided CPPFLAGS and LDFLAGS are put *behind* our internally computed compiler and linker flags. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10877 Pair-Programmed-With: Michael Adam Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Ralph Boehme Signed-off-by: Michael Adam Signed-off-by: Stefan Metzmacher (cherry picked from commit a6bda1f2bc85779feb9680bc74821da5ccd401c5) --- buildtools/wafsamba/samba_optimisation.py | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py index 583a651..1e7a57f 100644 --- a/buildtools/wafsamba/samba_optimisation.py +++ b/buildtools/wafsamba/samba_optimisation.py @@ -331,3 +331,45 @@ def samba_before_apply_obj_vars(self): for i in v['LIBPATH']: if is_standard_libpath(v, i): v['LIBPATH'].remove(i) + +@feature('cc') +@before('apply_incpaths', 'apply_obj_vars_cc') +def samba_stash_cppflags(self): + """Fix broken waf ordering of CPPFLAGS""" + + self.env.SAVED_CPPFLAGS = self.env.CPPFLAGS + self.env.CPPFLAGS = [] + +@feature('cc') +@after('apply_incpaths', 'apply_obj_vars_cc') +def samba_pop_cppflags(self): + """append stashed user CPPFLAGS after our internally computed flags""" + + # + # Note that we don't restore the values to 'CPPFLAGS', + # but to _CCINCFLAGS instead. + # + # buildtools/wafadmin/Tools/cc.py defines the 'cc' task generator as + # '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT}' + # + # Our goal is to effectively invert the order of ${CPPFLAGS} and + # ${_CCINCFLAGS}. + self.env.append_value('_CCINCFLAGS', self.env.SAVED_CPPFLAGS) + self.env.SAVED_CPPFLAGS = [] + +@feature('cprogram', 'cshlib', 'cstaticlib') +@before('apply_obj_vars', 'add_extra_flags') +def samba_stash_linkflags(self): + """stash away LINKFLAGS in order to fix waf's broken ordering wrt or + user LDFLAGS""" + + self.env.SAVE_LINKFLAGS = self.env.LINKFLAGS + self.env.LINKFLAGS = [] + +@feature('cprogram', 'cshlib', 'cstaticlib') +@after('apply_obj_vars', 'add_extra_flags') +def samba_pop_linkflags(self): + """after apply_obj_vars append saved LDFLAGS""" + + self.env.append_value('LINKFLAGS', self.env.SAVE_LINKFLAGS) + self.env.SAVE_LINKFLAGS = [] -- 1.9.1 From 7cf587c7b1abdf9bab56a3916a9b357a08e0153d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Dec 2014 13:10:30 +0100 Subject: [PATCH 19/26] wafsamba: generate an empty.c file if a SAMBA_{LIBRARY,SUBSYSTEM} doesn't have any source files This is better than passing '-' as filename to the compiler/linker. This replaces commit 65743f932b511db009655847e77288c95c0aa525. Bug: https://bugzilla.samba.org/show_bug.cgi?id=9334 Bug: https://bugzilla.samba.org/show_bug.cgi?id=10315 Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme Reviewed-by: Michael Adam (cherry picked from commit d7bd51a79d0784d3db809c0c5e82193f79799dc3) --- buildtools/wafsamba/wafsamba.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index c62b732..7a5e23c 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -94,6 +94,11 @@ def ADD_INIT_FUNCTION(bld, subsystem, target, init_function): Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION +def generate_empty_file(task): + target_fname = installed_location=task.outputs[0].bldpath(task.env) + target_file = open(installed_location, 'w') + target_file.close() + return 0 ################################################################# def SAMBA_LIBRARY(bld, libname, source, @@ -149,9 +154,15 @@ def SAMBA_LIBRARY(bld, libname, source, source = bld.SUBDIR(subdir, source) # remember empty libraries, so we can strip the dependencies - if ((source == '') or (source == [])) and deps == '' and public_deps == '': - SET_TARGET_TYPE(bld, libname, 'EMPTY') - return + if ((source == '') or (source == [])): + if deps == '' and public_deps == '': + SET_TARGET_TYPE(bld, libname, 'EMPTY') + return + empty_c = libname + '.empty.c' + bld.SAMBA_GENERATOR('%s_empty_c' % libname, + rule=generate_empty_file, + target=empty_c) + source=empty_c if BUILTIN_LIBRARY(bld, libname): obj_target = libname @@ -537,9 +548,15 @@ def SAMBA_SUBSYSTEM(bld, modname, source, return # remember empty subsystems, so we can strip the dependencies - if ((source == '') or (source == [])) and deps == '' and public_deps == '': - SET_TARGET_TYPE(bld, modname, 'EMPTY') - return + if ((source == '') or (source == [])): + if deps == '' and public_deps == '': + SET_TARGET_TYPE(bld, modname, 'EMPTY') + return + empty_c = modname + '.empty.c' + bld.SAMBA_GENERATOR('%s_empty_c' % modname, + rule=generate_empty_file, + target=empty_c) + source=empty_c if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'): return -- 1.9.1 From 9ebcaa5a96722d590a2009d271a254cb5577bbaa Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 22 Dec 2014 11:27:40 +0100 Subject: [PATCH 20/26] Revert "waf: added suncc_wrap" This reverts commit 65743f932b511db009655847e77288c95c0aa525. Conflicts: buildtools/wafsamba/samba_optimisation.py Signed-off-by: Michael Adam Reviewed-by: Stefan Metzmacher (cherry picked from commit ffff95d421e3ca7fa31ec668a2e8fc7fdaee05df) --- buildtools/wafsamba/samba_optimisation.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py index 1e7a57f..8bd4dd6 100644 --- a/buildtools/wafsamba/samba_optimisation.py +++ b/buildtools/wafsamba/samba_optimisation.py @@ -9,7 +9,7 @@ import os import Build, Utils, Node from TaskGen import feature, after, before -import preproc, Task +import preproc @feature('cc', 'cxx') @after('apply_type_vars', 'apply_lib_vars', 'apply_core') @@ -151,23 +151,6 @@ Task.TaskBase.hash_constraints = hash_constraints # return task -def suncc_wrap(cls): - '''work around a problem with cc on solaris not handling module aliases - which have empty libs''' - if getattr(cls, 'solaris_wrap', False): - return - cls.solaris_wrap = True - oldrun = cls.run - def run(self): - if self.env.CC_NAME == "sun" and not self.inputs: - self.env = self.env.copy() - self.env.append_value('LINKFLAGS', '-') - return oldrun(self) - cls.run = run -suncc_wrap(Task.TaskBase.classes['cc_link']) - - - def hash_env_vars(self, env, vars_lst): idx = str(id(env)) + str(vars_lst) try: -- 1.9.1 From 1173070aa04389b4fac72bc73ef086bb1c9ae2cd Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 22 Dec 2014 11:30:21 +0100 Subject: [PATCH 21/26] wafsamba: remove commented out code. This code has only ever been there as commented out... Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Michael Adam Signed-off-by: Stefan Metzmacher (cherry picked from commit 9f2979a1a42f4714bdc49d09e4b5094333409834) --- buildtools/wafsamba/samba_optimisation.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py index 8bd4dd6..5def580 100644 --- a/buildtools/wafsamba/samba_optimisation.py +++ b/buildtools/wafsamba/samba_optimisation.py @@ -124,33 +124,6 @@ def hash_constraints(self): return sum Task.TaskBase.hash_constraints = hash_constraints - -# import cc -# from TaskGen import extension -# import Utils - -# @extension(cc.EXT_CC) -# def c_hook(self, node): -# task = self.create_task('cc', node, node.change_ext('.o')) -# try: -# self.compiled_tasks.append(task) -# except AttributeError: -# raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self)) - -# bld = self.bld -# try: -# dc = bld.dc -# except AttributeError: -# dc = bld.dc = {} - -# if task.outputs[0].id in dc: -# raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator)) -# else: -# dc[task.outputs[0].id] = task - -# return task - - def hash_env_vars(self, env, vars_lst): idx = str(id(env)) + str(vars_lst) try: -- 1.9.1 From 02a1a35ac401ffdbac54edc9867275208fe1329d Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Tue, 17 Sep 2013 00:00:40 +0200 Subject: [PATCH 22/26] wafadmin: backported the openbsd fixes from waf 1.7 This is a backport from waf 1.5... Reviewed-by: Michael Adam Reviewed-by: Stefan Metzmacher Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Jan 9 02:02:07 CET 2015 on sn-devel-104 (cherry picked from commit 115eb94215f4d9c73d05606de2ad978f6b48d07f) --- buildtools/wafadmin/Tools/ccroot.py | 18 ++++++++++++------ buildtools/wafadmin/Tools/gcc.py | 4 ++++ buildtools/wafadmin/Tools/gxx.py | 4 ++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/buildtools/wafadmin/Tools/ccroot.py b/buildtools/wafadmin/Tools/ccroot.py index 264bdc7..d59cf26 100644 --- a/buildtools/wafadmin/Tools/ccroot.py +++ b/buildtools/wafadmin/Tools/ccroot.py @@ -177,10 +177,14 @@ def get_target_name(self): dir, name = os.path.split(self.target) - if self.env.DEST_BINFMT == 'pe' and getattr(self, 'vnum', None) and 'cshlib' in self.features: - # include the version in the dll file name, - # the import lib file name stays unversionned. - name = name + '-' + self.vnum.split('.')[0] + if 'cshlib' in self.features and getattr(self, 'vnum', None): + nums = self.vnum.split('.') + if self.env.DEST_BINFMT == 'pe': + # include the version in the dll file name, + # the import lib file name stays unversionned. + name = name + '-' + nums[0] + elif self.env.DEST_OS == 'openbsd': + pattern = '%s.%s.%s' % (pattern, nums[0], nums[1]) return os.path.join(dir, pattern % name) @@ -598,14 +602,16 @@ def apply_vnum(self): if not path: return if self.env.DEST_OS == 'openbsd': - bld.install_as(path + os.sep + name2, node, env=self.env, chmod=self.link_task.chmod) + libname = self.link_task.outputs[0].name + bld.install_as('%s%s%s' % (path, os.sep, libname), node, env=self.env) else: bld.install_as(path + os.sep + name3, node, env=self.env) bld.symlink_as(path + os.sep + name2, name3) bld.symlink_as(path + os.sep + libname, name3) # the following task is just to enable execution from the build dir :-/ - self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)]) + if self.env.DEST_OS != 'openbsd': + self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)]) def exec_vnum_link(self): for x in self.outputs: diff --git a/buildtools/wafadmin/Tools/gcc.py b/buildtools/wafadmin/Tools/gcc.py index 420b44f..a6be0b2 100644 --- a/buildtools/wafadmin/Tools/gcc.py +++ b/buildtools/wafadmin/Tools/gcc.py @@ -114,6 +114,10 @@ def gcc_modifier_aix(conf): v['SHLIB_MARKER'] = '' @conftest +def gcc_modifier_openbsd(conf): + conf.env['SONAME_ST'] = [] + +@conftest def gcc_modifier_platform(conf): # * set configurations specific for a platform. # * the destination platform is detected automatically by looking at the macros the compiler predefines, diff --git a/buildtools/wafadmin/Tools/gxx.py b/buildtools/wafadmin/Tools/gxx.py index 8f4a0bf..4984122 100644 --- a/buildtools/wafadmin/Tools/gxx.py +++ b/buildtools/wafadmin/Tools/gxx.py @@ -112,6 +112,10 @@ def gxx_modifier_aix(conf): v['SHLIB_MARKER'] = '' @conftest +def gxx_modifier_openbsd(conf): + conf.env['SONAME_ST'] = [] + +@conftest def gxx_modifier_platform(conf): # * set configurations specific for a platform. # * the destination platform is detected automatically by looking at the macros the compiler predefines, -- 1.9.1 From 9a86ade1b9f1a7af81f2122911665bd6b40a16b4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 17 Jan 2015 00:24:53 +0100 Subject: [PATCH 23/26] wafsamba: make it possible to pass bundled_name to SAMBA_LIBRARY() Bug: https://bugzilla.samba.org/show_bug.cgi?id=10112 Signed-off-by: Stefan Metzmacher Reviewed-by: Jelmer Vernooij (cherry picked from commit 7668e457a6463fb2c1d7499659f37d10ca322190) --- buildtools/wafsamba/wafsamba.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index 7a5e23c..cbc0f44 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -130,6 +130,7 @@ def SAMBA_LIBRARY(bld, libname, source, pyext=False, target_type='LIBRARY', bundled_extension=False, + bundled_name=None, link_name=None, abi_directory=None, abi_match=None, @@ -223,7 +224,9 @@ def SAMBA_LIBRARY(bld, libname, source, raise Utils.WafError("public library '%s' must have header files" % libname) - if target_type == 'PYTHON' or realname or not private_library: + if bundled_name is not None: + pass + elif target_type == 'PYTHON' or realname or not private_library: if keep_underscore: bundled_name = libname else: -- 1.9.1 From 5bbca64365798c5a205d7801cdf915f2232dbcd6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 17 Jan 2015 00:24:53 +0100 Subject: [PATCH 24/26] wafsamba: passing 'subsystem' to SAMBA_MODULE() is not optional Bug: https://bugzilla.samba.org/show_bug.cgi?id=10112 Signed-off-by: Stefan Metzmacher Reviewed-by: Jelmer Vernooij (cherry picked from commit 85a30cc44070b09de963961ccfa3d7c40144317b) --- buildtools/wafsamba/wafsamba.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index cbc0f44..d403d65 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -445,13 +445,15 @@ def SAMBA_MODULE(bld, modname, source, ): '''define a Samba module.''' + bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname) + source = bld.EXPAND_VARIABLES(source, vars=vars) if subdir: source = bld.SUBDIR(subdir, source) if internal_module or BUILTIN_LIBRARY(bld, modname): # Do not create modules for disabled subsystems - if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': + if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': return bld.SAMBA_SUBSYSTEM(modname, source, deps=deps, @@ -472,18 +474,17 @@ def SAMBA_MODULE(bld, modname, source, return # Do not create modules for disabled subsystems - if subsystem and GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': + if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': return obj_target = modname + '.objlist' realname = modname - if subsystem is not None: - deps += ' ' + subsystem - while realname.startswith("lib"+subsystem+"_"): - realname = realname[len("lib"+subsystem+"_"):] - while realname.startswith(subsystem+"_"): - realname = realname[len(subsystem+"_"):] + deps += ' ' + subsystem + while realname.startswith("lib"+subsystem+"_"): + realname = realname[len("lib"+subsystem+"_"):] + while realname.startswith(subsystem+"_"): + realname = realname[len(subsystem+"_"):] realname = bld.make_libname(realname) while realname.startswith("lib"): -- 1.9.1 From 2253478b43a297d1b44deb4333de2d3f3fafbd4e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 17 Jan 2015 00:24:53 +0100 Subject: [PATCH 25/26] wafsamba: remove unused variable in SAMBA_MODULE() Bug: https://bugzilla.samba.org/show_bug.cgi?id=10112 Signed-off-by: Stefan Metzmacher Reviewed-by: Jelmer Vernooij (cherry picked from commit 4da20e2e31790ca54f17b4a6039c24b7b502ac5f) --- buildtools/wafsamba/wafsamba.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index d403d65..1319751 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -477,8 +477,6 @@ def SAMBA_MODULE(bld, modname, source, if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': return - obj_target = modname + '.objlist' - realname = modname deps += ' ' + subsystem while realname.startswith("lib"+subsystem+"_"): -- 1.9.1 From 3a7a5c9b81c3b5dc354cbd3febace8927bc66588 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 17 Jan 2015 00:24:53 +0100 Subject: [PATCH 26/26] wafsamba: create unique names when building shared modules After commit 76fdcf5c15bd904c3686f0c2dd93d27486c61ca4, we could endup with bin/default/source3/auth/libauth-samba4.so being created two times. Once by SAMBA3_LIBRARY('auth',...) and once again by SAMBA3_MODULE('auth_samba4', ...). As a result bin/default/source3/auth/libauth-samba4.so gets randomly overwritten. SAMBA3_MODULE('auth_samba4', ...) results in bin/default/source3/auth/libauth_module_samba4.so now. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10112 Signed-off-by: Stefan Metzmacher Reviewed-by: Jelmer Vernooij Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Mon Jan 19 04:43:53 CET 2015 on sn-devel-104 (cherry picked from commit 47155641cb48d39d3ee7d8b8962f5ed6b23617d4) --- buildtools/wafsamba/wafsamba.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index 1319751..188e535 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -484,6 +484,8 @@ def SAMBA_MODULE(bld, modname, source, while realname.startswith(subsystem+"_"): realname = realname[len(subsystem+"_"):] + build_name = "%s_module_%s" % (subsystem, realname) + realname = bld.make_libname(realname) while realname.startswith("lib"): realname = realname[len("lib"):] @@ -503,6 +505,7 @@ def SAMBA_MODULE(bld, modname, source, local_include=local_include, global_include=global_include, vars=vars, + bundled_name=build_name, link_name=build_link_name, install_path="${MODULESDIR}/%s" % subsystem, pyembed=pyembed, -- 1.9.1