Skip to content

Commit 4f9aa81

Browse files
committed
Split the pthread library out of libc
1 parent b8c4812 commit 4f9aa81

File tree

8 files changed

+163
-117
lines changed

8 files changed

+163
-117
lines changed

embuilder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@
113113
'crtbegin',
114114
'libsanitizer_common_rt',
115115
'libubsan_rt',
116-
'libwasm_workers_stub-debug',
116+
'libwasm_workers-debug-stub',
117+
'libpthread-debug',
118+
'libpthread-debug-stub',
117119
'libfetch',
118120
'libfetch-mt',
119121
'libwasmfs',

test/code_size/embind_val_wasm.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"a.js": 6849,
55
"a.js.gz": 2947,
66
"a.wasm": 9565,
7-
"a.wasm.gz": 4904,
7+
"a.wasm.gz": 4903,
88
"total": 16966,
9-
"total_gz": 8231
9+
"total_gz": 8230
1010
}

test/other/codesize/test_codesize_minimal_pthreads.funcs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
$__emscripten_stdout_close
12
$__emscripten_stdout_seek
2-
$__errno_location
33
$__memcpy
44
$__memset
55
$__pthread_getspecific
@@ -67,6 +67,7 @@ $em_task_queue_free
6767
$em_task_queue_is_empty
6868
$emscripten_builtin_free
6969
$emscripten_builtin_malloc
70+
$emscripten_builtin_memalign
7071
$emscripten_current_thread_process_queued_calls
7172
$emscripten_futex_wait
7273
$emscripten_futex_wake
@@ -80,7 +81,6 @@ $init_mparams
8081
$lock
8182
$main
8283
$nodtor
83-
$pthread_attr_destroy
8484
$pthread_cond_signal
8585
$pthread_mutex_destroy
8686
$pthread_setspecific
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19501
1+
19971

test/test_core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4625,10 +4625,10 @@ def test_dylink_postsets_chunking(self):
46254625

46264626
@with_dylink_reversed
46274627
@parameterized({
4628-
'libcxx': ('libc,libc++,libmalloc,libc++abi',),
4628+
'libcxx': ('libc,libpthread,libc++,libmalloc,libc++abi',),
46294629
'all': ('1',),
4630-
'missing': ('libc,libmalloc,libc++abi', False, False, False),
4631-
'missing_assertions': ('libc,libmalloc,libc++abi', False, False, True),
4630+
'missing': ('libc,libpthread,libmalloc,libc++abi', False, False, False),
4631+
'missing_assertions': ('libc,libpthread,libmalloc,libc++abi', False, False, True),
46324632
})
46334633
def test_dylink_syslibs(self, syslibs, expect_pass=True, with_reversed=True, assertions=True):
46344634
# one module uses libcxx, need to force its inclusion when it isn't the main

test/test_other.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6007,9 +6007,9 @@ def test_bad_lookup(self):
60076007
# partial list, but ok since we grab them as needed
60086008
'parial': [{'EMCC_FORCE_STDLIBS': 'libc++'}, False],
60096009
# fail! not enough stdlibs
6010-
'partial_only': [{'EMCC_FORCE_STDLIBS': 'libc++,libc,libc++abi', 'EMCC_ONLY_FORCED_STDLIBS': '1'}, True],
6010+
'partial_only': [{'EMCC_FORCE_STDLIBS': 'libc++,libc,libpthread,libc++abi', 'EMCC_ONLY_FORCED_STDLIBS': '1'}, True],
60116011
# force all the needed stdlibs, so this works even though we ignore the input file
6012-
'full_only': [{'EMCC_FORCE_STDLIBS': 'libc,libc++abi,libc++,libmalloc', 'EMCC_ONLY_FORCED_STDLIBS': '1'}, False],
6012+
'full_only': [{'EMCC_FORCE_STDLIBS': 'libc,libpthread,libc++abi,libc++,libmalloc', 'EMCC_ONLY_FORCED_STDLIBS': '1'}, False],
60136013
})
60146014
def test_only_force_stdlibs(self, env, fail):
60156015
cmd = [EMXX, test_file('hello_libcxx.cpp')]
@@ -6040,7 +6040,7 @@ def test_only_force_stdlibs_2(self):
60406040
}
60416041
}
60426042
''')
6043-
with env_modify({'EMCC_FORCE_STDLIBS': 'libc,libc++abi,libc++,libmalloc', 'EMCC_ONLY_FORCED_STDLIBS': '1'}):
6043+
with env_modify({'EMCC_FORCE_STDLIBS': 'libc,libpthread,libc++abi,libc++,libmalloc', 'EMCC_ONLY_FORCED_STDLIBS': '1'}):
60446044
self.run_process([EMXX, 'src.cpp', '-sDISABLE_EXCEPTION_CATCHING=0'])
60456045
self.assertContained('Caught exception: std::exception', self.run_js('a.out.js'))
60466046

@@ -12286,10 +12286,10 @@ def test_nostdlib(self):
1228612286
self.assertContained(err, self.expect_fail([EMCC, test_file('unistd/close.c'), '-nodefaultlibs']))
1228712287

1228812288
# Build again but with explit system libraries
12289-
libs = ['-lc', '-lcompiler_rt']
12289+
libs = ['-lc', '-lpthread', '-lcompiler_rt']
1229012290
self.run_process([EMCC, test_file('unistd/close.c'), '-nostdlib'] + libs)
1229112291
self.run_process([EMCC, test_file('unistd/close.c'), '-nodefaultlibs'] + libs)
12292-
self.run_process([EMCC, test_file('unistd/close.c'), '-nolibc', '-lc'])
12292+
self.run_process([EMCC, test_file('unistd/close.c'), '-nolibc', '-lc', '-lpthread'])
1229312293
self.run_process([EMCC, test_file('unistd/close.c'), '-nostartfiles'])
1229412294

1229512295
def test_argument_match(self):
@@ -13183,12 +13183,13 @@ def test_offset_convertor_plus_wasm2js(self):
1318313183

1318413184
def test_standard_library_mapping(self):
1318513185
# Test the `-l` flags on the command line get mapped the correct libraries variant
13186-
libs = ['-lc', '-lbulkmemory', '-lcompiler_rt', '-lmalloc']
13186+
libs = ['-lc', '-lpthread', '-lbulkmemory', '-lcompiler_rt', '-lmalloc']
1318713187
err = self.run_process([EMCC, test_file('hello_world.c'), '-pthread', '-nodefaultlibs', '-v'] + libs, stderr=PIPE).stderr
1318813188

1318913189
# Check that the linker was run with `-mt` variants because `-pthread` was passed.
1319013190
self.assertContained(' -lc-mt-debug ', err)
1319113191
self.assertContained(' -ldlmalloc-mt ', err)
13192+
self.assertContained(' -lpthread-debug ', err)
1319213193
self.assertContained(' -lcompiler_rt-mt ', err)
1319313194

1319413195
def test_explicit_gl_linking(self):

tools/link.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2721,7 +2721,6 @@ def map_to_js_libs(library_name):
27212721
'dl': [],
27222722
'm': [],
27232723
'rt': [],
2724-
'pthread': [],
27252724
# This is the name of GNU's C++ standard library. We ignore it here
27262725
# for compatibility with GNU toolchains.
27272726
'stdc++': [],

0 commit comments

Comments
 (0)