From 990960bbca7f319f80fe10089048ed246c89f9dd Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Mon, 18 May 2009 11:06:26 +0100 Subject: [PATCH] Add -Wl,--soname=libns3.so to link flags to allow dlopen hacks Mathieu's explanation: """ In python, I want to load the ns3 python bindings without having to install libns3.so in /usr and without having to configure LD_LIBRARY_PATH. So, I need to dlopen (RTLD_GLOBAL) libns3.so before doing imp.find_module ('ns3') to ensure that python finds the libns3.so library. To do the dlopen, I need to give a full path to libns3.so but, if you do this without a soname, the dynamic loader does not know about libns3.so: it knows only about /foo/bar/libns3.so. """ --- wscript | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wscript b/wscript index 8a4cd5043..508baa784 100644 --- a/wscript +++ b/wscript @@ -255,13 +255,18 @@ def configure(conf): env.append_value("LINKFLAGS", "-Wl,--enable-runtime-pseudo-reloc") elif sys.platform == 'cygwin': env.append_value("LINKFLAGS", "-Wl,--enable-auto-import") + cxx, = env['CXX'] + p = subprocess.Popen([cxx, '-print-file-name=libstdc++.so'], stdout=subprocess.PIPE) libstdcxx_location = os.path.dirname(p.stdout.read().strip()) p.wait() if libstdcxx_location: conf.env.append_value('NS3_MODULE_PATH', libstdcxx_location) + if conf.check_compilation_flag('-Wl,--soname=foo'): + env['WL_SONAME_SUPPORTED'] = True + conf.sub_config('src') conf.sub_config('utils') conf.sub_config('bindings/python') @@ -480,11 +485,15 @@ def build(bld): ## Create a single ns3 library containing all enabled modules if env['ENABLE_STATIC_NS3']: lib = bld.new_task_gen('cxx', 'staticlib') + lib.name = 'ns3' + lib.target = 'ns3' else: lib = bld.new_task_gen('cxx', 'shlib') + lib.name = 'ns3' + lib.target = 'ns3' + if lib.env['CXX_NAME'] == 'gcc' and env['WL_SONAME_SUPPORTED']: + lib.env.append_value('LINKFLAGS', '-Wl,--soname=%s' % ccroot.get_target_name(lib)) - lib.name = 'ns3' - lib.target = 'ns3' if env['NS3_ENABLED_MODULES']: lib.add_objects = list(modules) env['NS3_ENABLED_MODULES'] = list(modules)