From 56d0ecb720192a12a8f9ad26554c75c6bb65257a Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Mon, 7 Oct 2019 00:36:42 +0300 Subject: [PATCH 1/4] waf: backport test_args parameter This backports the addition of test_args parameter from Waf 2.0.18 (Waf commit bbaa976ae0147957db11504362e24df30c371354) BUG: https://bugzilla.samba.org/show_bug.cgi?id=13846 Signed-off-by: Uri Simchoni --- third_party/waf/waflib/Tools/c_config.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/third_party/waf/waflib/Tools/c_config.py b/third_party/waf/waflib/Tools/c_config.py index d546be95614..80580cc9fcb 100644 --- a/third_party/waf/waflib/Tools/c_config.py +++ b/third_party/waf/waflib/Tools/c_config.py @@ -659,20 +659,21 @@ class test_exec(Task.Task): """ color = 'PINK' def run(self): + cmd = [self.inputs[0].abspath()] + getattr(self.generator, 'test_args', []) if getattr(self.generator, 'rpath', None): if getattr(self.generator, 'define_ret', False): - self.generator.bld.retval = self.generator.bld.cmd_and_log([self.inputs[0].abspath()]) + self.generator.bld.retval = self.generator.bld.cmd_and_log(cmd) else: - self.generator.bld.retval = self.generator.bld.exec_command([self.inputs[0].abspath()]) + self.generator.bld.retval = self.generator.bld.exec_command(cmd) else: env = self.env.env or {} env.update(dict(os.environ)) for var in ('LD_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'PATH'): env[var] = self.inputs[0].parent.abspath() + os.path.pathsep + env.get(var, '') if getattr(self.generator, 'define_ret', False): - self.generator.bld.retval = self.generator.bld.cmd_and_log([self.inputs[0].abspath()], env=env) + self.generator.bld.retval = self.generator.bld.cmd_and_log(cmd, env=env) else: - self.generator.bld.retval = self.generator.bld.exec_command([self.inputs[0].abspath()], env=env) + self.generator.bld.retval = self.generator.bld.exec_command(cmd, env=env) @feature('test_exec') @after_method('apply_link') -- 2.21.0 From 370a9a5e39478951e1f3797de7f72a10c2ae00dc Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Mon, 7 Oct 2019 00:37:17 +0300 Subject: [PATCH 2/4] wafsamba: use test_args instead of exec_args to support cross-compilation exec_args seems to have been a custom addition to Samba's copy of waf. Upstream Waf has an identically-purposed parameter called test_args. This parameter is being used for addiing runtime args to test programs that are being run during configuration phases. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13846 Signed-off-by: Uri Simchoni --- buildtools/wafsamba/samba_autoconf.py | 6 +++--- buildtools/wafsamba/samba_cross.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index 63664a41160..683f0d5316b 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -422,9 +422,9 @@ def CHECK_CODE(conf, code, define, cflags.extend(ccflags) if on_target: - exec_args = conf.SAMBA_CROSS_ARGS(msg=msg) + test_args = conf.SAMBA_CROSS_ARGS(msg=msg) else: - exec_args = [] + test_args = [] conf.COMPOUND_START(msg) @@ -439,7 +439,7 @@ def CHECK_CODE(conf, code, define, type=type, msg=msg, quote=quote, - exec_args=exec_args, + test_args=test_args, define_ret=define_ret) except Exception: if always: diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py index 8863c2c53e7..60ddf967237 100644 --- a/buildtools/wafsamba/samba_cross.py +++ b/buildtools/wafsamba/samba_cross.py @@ -139,7 +139,7 @@ class cross_Popen(Utils.subprocess.Popen): @conf def SAMBA_CROSS_ARGS(conf, msg=None): - '''get exec_args to pass when running cross compiled binaries''' + '''get test_args to pass when running cross compiled binaries''' if not conf.env.CROSS_COMPILE: return [] -- 2.21.0 From f2ba032ce268f7f872156dfad40ddc20a606e037 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Mon, 7 Oct 2019 00:37:31 +0300 Subject: [PATCH 3/4] wafsamba: avoid pre-forking if cross-compilation is enabled Waf supports pre-forking to run configuration tests, but this doesn't play well with Samba's cross-compilation support, because Samba monkey-patches the actual fork+exec, which doesn't happen in a pre-forked process pool. This patch emulates the impact of WAF_NO_PREFORK env var when cross-compilation is enabled. The blueprint for the solution has been suggested by Thomas Nagy in https://bugzilla.samba.org/show_bug.cgi?id=13846#c7 (item #2) BUG: https://bugzilla.samba.org/show_bug.cgi?id=13846 Signed-off-by: Uri Simchoni --- buildtools/wafsamba/samba_cross.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py index 60ddf967237..6fca470f2b7 100644 --- a/buildtools/wafsamba/samba_cross.py +++ b/buildtools/wafsamba/samba_cross.py @@ -147,6 +147,8 @@ def SAMBA_CROSS_ARGS(conf, msg=None): if real_Popen is None: real_Popen = Utils.subprocess.Popen Utils.subprocess.Popen = cross_Popen + Utils.run_process = Utils.run_regular_process + Utils.get_process = Utils.alloc_process_pool = Utils.nada ret = [] -- 2.21.0 From bc74ca5dd9d2a7132f3039e371cb5ef474bd09c0 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Mon, 7 Oct 2019 00:37:41 +0300 Subject: [PATCH 4/4] wafsamba: pass environment to cross-execute tests This can come in handy for cross-execute scripts in general, and is particularly required by the samba-xc test for cross-answers / cross-execute, because Samba sets LD_LIBRARY_PATH during rpath checks, and the test program needs that in order to successfully run. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13846 Signed-off-by: Uri Simchoni --- buildtools/wafsamba/samba_cross.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py index 6fca470f2b7..0868a855a0d 100644 --- a/buildtools/wafsamba/samba_cross.py +++ b/buildtools/wafsamba/samba_cross.py @@ -120,7 +120,8 @@ class cross_Popen(Utils.subprocess.Popen): if use_answers: p = real_Popen(newargs, stdout=Utils.subprocess.PIPE, - stderr=Utils.subprocess.PIPE) + stderr=Utils.subprocess.PIPE, + env=kw.get('env', {})) ce_out, ce_err = p.communicate() ans = (p.returncode, samba_utils.get_string(ce_out)) add_answer(ca_file, msg, ans) -- 2.21.0