Skip to content

Commit

Permalink
Improve test_dylink_tls. NFC
Browse files Browse the repository at this point in the history
Make TLS variables static which fixes a linker failure when
building with `-g` (for example this test currently fails under wasm2g
and wasm0g congigurations).

Also, add two different TLS variables in each of the modules which
helps with debugging since only one of them will be at TLS offset 0.
  • Loading branch information
sbc100 committed Aug 31, 2021
1 parent 872b959 commit bda79ec
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4594,29 +4594,53 @@ def test_dylink_tls(self):
# once we figure out how to do that.
create_file('main.c', r'''
#include <stdio.h>
#include <threads.h>
_Thread_local int foo = 10;
static thread_local int foo = 10;
static thread_local int bar = 11;
void sidey();
int get_foo() {
return foo;
}
int get_bar() {
return bar;
}
int main(int argc, char const *argv[]) {
printf("main TLS: %d\n", foo);
printf("main TLS: %d %d\n", get_foo(), get_bar());
sidey();
return 0;
}
''')
create_file('side.c', r'''
#include <stdio.h>
#include <threads.h>
static thread_local int baz = 42;
static thread_local int wiz = 43;
_Thread_local int bar = 11;
int get_baz() {
return baz;
}
int get_wiz() {
return wiz;
}
void sidey() {
printf("side TLS: %d\n", bar);
printf("side TLS: %d %d\n", get_baz(), get_wiz());
}
''')
self.emcc_args.append('-Wno-experimental')
expected = '''\
main TLS: 10 11
side TLS: 42 43
'''
self.dylink_testf('main.c', 'side.c',
expected='main TLS: 10\nside TLS: 11\n',
expected=expected,
need_reverse=False)

def test_random(self):
Expand Down

0 comments on commit bda79ec

Please sign in to comment.