diff --git a/examples/cross_module_inheritance/test_cross_module_inheritance.py b/examples/cross_module_inheritance/test_cross_module_inheritance.py new file mode 100644 index 0000000..cabc97e --- /dev/null +++ b/examples/cross_module_inheritance/test_cross_module_inheritance.py @@ -0,0 +1,9 @@ +# This bit of magic is required for GNU compilers for now for resolving symbols +# across libraries. See many rants online regarding this issue... +import sys, ctypes +sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL) + +import A, B + +b = B.Derived() +print isinstance(b, A.Base) diff --git a/examples/cross_module_inheritance/wscript b/examples/cross_module_inheritance/wscript index 4fcdd2b..985813c 100644 --- a/examples/cross_module_inheritance/wscript +++ b/examples/cross_module_inheritance/wscript @@ -2,33 +2,26 @@ def build(bld): - for src, tgt in (('Agen.py', 'Amodule.cc'), - ('Bgen.py', 'Bmodule.cc')): - gen = bld.new_task_gen( - features='command', - source=src, - target=tgt, - command='${PYTHON} ${SRC[0]} ${TGT[0]}') + for src, tgt in (("Agen.py", "Amodule.cc"), + ("Bgen.py", "Bmodule.cc")): + gen = bld.new_task_gen(features="command", + source=src, + target=tgt, + command="${PYTHON} ${SRC[0]} ${TGT[0]}") - if bld.env['CXX']: - # bld.shlib(source = 'Amodule.cc', - # target = 'A', - # features = 'pyext', - # use = ['PYTHON']) - # bld.shlib(source = 'Bmodule.cc', - # target = 'B', - # features = 'pyext', - # use = ['PYTHON', 'A']) + if bld.env["CXX"]: + obj = bld.new_task_gen(features="cxx cxxshlib pyext", + source = "Amodule.cc", + target = "A", + install_path = None, # do not install + includes = ".", + cxxflags = "-fvisibility=default", # Hack for gcc only -- need to clean up + ) - obj = bld.new_task_gen(features=['cxx', 'cxxshlib', 'pyext']) - obj.source = ['Amodule.cc'] - obj.target = 'A' - obj.install_path = None # do not install - obj.includes = '.' - - obj = bld.new_task_gen(features=['cxx', 'cxxshlib', 'pyext']) - obj.source = ['Bmodule.cc'] - obj.target = 'B' - obj.install_path = None # do not install - obj.includes = '.' - obj.links = ['A'] + obj = bld.new_task_gen(features="cxx cxxshlib pyext", + source = "Bmodule.cc", + target = "B", + install_path = None, # do not install + includes = ".", + cxxflags = "-fvisibility=default", # Hack for gcc only -- need to clean up + ) diff --git a/wscript b/wscript index 30647ed..fca9cdf 100644 --- a/wscript +++ b/wscript @@ -286,11 +286,14 @@ def configure(conf): else: conf.env['ENABLE_PYGCCXML'] = True - # -fvisibility=hidden optimization - if (conf.env['CXX_NAME'] == 'gcc' and [int(x) for x in conf.env['CC_VERSION']] >= [4,0,0] - and conf.check_compilation_flag('-fvisibility=hidden')): - conf.env.append_value('CXXFLAGS_PYEXT', '-fvisibility=hidden') - conf.env.append_value('CCFLAGS_PYEXT', '-fvisibility=hidden') + # This breaks the ability to use cross-module dependencies (such as shown in + # examples/cross_module_inheritance), so I'm turning off the hidden flag for + # now. I welcome a better solution! + # # -fvisibility=hidden optimization + # if (conf.env['CXX_NAME'] == 'gcc' and [int(x) for x in conf.env['CC_VERSION']] >= [4,0,0] + # and conf.check_compilation_flag('-fvisibility=hidden')): + # conf.env.append_value('CXXFLAGS_PYEXT', '-fvisibility=hidden') + # conf.env.append_value('CCFLAGS_PYEXT', '-fvisibility=hidden') # Add include path for our stdint.h replacement, if needed (pstdint.h) if not conf.check_nonfatal(header_name='stdint.h'):