diff --git a/bindings/python/wscript b/bindings/python/wscript index d33fdf381..6d39fe62d 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -445,6 +445,10 @@ def build(bld): pymod.target = 'ns3/_ns3' pymod.name = 'ns3module' pymod.uselib_local = "ns3" + if pymod.env['ENABLE_STATIC_NS3']: + pymod.env.append_value('LINKFLAGS', '-Wl,--whole-archive,-Bstatic') + pymod.env.append_value('LINKFLAGS', '-lns3') + pymod.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive') defines = list(pymod.env['CXXDEFINES']) defines.extend(['NS_DEPRECATED=', 'NS3_DEPRECATED_H']) diff --git a/src/wscript b/src/wscript index 94b64ead7..f1517e2a3 100644 --- a/src/wscript +++ b/src/wscript @@ -74,6 +74,14 @@ def create_ns3_module(bld, name, dependencies=()): module.module_deps = list(dependencies) if not module.env['ENABLE_STATIC_NS3']: module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS']) + elif module.env['CXX_NAME'] == 'gcc' and \ + os.uname()[4] == 'x86_64' and \ + module.env['ENABLE_PYTHON_BINDINGS']: + # enable that flag for static builds only on x86-64 platforms + # when gcc is present and only when we want python bindings + # (it's more efficient to not use this option if we can avoid it) + module.env.append_value('CXXFLAGS', '-mcmodel=large') + module.env.append_value('CXXDEFINES', "NS3_MODULE_COMPILATION") return module diff --git a/wscript b/wscript index 1be89ff62..fdcc6e1bf 100644 --- a/wscript +++ b/wscript @@ -291,7 +291,6 @@ def configure(conf): conf.find_program('valgrind', var='VALGRIND') if Options.options.enable_static and \ - not conf.env['ENABLE_PYTHON_BINDINGS'] and \ env['PLATFORM'].startswith('linux'): conf.env['ENABLE_STATIC_NS3'] = Options.options.enable_static