Skip to content

Commit 76f29df

Browse files
author
Morten Sørvig
committed
Make embind work with -fvisibility=hidden
Export emscripten::val and emscripten::memory_view in order to prevent embind errors: BindingError: _emval_take_value has unknown type N10emscripten11memory_viewIhEE Embind generates a numerical type id from the address of the std::type_info object resulting from evaluating a typeid expressiion (e.g. 'void *id = &typeid(T)'). However, C++ does not guarantee that this address is identical for all evaluations of the typeid expression. In practice it is when using static linking, but not when using dynamic linking when the libraries are built with the '-fvisibility=hidden' compiler option. The non-identical id's then cause embind to decide that types have not been registered when used from a library, since they have been registered with a different id by the main wasm module. Exporting the types in question makes typeid addresses identical again, and fixes/works around the issue.
1 parent e053f23 commit 76f29df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/test_other.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,17 @@ def decorated(self, *args, **kwargs):
220220
return decorated
221221

222222

223+
def requires_dylink(func):
224+
assert callable(func)
225+
226+
@wraps(func)
227+
def decorated(self, *args, **kwargs):
228+
self.check_dylink()
229+
return func(self, *args, **kwargs)
230+
231+
return decorated
232+
233+
223234
def llvm_nm(file):
224235
output = shared.run_process([LLVM_NM, file], stdout=PIPE).stdout
225236

0 commit comments

Comments
 (0)