From a09d80dfd18258f0e56dbd67323024628bf01a9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20B=C3=BChler?= Date: Sun, 18 Dec 2016 21:19:10 +0100 Subject: [PATCH] fix SCons fullstatic build with glibc pthreads [with some modifications by gstrauss] --- src/SConscript | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SConscript b/src/SConscript index 0fd569f6..9195c4d6 100644 --- a/src/SConscript +++ b/src/SConscript @@ -223,11 +223,19 @@ for libs in staticlib: fullstaticlib += [ aword ] f.close +## glibc pthread needs to be linked completely (especially nptl-init.o) +## or not at all, or else pthread structures may not be initialized correctly +import platform +fullstatic_libs = GatherLibs(env, fullstaticlib) +fullstatic_linkflags = [staticenv['LINKFLAGS'], '-static'] +if (('pthread' in fullstatic_libs) or ('pcre' in fullstatic_libs)) and (platform.system() == 'Linux'): + fullstatic_linkflags += ['-Wl,--whole-archive','-lpthread','-Wl,--no-whole-archive'] + ## includes all modules, linked statically fullstaticbin = staticenv.Program('../fullstatic/build/lighttpd', staticobj, - LIBS = GatherLibs(env, fullstaticlib), - LINKFLAGS= [staticenv['LINKFLAGS'], '-static'] + LIBS = fullstatic_libs, + LINKFLAGS= fullstatic_linkflags ) Alias('static', staticbin) -- 2.11.4.GIT