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.
"""
This commit is contained in:
13
wscript
13
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)
|
||||
|
||||
Reference in New Issue
Block a user