Skip to content

Commit bda79ec

Browse files
committed
Improve test_dylink_tls. NFC
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.
1 parent 872b959 commit bda79ec

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

tests/test_core.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,29 +4594,53 @@ def test_dylink_tls(self):
45944594
# once we figure out how to do that.
45954595
create_file('main.c', r'''
45964596
#include <stdio.h>
4597+
#include <threads.h>
45974598
4598-
_Thread_local int foo = 10;
4599+
static thread_local int foo = 10;
4600+
static thread_local int bar = 11;
45994601
46004602
void sidey();
46014603
4604+
int get_foo() {
4605+
return foo;
4606+
}
4607+
4608+
int get_bar() {
4609+
return bar;
4610+
}
4611+
46024612
int main(int argc, char const *argv[]) {
4603-
printf("main TLS: %d\n", foo);
4613+
printf("main TLS: %d %d\n", get_foo(), get_bar());
46044614
sidey();
46054615
return 0;
46064616
}
46074617
''')
46084618
create_file('side.c', r'''
46094619
#include <stdio.h>
4620+
#include <threads.h>
4621+
4622+
static thread_local int baz = 42;
4623+
static thread_local int wiz = 43;
46104624
4611-
_Thread_local int bar = 11;
4625+
int get_baz() {
4626+
return baz;
4627+
}
4628+
4629+
int get_wiz() {
4630+
return wiz;
4631+
}
46124632
46134633
void sidey() {
4614-
printf("side TLS: %d\n", bar);
4634+
printf("side TLS: %d %d\n", get_baz(), get_wiz());
46154635
}
46164636
''')
46174637
self.emcc_args.append('-Wno-experimental')
4638+
expected = '''\
4639+
main TLS: 10 11
4640+
side TLS: 42 43
4641+
'''
46184642
self.dylink_testf('main.c', 'side.c',
4619-
expected='main TLS: 10\nside TLS: 11\n',
4643+
expected=expected,
46204644
need_reverse=False)
46214645

46224646
def test_random(self):

0 commit comments

Comments
 (0)