Change link order for static links

This commit is contained in:
seelabs
2015-12-04 10:28:15 -05:00
committed by Nik Bougalis
parent f6f4452231
commit e19e6c6b0a

View File

@@ -393,16 +393,15 @@ def config_base(env):
env.Append(CPPPATH=[os.path.join(profile_jemalloc, 'include')]) env.Append(CPPPATH=[os.path.join(profile_jemalloc, 'include')])
env.Append(LINKFLAGS=['-Wl,-rpath,' + os.path.join(profile_jemalloc, 'lib')]) env.Append(LINKFLAGS=['-Wl,-rpath,' + os.path.join(profile_jemalloc, 'lib')])
def add_static_libs(env, libs): def add_static_libs(env, static_libs, dyn_libs=None):
if not 'HASSTATICLIBS' in env: if not 'HASSTATICLIBS' in env:
env['HASSTATICLIBS'] = True env['HASSTATICLIBS'] = True
env['STATICLIBS'] = '' env.Replace(LINKCOM=env['LINKCOM'] + " -Wl,-Bstatic $STATICLIBS -Wl,-Bdynamic $DYNAMICLIBS")
env.Replace(LINKCOM=env['LINKCOM'] + " -Wl,-Bstatic $STATICLIBS") for k,l in [('STATICLIBS', static_libs or []), ('DYNAMICLIBS', dyn_libs or [])]:
c = env['STATICLIBS'] c = env.get(k, '')
if c == None: c = '' for f in l:
for f in libs: c += ' -l' + f
c += ' -l' + f env[k] = c
env['STATICLIBS'] = c
def get_libs(lib, static): def get_libs(lib, static):
'''Returns a tuple of lists. The first element is the static libs, '''Returns a tuple of lists. The first element is the static libs,
@@ -453,9 +452,9 @@ def config_env(toolchain, variant, env):
link_static = should_link_static() link_static = should_link_static()
for l in ['openssl', 'protobuf']: for l in ['openssl', 'protobuf']:
static, dynamic = get_libs(l, link_static) static, dynamic = get_libs(l, link_static)
if static: if link_static:
add_static_libs(env, static) add_static_libs(env, static, dynamic)
if dynamic: else:
env.Append(LIBS=dynamic) env.Append(LIBS=dynamic)
env.ParseConfig('pkg-config --static --cflags ' + l) env.ParseConfig('pkg-config --static --cflags ' + l)