diff --git a/admin/scons/Setup.py b/admin/scons/Setup.py index 96c691643..b8bc1ab96 100644 --- a/admin/scons/Setup.py +++ b/admin/scons/Setup.py @@ -78,6 +78,7 @@ def defineBuildEnvironment(): , CFLAGS='-std=gnu99' ) env.Append(LINKFLAGS='-Wl,--no-undefined') # require every dependency is given on link, in the right order + env.Append(LINKFLAGS='-Wl,--as-needed') # by default only link against dependencies actually needed to resolve symbols handleVerboseMessages(env) handleNoBugSwitches(env) diff --git a/tests/SConscript b/tests/SConscript index f8c0aa337..1139b64d2 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -62,6 +62,13 @@ def testCases(env,dir): +# Specific linker treatment for the testsuite: +# force explicit linking against all dependencies to ensure auto-registration of +# any test-class on startup, even if no code dependency is visible to the linker +envSuite = env.Clone() +envSuite.Append(LINKFLAGS='-Wl,--no-as-needed') + + # have to treat some subdirs separately. specialDirs = ['plugin','tool','include'] testSrcDirs = globRootdirs('*') @@ -69,7 +76,7 @@ testSrcDirs = globRootdirs('*') testcases = [testCases(env, dir) for dir in testSrcDirs if not dir in specialDirs] testLibs = sharedTestLibs.values() -testrunner = env.Program("test-suite", ["testrunner.cpp"]+testLibs+core_lib) +testrunner = envSuite.Program("test-suite", ["testrunner.cpp"]+testLibs+core_lib) testsuite = ( testcases