From 4e5b1901a199813bbe7ee1028422ac5c62d3677d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 30 Sep 2014 04:40:24 +0200 Subject: [PATCH] Solution for #948 : special treatment for the test-suite Note: this changeset globally sets the linkerflag --as-needed but adds a single, hard coded exception to this rule for taget/test-suite --- admin/scons/Setup.py | 1 + tests/SConscript | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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