From 30e11d55b526632f93fb60ff944c771f452ab5b4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 8 Sep 2011 19:07:47 +1000 Subject: build: Add duplicate symbol checking as part of make test This ensures we do not get duplicate symbols again, when run as ./configure.developer on non-build farm machines. Andrew Bartlett Autobuild-User: Andrew Bartlett Autobuild-Date: Thu Sep 8 13:37:40 CEST 2011 on sn-devel-104 --- Makefile | 8 ++++---- buildtools/wafsamba/symbols.py | 28 ++++++++++++++++++++++------ buildtools/wafsamba/wscript | 4 ++++ wscript | 1 + wscript_build | 1 + 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 3b40c73d95..0552052332 100644 --- a/Makefile +++ b/Makefile @@ -13,20 +13,20 @@ uninstall: $(WAF) uninstall test: - $(WAF) test $(TEST_OPTIONS) + $(WAF) test --dup-symbol-check $(TEST_OPTIONS) help: @echo NOTE: to run extended waf options use $(WAF_BINARY) or modify your PATH $(WAF) --help subunit-test: - $(WAF) test --filtered-subunit $(TEST_OPTIONS) + $(WAF) test --dup-symbol-check --filtered-subunit $(TEST_OPTIONS) testenv: - $(WAF) test --testenv $(TEST_OPTIONS) + $(WAF) test --dup-symbol-check --testenv $(TEST_OPTIONS) quicktest: - $(WAF) test --quick $(TEST_OPTIONS) + $(WAF) test --dup-symbol-check --quick $(TEST_OPTIONS) dist: touch .tmplock diff --git a/buildtools/wafsamba/symbols.py b/buildtools/wafsamba/symbols.py index dfab71c2c4..87757357af 100644 --- a/buildtools/wafsamba/symbols.py +++ b/buildtools/wafsamba/symbols.py @@ -567,7 +567,7 @@ def symbols_whyneeded(task): Logs.info("target '%s' uses symbols %s from '%s'" % (target, overlap, subsystem)) -def report_duplicate(bld, binname, sym, libs): +def report_duplicate(bld, binname, sym, libs, fail_on_error): '''report duplicated symbols''' if sym in ['_init', '_fini']: return @@ -577,10 +577,13 @@ def report_duplicate(bld, binname, sym, libs): libnames.append(bld.env.library_dict[lib]) else: libnames.append(lib) - print("%s: Symbol %s linked in multiple libraries %s" % (binname, sym, libnames)) + if fail_on_error: + raise Utils.WafError("%s: Symbol %s linked in multiple libraries %s" % (binname, sym, libnames)) + else: + print("%s: Symbol %s linked in multiple libraries %s" % (binname, sym, libnames)) -def symbols_dupcheck_binary(bld, binname): +def symbols_dupcheck_binary(bld, binname, fail_on_error): '''check for duplicated symbols in one binary''' libs = get_libs_recursive(bld, binname, set()) @@ -596,10 +599,10 @@ def symbols_dupcheck_binary(bld, binname): if len(symmap[sym]) > 1: for libpath in symmap[sym]: if libpath in bld.env.library_dict: - report_duplicate(bld, binname, sym, symmap[sym]) + report_duplicate(bld, binname, sym, symmap[sym], fail_on_error) break -def symbols_dupcheck(task): +def symbols_dupcheck(task, fail_on_error=False): '''check for symbols defined in two different subsystems''' bld = task.env.bld tgt_list = get_tgt_list(bld) @@ -610,8 +613,12 @@ def symbols_dupcheck(task): for t in tgt_list: if t.samba_type == 'BINARY': binname = os_path_relpath(t.link_task.outputs[0].abspath(bld.env), os.getcwd()) - symbols_dupcheck_binary(bld, binname) + symbols_dupcheck_binary(bld, binname, fail_on_error) + +def symbols_dupcheck_fatal(task): + '''check for symbols defined in two different subsystems (and fail if duplicates are found)''' + symbols_dupcheck(task, fail_on_error=True) def SYMBOL_CHECK(bld): @@ -636,3 +643,12 @@ def SYMBOL_CHECK(bld): Build.BuildContext.SYMBOL_CHECK = SYMBOL_CHECK + +def DUP_SYMBOL_CHECK(bld): + if Options.options.DUP_SYMBOLCHECK and bld.env.DEVELOPER and not bld.env.BUILD_FARM: + '''check for duplicate symbols''' + bld.SET_BUILD_GROUP('syslibcheck') + task = bld(rule=symbols_dupcheck_fatal, always=True, name='symbol duplicate checking') + task.env.bld = bld + +Build.BuildContext.DUP_SYMBOL_CHECK = DUP_SYMBOL_CHECK diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index ecc2ae51f6..1a7f3eb699 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -121,6 +121,10 @@ def set_options(opt): help=("check symbols in object files against project rules"), action='store_true', dest='SYMBOLCHECK', default=False) + gr.add_option('--dup-symbol-check', + help=("check for duplicate symbols in object files and system libs (must be configured with --enable-developer)"), + action='store_true', dest='DUP_SYMBOLCHECK', default=False) + gr.add_option('--why-needed', help=("TARGET:DEPENDENCY check why TARGET needs DEPENDENCY"), action='store', type='str', dest='WHYNEEDED', default=None) diff --git a/wscript b/wscript index 0b5e68f136..548f8ec3ef 100755 --- a/wscript +++ b/wscript @@ -52,6 +52,7 @@ def configure(conf): if Options.options.developer: conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD') + conf.env.DEVELOPER = True # this enables smbtorture.static for s3 in the build farm conf.env.BUILD_FARM = Options.options.BUILD_FARM or os.environ.get('RUN_FROM_BUILD_FARM') diff --git a/wscript_build b/wscript_build index 9e2737d5fb..1b6fb31e41 100644 --- a/wscript_build +++ b/wscript_build @@ -123,3 +123,4 @@ bld.RECURSE('source3') bld.RECURSE('testsuite/headers') bld.SYMBOL_CHECK() +bld.DUP_SYMBOL_CHECK() -- cgit