build: Add duplicate symbol checking as part of make test
authorAndrew Bartlett <abartlet@samba.org>
Thu, 8 Sep 2011 09:07:47 +0000 (19:07 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 8 Sep 2011 11:37:40 +0000 (13:37 +0200)
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 <abartlet@samba.org>
Autobuild-Date: Thu Sep  8 13:37:40 CEST 2011 on sn-devel-104

Makefile
buildtools/wafsamba/symbols.py
buildtools/wafsamba/wscript
wscript
wscript_build

index 3b40c73..0552052 100644 (file)
--- 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
index dfab71c..8775735 100644 (file)
@@ -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
index ecc2ae5..1a7f3eb 100755 (executable)
@@ -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 0b5e68f..548f8ec 100755 (executable)
--- 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')
index 9e2737d..1b6fb31 100644 (file)
@@ -123,3 +123,4 @@ bld.RECURSE('source3')
 bld.RECURSE('testsuite/headers')
 
 bld.SYMBOL_CHECK()
+bld.DUP_SYMBOL_CHECK()