diff --git a/tests/test_other.py b/tests/test_other.py index 9195ff1e9782..874f16dd1bd7 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -1770,8 +1770,8 @@ def test_dylink_pthread_static_data(self): emcc_args=[ '-pthread', '-Wno-experimental', '-sPROXY_TO_PTHREAD', - '-sEXIT_RUNTIME=1', - '-sMAIN_MODULE=1', + '-sEXIT_RUNTIME', + '-sMAIN_MODULE=2', 'side.wasm', ]) @@ -1795,6 +1795,55 @@ def test_dylink_pthread_bigint_em_js(self): self.emcc_args += ['-Wno-experimental'] self.do_runf(test_file('core/test_em_js.cpp')) + @node_pthreads + def test_dylink_pthread_comdat(self): + # Test that the comdat info for `Foo`, which is defined in the side module, + # is visible to the main module. + create_file('foo.h', r''' + struct Foo { + // Making this method virtual causes the comdat group for the + // class to only be defined in the side module. + virtual void method() const; + }; + ''') + create_file('main.cpp', r''' + #include "foo.h" + #include + #include + + int main() { + _emscripten_outf("main: Foo typeid: %s", typeid(Foo).name()); + + Foo().method(); + return 0; + } + ''') + create_file('side.cpp', r''' + #include "foo.h" + #include + #include + + void Foo::method() const { + _emscripten_outf("side: Foo typeid: %s", typeid(Foo).name()); + } + ''') + self.run_process([ + EMCC, + '-o', 'libside.wasm', + 'side.cpp', + '-pthread', '-Wno-experimental', + '-sSIDE_MODULE=1']) + self.do_runf( + 'main.cpp', + 'main: Foo typeid: 3Foo\nside: Foo typeid: 3Foo\n', + emcc_args=[ + '-pthread', '-Wno-experimental', + '-sPROXY_TO_PTHREAD', + '-sEXIT_RUNTIME', + '-sMAIN_MODULE=2', + 'libside.wasm', + ]) + def test_dylink_no_autoload(self): create_file('main.c', r''' #include