@@ -1771,8 +1771,8 @@ def test_dylink_pthread_static_data(self):
1771
1771
emcc_args = [
1772
1772
'-pthread' , '-Wno-experimental' ,
1773
1773
'-sPROXY_TO_PTHREAD' ,
1774
- '-sEXIT_RUNTIME=1 ' ,
1775
- '-sMAIN_MODULE=1 ' ,
1774
+ '-sEXIT_RUNTIME' ,
1775
+ '-sMAIN_MODULE=2 ' ,
1776
1776
'side.wasm' ,
1777
1777
])
1778
1778
@@ -1796,6 +1796,55 @@ def test_dylink_pthread_bigint_em_js(self):
1796
1796
self .emcc_args += ['-Wno-experimental' ]
1797
1797
self .do_runf (test_file ('core/test_em_js.cpp' ))
1798
1798
1799
+ @node_pthreads
1800
+ def test_dylink_pthread_comdat (self ):
1801
+ # Test that the comdat info for `Foo`, which is defined in the side module,
1802
+ # is visible to the main module.
1803
+ create_file ('foo.h' , r'''
1804
+ struct Foo {
1805
+ // Making this method virtual causes the comdat group for the
1806
+ // class to only be defined in the side module.
1807
+ virtual void method() const;
1808
+ };
1809
+ ''' )
1810
+ create_file ('main.cpp' , r'''
1811
+ #include "foo.h"
1812
+ #include <typeinfo>
1813
+ #include <emscripten/console.h>
1814
+
1815
+ int main() {
1816
+ _emscripten_outf("main: Foo typeid: %s", typeid(Foo).name());
1817
+
1818
+ Foo().method();
1819
+ return 0;
1820
+ }
1821
+ ''' )
1822
+ create_file ('side.cpp' , r'''
1823
+ #include "foo.h"
1824
+ #include <typeinfo>
1825
+ #include <emscripten/console.h>
1826
+
1827
+ void Foo::method() const {
1828
+ _emscripten_outf("side: Foo typeid: %s", typeid(Foo).name());
1829
+ }
1830
+ ''' )
1831
+ self .run_process ([
1832
+ EMCC ,
1833
+ '-o' , 'libside.wasm' ,
1834
+ 'side.cpp' ,
1835
+ '-pthread' , '-Wno-experimental' ,
1836
+ '-sSIDE_MODULE=1' ])
1837
+ self .do_runf (
1838
+ 'main.cpp' ,
1839
+ 'main: Foo typeid: 3Foo\n side: Foo typeid: 3Foo\n ' ,
1840
+ emcc_args = [
1841
+ '-pthread' , '-Wno-experimental' ,
1842
+ '-sPROXY_TO_PTHREAD' ,
1843
+ '-sEXIT_RUNTIME' ,
1844
+ '-sMAIN_MODULE=2' ,
1845
+ 'libside.wasm' ,
1846
+ ])
1847
+
1799
1848
def test_dylink_no_autoload (self ):
1800
1849
create_file ('main.c' , r'''
1801
1850
#include <stdio.h>
0 commit comments