Skip to content

Commit

Permalink
Add pthread + dylink test for side-module-defined C++ comat info. NFC
Browse files Browse the repository at this point in the history
This test will only pass once that corresponding llvm fix lands:
https://reviews.llvm.org/D127333

See #17150
  • Loading branch information
sbc100 committed Jun 8, 2022
1 parent a36ffd3 commit 2fcb8d9
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
])

Expand All @@ -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 <typeinfo>
#include <emscripten/console.h>
int main() {
_emscripten_outf("main: Foo typeid: %s", typeid(Foo).name());
Foo().method();
return 0;
}
''')
create_file('side.cpp', r'''
#include "foo.h"
#include <typeinfo>
#include <emscripten/console.h>
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 <stdio.h>
Expand Down

0 comments on commit 2fcb8d9

Please sign in to comment.