From 57865709e1d7ce9816d34fd52ceca61e7bfd5640 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 25 Aug 2020 16:57:48 -0700 Subject: [PATCH 01/22] Make asm.js threading globals thread-safe --- system/lib/compiler-rt/extras.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/lib/compiler-rt/extras.c b/system/lib/compiler-rt/extras.c index 041869ca68cf9..568410c3ce306 100644 --- a/system/lib/compiler-rt/extras.c +++ b/system/lib/compiler-rt/extras.c @@ -11,8 +11,8 @@ /* References to these globals are generated in the llvm backend so they * cannot be static */ -int __THREW__ = 0; -int __threwValue = 0; +int _Thread_local __THREW__ = 0; +int _Thread_local __threwValue = 0; void setThrew(int threw, int value) { if (__THREW__ == 0) { From 0faaddd7e5e9571702828bb64294e83a301f1cf0 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 25 Aug 2020 18:34:17 -0700 Subject: [PATCH 02/22] make compiler-rt an MT library? --- tools/system_libs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/system_libs.py b/tools/system_libs.py index 396d5cb0fbfa8..12fe4af7ec2e3 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -633,7 +633,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(Library): +class libcompiler_rt(Library, MTLibrary): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 From 0ae338fa4210d5df385f41df704448de2558d442 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 26 Aug 2020 09:50:16 -0700 Subject: [PATCH 03/22] fix --- system/lib/compiler-rt/extras.c | 22 ---------------------- system/lib/libc/extras.c | 12 ++++++++++++ tools/system_libs.py | 3 +-- 3 files changed, 13 insertions(+), 24 deletions(-) delete mode 100644 system/lib/compiler-rt/extras.c diff --git a/system/lib/compiler-rt/extras.c b/system/lib/compiler-rt/extras.c deleted file mode 100644 index 568410c3ce306..0000000000000 --- a/system/lib/compiler-rt/extras.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2018 The Emscripten Authors. All rights reserved. - * Emscripten is available under two separate licenses, the MIT license and the - * University of Illinois/NCSA Open Source License. Both these licenses can be - * found in the LICENSE file. - * - * Support functions for emscripten setjmp/longjmp and exception handling - * support. - * See: https://llvm.org/doxygen/WebAssemblyLowerEmscriptenEHSjLj_8cpp.html - */ - -/* References to these globals are generated in the llvm backend so they - * cannot be static */ -int _Thread_local __THREW__ = 0; -int _Thread_local __threwValue = 0; - -void setThrew(int threw, int value) { - if (__THREW__ == 0) { - __THREW__ = threw; - __threwValue = value; - } -} diff --git a/system/lib/libc/extras.c b/system/lib/libc/extras.c index 148cbcc7bc601..195067bb8c61a 100644 --- a/system/lib/libc/extras.c +++ b/system/lib/libc/extras.c @@ -31,3 +31,15 @@ long* _get_timezone() { void __lock(void* ptr) {} void __unlock(void* ptr) {} +/* References to these longjmp- and exceptions-supporting things are generated + in the llvm backend so they cannot be static */ + +int _Thread_local __THREW__ = 0; +int _Thread_local __threwValue = 0; + +void setThrew(int threw, int value) { + if (__THREW__ == 0) { + __THREW__ = threw; + __threwValue = value; + } +} diff --git a/tools/system_libs.py b/tools/system_libs.py index 12fe4af7ec2e3..1c110f99f9463 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -633,7 +633,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(Library, MTLibrary): +class libcompiler_rt(Library): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 @@ -642,7 +642,6 @@ class libcompiler_rt(Library, MTLibrary): cflags = ['-O2', '-fno-builtin'] src_dir = ['system', 'lib', 'compiler-rt', 'lib', 'builtins'] src_files = glob_in_path(src_dir, '*.c') - src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'extras.c')) src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'stack_ops.s')) src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'emscripten_setjmp.c')) From fccf48cb715dd07af51d44ab31c8ca5dc22db237 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Wed, 26 Aug 2020 15:59:31 -0700 Subject: [PATCH 04/22] feedback: refactor into a side file --- .../lib/libc/emscripten_exception_builtins.c | 26 +++++++++++++++++++ system/lib/libc/extras.c | 13 ---------- tools/system_libs.py | 2 +- 3 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 system/lib/libc/emscripten_exception_builtins.c diff --git a/system/lib/libc/emscripten_exception_builtins.c b/system/lib/libc/emscripten_exception_builtins.c new file mode 100644 index 0000000000000..6573d391ea7a5 --- /dev/null +++ b/system/lib/libc/emscripten_exception_builtins.c @@ -0,0 +1,26 @@ +/* + * Copyright 2018 The Emscripten Authors. All rights reserved. + * Emscripten is available under two separate licenses, the MIT license and the + * University of Illinois/NCSA Open Source License. Both these licenses can be + * found in the LICENSE file. + */ + +/* + References to these longjmp- and exceptions-supporting things are generated + in the llvm backend. + + Note that these might make more sense in compiler-rt, but they need to be + built with multithreading support when relevant (to avoid races between + threads that throw at the same time etc.), and compiler-rt is not built + that way atm. +*/ + +int _Thread_local __THREW__ = 0; +int _Thread_local __threwValue = 0; + +void setThrew(int threw, int value) { + if (__THREW__ == 0) { + __THREW__ = threw; + __threwValue = value; + } +} diff --git a/system/lib/libc/extras.c b/system/lib/libc/extras.c index 195067bb8c61a..f7bd7ff8ea0c1 100644 --- a/system/lib/libc/extras.c +++ b/system/lib/libc/extras.c @@ -30,16 +30,3 @@ long* _get_timezone() { void __lock(void* ptr) {} void __unlock(void* ptr) {} - -/* References to these longjmp- and exceptions-supporting things are generated - in the llvm backend so they cannot be static */ - -int _Thread_local __THREW__ = 0; -int _Thread_local __threwValue = 0; - -void setThrew(int threw, int value) { - if (__THREW__ == 0) { - __THREW__ = threw; - __threwValue = value; - } -} diff --git a/tools/system_libs.py b/tools/system_libs.py index c59888fc2da4e..4dfc77331b52d 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -742,7 +742,7 @@ def get_files(self): libc_files += files_in_path( path_components=['system', 'lib', 'libc'], - filenames=['extras.c', 'wasi-helpers.c']) + filenames=['emscripten_exception_builtins.c', 'extras.c', 'wasi-helpers.c']) return libc_files From a9741ea5e36c34f8405264e699d4569d9a20f5f3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 26 Aug 2020 16:43:34 -0700 Subject: [PATCH 05/22] add a test --- tests/core/pthread/exceptions.cpp | 78 +++++++++++++++++++++++++++++++ tests/core/pthread/exceptions.out | 1 + tests/test_core.py | 6 +++ 3 files changed, 85 insertions(+) create mode 100644 tests/core/pthread/exceptions.cpp create mode 100644 tests/core/pthread/exceptions.out diff --git a/tests/core/pthread/exceptions.cpp b/tests/core/pthread/exceptions.cpp new file mode 100644 index 0000000000000..60e2cfe15e767 --- /dev/null +++ b/tests/core/pthread/exceptions.cpp @@ -0,0 +1,78 @@ +// Copyright 2019 The Emscripten Authors. All rights reserved. +// Emscripten is available under two separate licenses, the MIT license and the +// University of Illinois/NCSA Open Source License. Both these licenses can be +// found in the LICENSE file. + +#include +#include +#include +#include +#include + +#include + +#define NUM_THREADS 2 +#define TOTAL 1000 +#define THREAD_ADDS 750 +#define MAIN_ADDS 5 + +static std::atomic sum; +static std::atomic total; + +void *ThreadMain(void *arg) { + for (int i = 0; i < TOTAL; i++) { + try { + // Throw two different types, to make sure we check throwing and landing + // pad behavior. + if (i & 3) { + throw 3.14159f; + } + throw i; + } catch (int x) { + total += x; + } catch (float f) { + sum++; + // wait for a change, so we see interleaved processing. + int last = sum.load(); + while (sum.load() == last) {} + } + } + pthread_exit((void*)TOTAL); +} + +pthread_t thread[NUM_THREADS]; + +void CreateThread(int i) +{ + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + static int counter = 1; + int rc = pthread_create(&thread[i], &attr, ThreadMain, (void*)i); + assert(rc == 0); + pthread_attr_destroy(&attr); +} + +void loop() { + static int main_adds = 0; + int worker_adds = sum.load() - main_adds; + sum++; + main_adds++; + printf("main iter %d : %d\n", main_adds, worker_adds); + if (worker_adds == NUM_THREADS * THREAD_ADDS && + main_adds >= MAIN_ADDS) { + printf("done: %d.\n", total.load()); + emscripten_cancel_main_loop(); + exit(0); + } +} + +int main() { + // Create initial threads. + for(int i = 0; i < NUM_THREADS; ++i) { + printf("maek\n"); + CreateThread(i); + } + + emscripten_set_main_loop(loop, 0, 0); +} diff --git a/tests/core/pthread/exceptions.out b/tests/core/pthread/exceptions.out new file mode 100644 index 0000000000000..a179329e2e7d0 --- /dev/null +++ b/tests/core/pthread/exceptions.out @@ -0,0 +1 @@ +done: 249000. diff --git a/tests/test_core.py b/tests/test_core.py index 96faf6c3c0d97..3df71e6d58543 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -8247,6 +8247,12 @@ def test(): self.emcc_args += ['-DPOOL'] test() + @node_pthreads + def test_pthread_exceptions(self): + self.set_setting('PTHREAD_POOL_SIZE', '2') + self.emcc_args += ['-fexceptions'] + self.do_run_in_out_file_test('tests', 'core', 'pthread', 'exceptions.cpp') + def test_emscripten_atomics_stub(self): self.do_run_in_out_file_test('tests', 'core', 'pthread', 'emscripten_atomics.c') From faa03bc4051e738ed35457b9dad4bde200b9a34d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 15:19:07 -0700 Subject: [PATCH 06/22] use threads.h [ci skip] --- system/lib/libc/emscripten_exception_builtins.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/lib/libc/emscripten_exception_builtins.c b/system/lib/libc/emscripten_exception_builtins.c index 6573d391ea7a5..af512ca7c48dc 100644 --- a/system/lib/libc/emscripten_exception_builtins.c +++ b/system/lib/libc/emscripten_exception_builtins.c @@ -15,8 +15,10 @@ that way atm. */ -int _Thread_local __THREW__ = 0; -int _Thread_local __threwValue = 0; +#include + +thread_local int __THREW__ = 0; +thread_local int __threwValue = 0; void setThrew(int threw, int value) { if (__THREW__ == 0) { From 06ab3167092f1e3e9419b484ac1f9a9039992aeb Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 15:27:26 -0700 Subject: [PATCH 07/22] add a compiler-rt mt variant [ci skip] --- .../{libc => compiler-rt}/emscripten_exception_builtins.c | 0 tools/system_libs.py | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename system/lib/{libc => compiler-rt}/emscripten_exception_builtins.c (100%) diff --git a/system/lib/libc/emscripten_exception_builtins.c b/system/lib/compiler-rt/emscripten_exception_builtins.c similarity index 100% rename from system/lib/libc/emscripten_exception_builtins.c rename to system/lib/compiler-rt/emscripten_exception_builtins.c diff --git a/tools/system_libs.py b/tools/system_libs.py index e0a2b0e5383e9..55b918c17f171 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -635,7 +635,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(Library): +class libcompiler_rt(MuslInternalLibrary, MTLibrary): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 @@ -646,6 +646,7 @@ class libcompiler_rt(Library): src_files = glob_in_path(src_dir, '*.c') src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'stack_ops.s')) src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'emscripten_setjmp.c')) + src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'emscripten_exception_builtins.c')) class libc(AsanInstrumentedLibrary, MuslInternalLibrary, MTLibrary): @@ -743,7 +744,7 @@ def get_files(self): libc_files += files_in_path( path_components=['system', 'lib', 'libc'], - filenames=['emscripten_exception_builtins.c', 'extras.c', 'wasi-helpers.c']) + filenames=['extras.c', 'wasi-helpers.c']) return libc_files From b3db6a9a63f7d52ea4b51111f45653d8365e8652 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 16:08:49 -0700 Subject: [PATCH 08/22] review feedback [ci skip] --- system/lib/compiler-rt/emscripten_exception_builtins.c | 5 ----- tests/core/pthread/exceptions.cpp | 7 +------ 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/system/lib/compiler-rt/emscripten_exception_builtins.c b/system/lib/compiler-rt/emscripten_exception_builtins.c index af512ca7c48dc..5d09170a5fac9 100644 --- a/system/lib/compiler-rt/emscripten_exception_builtins.c +++ b/system/lib/compiler-rt/emscripten_exception_builtins.c @@ -8,11 +8,6 @@ /* References to these longjmp- and exceptions-supporting things are generated in the llvm backend. - - Note that these might make more sense in compiler-rt, but they need to be - built with multithreading support when relevant (to avoid races between - threads that throw at the same time etc.), and compiler-rt is not built - that way atm. */ #include diff --git a/tests/core/pthread/exceptions.cpp b/tests/core/pthread/exceptions.cpp index 60e2cfe15e767..14e2598dcea6c 100644 --- a/tests/core/pthread/exceptions.cpp +++ b/tests/core/pthread/exceptions.cpp @@ -44,13 +44,8 @@ pthread_t thread[NUM_THREADS]; void CreateThread(int i) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - static int counter = 1; - int rc = pthread_create(&thread[i], &attr, ThreadMain, (void*)i); + int rc = pthread_create(&thread[i], nullptr, ThreadMain, (void*)i); assert(rc == 0); - pthread_attr_destroy(&attr); } void loop() { From 7955ce2f3cad124fed77fb28f0fe7c0e2b3d581d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 19:38:19 -0700 Subject: [PATCH 09/22] Also build libc_rt_wasm with -mt when needed --- tools/system_libs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/system_libs.py b/tools/system_libs.py index 55b918c17f171..4f22b75a3e87c 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -1206,7 +1206,7 @@ class CompilerRTLibrary(Library): force_object_files = True -class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary): +class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary, MTLibrary): name = 'libc_rt_wasm' def get_files(self): From 96cbf74a4c305a4a92a2c86c2c875b3e10de6d20 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 19:42:10 -0700 Subject: [PATCH 10/22] fix test --- tests/test_other.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_other.py b/tests/test_other.py index c5f1ae697c1d8..585e27230d4f1 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -9257,6 +9257,8 @@ def test_warning_flags(self): self.assertContained('error: use of legacy setting: TOTAL_MEMORY (setting renamed to INITIAL_MEMORY) [-Wlegacy-settings] [-Werror]', stderr) # check that `-Wno-pthreads-mem` disables USE_PTHREADS + ALLOW_GROWTH_MEMORY warning + # (note that we must build the .o file with atomics support now) + self.run_process([EMCC, '-c', '-o', 'hello.o', path_from_root('tests', 'hello_world.c'), '-pthread']) stderr = self.run_process(cmd + ['-Wno-pthreads-mem-growth', '-s', 'USE_PTHREADS=1', '-s', 'ALLOW_MEMORY_GROWTH=1'], stderr=PIPE).stderr self.assertNotContained('USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271', stderr) From 06296089394a107d974e5ee36b3f8e2c003a4f54 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 19:43:19 -0700 Subject: [PATCH 11/22] Revert "Disable tests to allow LLVM to roll in (#12337)" This reverts commit 270f795c0492d681b55de89f9888cf577be9d4fc. --- tests/test_core.py | 4 ---- tests/test_other.py | 4 ---- 2 files changed, 8 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 29c5a3e78788c..d1d5021cdfb4c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -7750,7 +7750,6 @@ def test_stack_overflow_check(self): self.emcc_args += ['-DONE_BIG_STRING'] self.do_runf(path_from_root('tests', 'stack_overflow.cpp'), 'stack overflow', assert_returncode=NON_ZERO) - @unittest.skip('let llvm roll in') @node_pthreads def test_binaryen_2170_emscripten_atomic_cas_u8(self): self.emcc_args += ['-s', 'USE_PTHREADS=1'] @@ -8163,7 +8162,6 @@ def test_fpic_static(self): self.emcc_args.append('-fPIC') self.do_run_in_out_file_test('tests', 'core', 'test_hello_world.c') - @unittest.skip('let llvm roll in') @node_pthreads def test_pthread_create(self): self.set_setting('-lbrowser.js') @@ -8184,7 +8182,6 @@ def test_pthread_exceptions(self): self.emcc_args += ['-fexceptions'] self.do_run_in_out_file_test('tests', 'core', 'pthread', 'exceptions.cpp') - @unittest.skip('let llvm roll in') def test_emscripten_atomics_stub(self): self.do_run_in_out_file_test('tests', 'core', 'pthread', 'emscripten_atomics.c') @@ -8194,7 +8191,6 @@ def test_emscripten_atomics(self): self.set_setting('USE_PTHREADS', '1') self.do_run_in_out_file_test('tests', 'core', 'pthread', 'emscripten_atomics.c') - @unittest.skip('let llvm roll in') @no_asan('incompatibility with atomics') @node_pthreads def test_emscripten_futexes(self): diff --git a/tests/test_other.py b/tests/test_other.py index 5e14e0d05022d..ed563d5f0c8b0 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -2563,7 +2563,6 @@ def test_fs_stream_proto(self): out = self.run_js('a.out.js', engine=engine) self.assertContained('File size: 724', out) - @unittest.skip('let llvm roll in') def test_node_emscripten_num_logical_cores(self): # Test with node.js that the emscripten_num_logical_cores method is working create_test_file('src.cpp', r''' @@ -7890,7 +7889,6 @@ def test_node_js_run_from_different_directory(self): self.assertContained('hello, world!', ret) # Tests that a pthreads + modularize build can be run in node js - @unittest.skip('let llvm roll in') def test_node_js_pthread_module(self): # create module loader script moduleLoader = 'moduleLoader.js' @@ -8816,7 +8814,6 @@ def test_asan_no_stack_trace(self): def test_asan_pthread_stubs(self): self.do_smart_test(path_from_root('tests', 'other', 'test_asan_pthread_stubs.c'), emcc_args=['-fsanitize=address', '-s', 'ALLOW_MEMORY_GROWTH=1']) - @unittest.skip('let llvm roll in') def test_proxy_to_pthread_stack(self): with js_engines_modify([NODE_JS + ['--experimental-wasm-threads', '--experimental-wasm-bulk-memory']]): self.do_smart_test(path_from_root('tests', 'other', 'test_proxy_to_pthread_stack.c'), @@ -9212,7 +9209,6 @@ def test_backwards_deps_in_archive(self): self.run_process([EMCC, 'empty.c', '-la', '-L.']) self.assertContained('success', self.run_js('a.out.js')) - @unittest.skip('let llvm roll in') def test_warning_flags(self): self.run_process([EMCC, '-c', '-o', 'hello.o', path_from_root('tests', 'hello_world.c')]) cmd = [EMCC, 'hello.o', '-o', 'a.js', '-g', '--closure', '1'] From 9e6193eda4e0db9793bbce845871b1c4aa191e6b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 19:44:12 -0700 Subject: [PATCH 12/22] [ci skip] --- tests/test_other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_other.py b/tests/test_other.py index ed563d5f0c8b0..846ca6a00707f 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -9238,7 +9238,7 @@ def test_warning_flags(self): self.assertContained('error: use of legacy setting: TOTAL_MEMORY (setting renamed to INITIAL_MEMORY) [-Wlegacy-settings] [-Werror]', stderr) # check that `-Wno-pthreads-mem` disables USE_PTHREADS + ALLOW_GROWTH_MEMORY warning - # (note that we must build the .o file with atomics support now) + # (note that we must build the .o file with atomics support, now) self.run_process([EMCC, '-c', '-o', 'hello.o', path_from_root('tests', 'hello_world.c'), '-pthread']) stderr = self.run_process(cmd + ['-Wno-pthreads-mem-growth', '-s', 'USE_PTHREADS=1', '-s', 'ALLOW_MEMORY_GROWTH=1'], stderr=PIPE).stderr self.assertNotContained('USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271', stderr) From e55647a396a1578cc16ef4580ccb03adc4accd73 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 24 Sep 2020 21:27:21 -0700 Subject: [PATCH 13/22] revert the extra disabled test too [ci skip] --- tests/test_core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_core.py b/tests/test_core.py index 67d419eb52808..d1d5021cdfb4c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -8185,7 +8185,6 @@ def test_pthread_exceptions(self): def test_emscripten_atomics_stub(self): self.do_run_in_out_file_test('tests', 'core', 'pthread', 'emscripten_atomics.c') - @unittest.skip('let llvm roll in') @no_asan('incompatibility with atomics') @node_pthreads def test_emscripten_atomics(self): From c76b122b9d6020a0c35bee684799dc62545f8f72 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 06:40:29 -0700 Subject: [PATCH 14/22] comment --- tests/test_other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_other.py b/tests/test_other.py index 846ca6a00707f..ed563d5f0c8b0 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -9238,7 +9238,7 @@ def test_warning_flags(self): self.assertContained('error: use of legacy setting: TOTAL_MEMORY (setting renamed to INITIAL_MEMORY) [-Wlegacy-settings] [-Werror]', stderr) # check that `-Wno-pthreads-mem` disables USE_PTHREADS + ALLOW_GROWTH_MEMORY warning - # (note that we must build the .o file with atomics support, now) + # (note that we must build the .o file with atomics support now) self.run_process([EMCC, '-c', '-o', 'hello.o', path_from_root('tests', 'hello_world.c'), '-pthread']) stderr = self.run_process(cmd + ['-Wno-pthreads-mem-growth', '-s', 'USE_PTHREADS=1', '-s', 'ALLOW_MEMORY_GROWTH=1'], stderr=PIPE).stderr self.assertNotContained('USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271', stderr) From d42e14854cd69d21f118e31927772726fc2fd56f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 07:52:40 -0700 Subject: [PATCH 15/22] embind and asan_js libraries now also need to be built with -mt --- tools/system_libs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/system_libs.py b/tools/system_libs.py index 4f22b75a3e87c..0eafd19bbe213 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -635,7 +635,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(MuslInternalLibrary, MTLibrary): +class libcompiler_rt(MTLibrary): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 @@ -1086,7 +1086,7 @@ class libwebgpu_cpp(MTLibrary): src_files = ['webgpu_cpp.cpp'] -class libembind(Library): +class libembind(MTLibrary): name = 'libembind' never_force = True @@ -1268,7 +1268,7 @@ class libasan_rt(SanitizerLibrary): src_dir = ['system', 'lib', 'compiler-rt', 'lib', 'asan'] -class libasan_js(Library): +class libasan_js(MTLibrary): name = 'libasan_js' cflags = ['-fsanitize=address'] From 36c0ee07d8656f93c75bd53aaa1e0aec7630134d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 09:22:24 -0700 Subject: [PATCH 16/22] -mt --- tools/cache.py | 2 ++ tools/system_libs.py | 48 +++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/tools/cache.py b/tools/cache.py index 51001b103ce60..4da107ab4ea4e 100644 --- a/tools/cache.py +++ b/tools/cache.py @@ -36,6 +36,8 @@ def __init__(self, dirname, use_subdir=True): subdir += '-lto' if shared.Settings.RELOCATABLE: subdir += '-pic' + if shared.Settings.USE_PTHREADS: + subdir += '-mt' dirname = os.path.join(dirname, subdir) self.dirname = dirname diff --git a/tools/system_libs.py b/tools/system_libs.py index 0eafd19bbe213..41642e1bb606c 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -62,6 +62,8 @@ def get_cflags(force_object_files=False): flags += ['-flto=' + shared.Settings.LTO] if shared.Settings.RELOCATABLE: flags += ['-s', 'RELOCATABLE'] + if shared.Settings.USE_PTHREADS: + flags += ['-s', 'USE_PTHREADS'] return flags @@ -635,7 +637,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(MTLibrary): +class libcompiler_rt(Library): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 @@ -649,7 +651,7 @@ class libcompiler_rt(MTLibrary): src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'emscripten_exception_builtins.c')) -class libc(AsanInstrumentedLibrary, MuslInternalLibrary, MTLibrary): +class libc(AsanInstrumentedLibrary, MuslInternalLibrary): name = 'libc' # Without -fno-builtin, LLVM can optimize away or convert calls to library @@ -760,7 +762,7 @@ def get_files(self): filenames=['vfprintf.c']) -class libsockets(MuslInternalLibrary, MTLibrary): +class libsockets(MuslInternalLibrary): name = 'libsockets' cflags = ['-Os', '-fno-builtin'] @@ -770,7 +772,7 @@ def get_files(self): return [os.path.join(network_dir, x) for x in LIBC_SOCKETS] -class libsockets_proxy(MuslInternalLibrary, MTLibrary): +class libsockets_proxy(MuslInternalLibrary): name = 'libsockets_proxy' cflags = ['-Os'] @@ -810,7 +812,7 @@ def can_use(self): return super(crt1_reactor, self).can_use() and shared.Settings.STANDALONE_WASM -class libcxxabi(NoExceptLibrary, MTLibrary): +class libcxxabi(NoExceptLibrary): name = 'libc++abi' cflags = [ '-Oz', @@ -823,7 +825,7 @@ class libcxxabi(NoExceptLibrary, MTLibrary): def get_cflags(self): cflags = super(libcxxabi, self).get_cflags() cflags.append('-DNDEBUG') - if not self.is_mt: + if shared.Settings.USE_PTHREADS == 0: cflags.append('-D_LIBCXXABI_HAS_NO_THREADS') if self.eh_mode == exceptions.none: cflags.append('-D_LIBCXXABI_NO_EXCEPTIONS') @@ -863,7 +865,7 @@ def get_files(self): filenames=filenames) -class libcxx(NoExceptLibrary, MTLibrary): +class libcxx(NoExceptLibrary): name = 'libc++' cflags = ['-DLIBCXX_BUILDING_LIBCXXABI=1', '-D_LIBCPP_BUILDING_LIBRARY', '-Oz', @@ -910,7 +912,7 @@ class libcxx(NoExceptLibrary, MTLibrary): ] -class libunwind(NoExceptLibrary, MTLibrary): +class libunwind(NoExceptLibrary): name = 'libunwind' cflags = ['-Oz', '-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS'] src_dir = ['system', 'lib', 'libunwind', 'src'] @@ -925,7 +927,7 @@ def can_use(self): def get_cflags(self): cflags = super(libunwind, self).get_cflags() cflags.append('-DNDEBUG') - if not self.is_mt: + if shared.Settings.USE_PTHREADS == 0: cflags.append('-D_LIBUNWIND_HAS_NO_THREADS') if self.eh_mode == exceptions.none: cflags.append('-D_LIBUNWIND_HAS_NO_EXCEPTIONS') @@ -936,7 +938,7 @@ def get_cflags(self): return cflags -class libmalloc(MTLibrary): +class libmalloc(Library): name = 'libmalloc' cflags = ['-O2', '-fno-builtin'] @@ -1024,7 +1026,7 @@ class libal(Library): src_files = ['al.c'] -class libgl(MTLibrary): +class libgl(Library): name = 'libgl' src_dir = ['system', 'lib', 'gl'] @@ -1078,7 +1080,7 @@ def get_default_variation(cls, **kwargs): ) -class libwebgpu_cpp(MTLibrary): +class libwebgpu_cpp(Library): name = 'libwebgpu_cpp' cflags = ['-std=c++11', '-O2'] @@ -1086,7 +1088,7 @@ class libwebgpu_cpp(MTLibrary): src_files = ['webgpu_cpp.cpp'] -class libembind(MTLibrary): +class libembind(Library): name = 'libembind' never_force = True @@ -1118,7 +1120,7 @@ def get_default_variation(cls, **kwargs): return super(libembind, cls).get_default_variation(with_rtti=shared.Settings.USE_RTTI, **kwargs) -class libfetch(MTLibrary): +class libfetch(Library): name = 'libfetch' never_force = True @@ -1126,7 +1128,7 @@ def get_files(self): return [shared.path_from_root('system', 'lib', 'fetch', 'emscripten_fetch.cpp')] -class libasmfs(MTLibrary): +class libasmfs(Library): name = 'libasmfs' never_force = True @@ -1147,12 +1149,12 @@ class libhtml5(Library): src_glob = '*.c' -class libpthread(AsanInstrumentedLibrary, MuslInternalLibrary, MTLibrary): +class libpthread(AsanInstrumentedLibrary, MuslInternalLibrary): name = 'libpthread' cflags = ['-O2'] def get_files(self): - if self.is_mt: + if shared.Settings.USE_PTHREADS: files = files_in_path( path_components=['system', 'lib', 'libc', 'musl', 'src', 'thread'], filenames=[ @@ -1196,7 +1198,7 @@ def get_files(self): return [shared.path_from_root('system', 'lib', 'pthread', 'library_pthread_stub.c')] def get_base_name_prefix(self): - return 'libpthread' if self.is_mt else 'libpthread_stub' + return 'libpthread' if shared.Settings.USE_PTHREADS else 'libpthread_stub' class CompilerRTLibrary(Library): @@ -1206,14 +1208,14 @@ class CompilerRTLibrary(Library): force_object_files = True -class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary, MTLibrary): +class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary): name = 'libc_rt_wasm' def get_files(self): return get_wasm_libc_rt_files() -class libubsan_minimal_rt_wasm(CompilerRTLibrary, MTLibrary): +class libubsan_minimal_rt_wasm(CompilerRTLibrary): name = 'libubsan_minimal_rt_wasm' never_force = True @@ -1222,7 +1224,7 @@ class libubsan_minimal_rt_wasm(CompilerRTLibrary, MTLibrary): src_files = ['ubsan_minimal_handlers.cpp'] -class libsanitizer_common_rt(CompilerRTLibrary, MTLibrary): +class libsanitizer_common_rt(CompilerRTLibrary): name = 'libsanitizer_common_rt' includes = [['system', 'lib', 'libc', 'musl', 'src', 'internal'], ['system', 'lib', 'compiler-rt', 'lib']] @@ -1233,7 +1235,7 @@ class libsanitizer_common_rt(CompilerRTLibrary, MTLibrary): src_glob_exclude = ['sanitizer_common_nolibc.cpp'] -class SanitizerLibrary(CompilerRTLibrary, MTLibrary): +class SanitizerLibrary(CompilerRTLibrary): never_force = True includes = [['system', 'lib', 'compiler-rt', 'lib']] @@ -1268,7 +1270,7 @@ class libasan_rt(SanitizerLibrary): src_dir = ['system', 'lib', 'compiler-rt', 'lib', 'asan'] -class libasan_js(MTLibrary): +class libasan_js(Library): name = 'libasan_js' cflags = ['-fsanitize=address'] From 05257b870037b0edb9c34bfc41f6d578478f2dec Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 10:59:27 -0700 Subject: [PATCH 17/22] Revert "-mt" This reverts commit 36c0ee07d8656f93c75bd53aaa1e0aec7630134d. --- tools/cache.py | 2 -- tools/system_libs.py | 48 +++++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/tools/cache.py b/tools/cache.py index 4da107ab4ea4e..51001b103ce60 100644 --- a/tools/cache.py +++ b/tools/cache.py @@ -36,8 +36,6 @@ def __init__(self, dirname, use_subdir=True): subdir += '-lto' if shared.Settings.RELOCATABLE: subdir += '-pic' - if shared.Settings.USE_PTHREADS: - subdir += '-mt' dirname = os.path.join(dirname, subdir) self.dirname = dirname diff --git a/tools/system_libs.py b/tools/system_libs.py index 41642e1bb606c..0eafd19bbe213 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -62,8 +62,6 @@ def get_cflags(force_object_files=False): flags += ['-flto=' + shared.Settings.LTO] if shared.Settings.RELOCATABLE: flags += ['-s', 'RELOCATABLE'] - if shared.Settings.USE_PTHREADS: - flags += ['-s', 'USE_PTHREADS'] return flags @@ -637,7 +635,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(Library): +class libcompiler_rt(MTLibrary): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 @@ -651,7 +649,7 @@ class libcompiler_rt(Library): src_files.append(shared.path_from_root('system', 'lib', 'compiler-rt', 'emscripten_exception_builtins.c')) -class libc(AsanInstrumentedLibrary, MuslInternalLibrary): +class libc(AsanInstrumentedLibrary, MuslInternalLibrary, MTLibrary): name = 'libc' # Without -fno-builtin, LLVM can optimize away or convert calls to library @@ -762,7 +760,7 @@ def get_files(self): filenames=['vfprintf.c']) -class libsockets(MuslInternalLibrary): +class libsockets(MuslInternalLibrary, MTLibrary): name = 'libsockets' cflags = ['-Os', '-fno-builtin'] @@ -772,7 +770,7 @@ def get_files(self): return [os.path.join(network_dir, x) for x in LIBC_SOCKETS] -class libsockets_proxy(MuslInternalLibrary): +class libsockets_proxy(MuslInternalLibrary, MTLibrary): name = 'libsockets_proxy' cflags = ['-Os'] @@ -812,7 +810,7 @@ def can_use(self): return super(crt1_reactor, self).can_use() and shared.Settings.STANDALONE_WASM -class libcxxabi(NoExceptLibrary): +class libcxxabi(NoExceptLibrary, MTLibrary): name = 'libc++abi' cflags = [ '-Oz', @@ -825,7 +823,7 @@ class libcxxabi(NoExceptLibrary): def get_cflags(self): cflags = super(libcxxabi, self).get_cflags() cflags.append('-DNDEBUG') - if shared.Settings.USE_PTHREADS == 0: + if not self.is_mt: cflags.append('-D_LIBCXXABI_HAS_NO_THREADS') if self.eh_mode == exceptions.none: cflags.append('-D_LIBCXXABI_NO_EXCEPTIONS') @@ -865,7 +863,7 @@ def get_files(self): filenames=filenames) -class libcxx(NoExceptLibrary): +class libcxx(NoExceptLibrary, MTLibrary): name = 'libc++' cflags = ['-DLIBCXX_BUILDING_LIBCXXABI=1', '-D_LIBCPP_BUILDING_LIBRARY', '-Oz', @@ -912,7 +910,7 @@ class libcxx(NoExceptLibrary): ] -class libunwind(NoExceptLibrary): +class libunwind(NoExceptLibrary, MTLibrary): name = 'libunwind' cflags = ['-Oz', '-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS'] src_dir = ['system', 'lib', 'libunwind', 'src'] @@ -927,7 +925,7 @@ def can_use(self): def get_cflags(self): cflags = super(libunwind, self).get_cflags() cflags.append('-DNDEBUG') - if shared.Settings.USE_PTHREADS == 0: + if not self.is_mt: cflags.append('-D_LIBUNWIND_HAS_NO_THREADS') if self.eh_mode == exceptions.none: cflags.append('-D_LIBUNWIND_HAS_NO_EXCEPTIONS') @@ -938,7 +936,7 @@ def get_cflags(self): return cflags -class libmalloc(Library): +class libmalloc(MTLibrary): name = 'libmalloc' cflags = ['-O2', '-fno-builtin'] @@ -1026,7 +1024,7 @@ class libal(Library): src_files = ['al.c'] -class libgl(Library): +class libgl(MTLibrary): name = 'libgl' src_dir = ['system', 'lib', 'gl'] @@ -1080,7 +1078,7 @@ def get_default_variation(cls, **kwargs): ) -class libwebgpu_cpp(Library): +class libwebgpu_cpp(MTLibrary): name = 'libwebgpu_cpp' cflags = ['-std=c++11', '-O2'] @@ -1088,7 +1086,7 @@ class libwebgpu_cpp(Library): src_files = ['webgpu_cpp.cpp'] -class libembind(Library): +class libembind(MTLibrary): name = 'libembind' never_force = True @@ -1120,7 +1118,7 @@ def get_default_variation(cls, **kwargs): return super(libembind, cls).get_default_variation(with_rtti=shared.Settings.USE_RTTI, **kwargs) -class libfetch(Library): +class libfetch(MTLibrary): name = 'libfetch' never_force = True @@ -1128,7 +1126,7 @@ def get_files(self): return [shared.path_from_root('system', 'lib', 'fetch', 'emscripten_fetch.cpp')] -class libasmfs(Library): +class libasmfs(MTLibrary): name = 'libasmfs' never_force = True @@ -1149,12 +1147,12 @@ class libhtml5(Library): src_glob = '*.c' -class libpthread(AsanInstrumentedLibrary, MuslInternalLibrary): +class libpthread(AsanInstrumentedLibrary, MuslInternalLibrary, MTLibrary): name = 'libpthread' cflags = ['-O2'] def get_files(self): - if shared.Settings.USE_PTHREADS: + if self.is_mt: files = files_in_path( path_components=['system', 'lib', 'libc', 'musl', 'src', 'thread'], filenames=[ @@ -1198,7 +1196,7 @@ def get_files(self): return [shared.path_from_root('system', 'lib', 'pthread', 'library_pthread_stub.c')] def get_base_name_prefix(self): - return 'libpthread' if shared.Settings.USE_PTHREADS else 'libpthread_stub' + return 'libpthread' if self.is_mt else 'libpthread_stub' class CompilerRTLibrary(Library): @@ -1208,14 +1206,14 @@ class CompilerRTLibrary(Library): force_object_files = True -class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary): +class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary, MTLibrary): name = 'libc_rt_wasm' def get_files(self): return get_wasm_libc_rt_files() -class libubsan_minimal_rt_wasm(CompilerRTLibrary): +class libubsan_minimal_rt_wasm(CompilerRTLibrary, MTLibrary): name = 'libubsan_minimal_rt_wasm' never_force = True @@ -1224,7 +1222,7 @@ class libubsan_minimal_rt_wasm(CompilerRTLibrary): src_files = ['ubsan_minimal_handlers.cpp'] -class libsanitizer_common_rt(CompilerRTLibrary): +class libsanitizer_common_rt(CompilerRTLibrary, MTLibrary): name = 'libsanitizer_common_rt' includes = [['system', 'lib', 'libc', 'musl', 'src', 'internal'], ['system', 'lib', 'compiler-rt', 'lib']] @@ -1235,7 +1233,7 @@ class libsanitizer_common_rt(CompilerRTLibrary): src_glob_exclude = ['sanitizer_common_nolibc.cpp'] -class SanitizerLibrary(CompilerRTLibrary): +class SanitizerLibrary(CompilerRTLibrary, MTLibrary): never_force = True includes = [['system', 'lib', 'compiler-rt', 'lib']] @@ -1270,7 +1268,7 @@ class libasan_rt(SanitizerLibrary): src_dir = ['system', 'lib', 'compiler-rt', 'lib', 'asan'] -class libasan_js(Library): +class libasan_js(MTLibrary): name = 'libasan_js' cflags = ['-fsanitize=address'] From 5657df5eb323e1c2b831a6a83ea5998ee57359e5 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 10:59:49 -0700 Subject: [PATCH 18/22] Revert "embind and asan_js libraries now also need to be built with -mt" This reverts commit d42e14854cd69d21f118e31927772726fc2fd56f. --- tools/system_libs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/system_libs.py b/tools/system_libs.py index 0eafd19bbe213..4f22b75a3e87c 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -635,7 +635,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(MTLibrary): +class libcompiler_rt(MuslInternalLibrary, MTLibrary): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 @@ -1086,7 +1086,7 @@ class libwebgpu_cpp(MTLibrary): src_files = ['webgpu_cpp.cpp'] -class libembind(MTLibrary): +class libembind(Library): name = 'libembind' never_force = True @@ -1268,7 +1268,7 @@ class libasan_rt(SanitizerLibrary): src_dir = ['system', 'lib', 'compiler-rt', 'lib', 'asan'] -class libasan_js(MTLibrary): +class libasan_js(Library): name = 'libasan_js' cflags = ['-fsanitize=address'] From b312b573cadfa0a489d4e0c19fd413e4d8e43c5d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 11:00:16 -0700 Subject: [PATCH 19/22] Revert "Also build libc_rt_wasm with -mt when needed" This reverts commit 7955ce2f3cad124fed77fb28f0fe7c0e2b3d581d. --- tools/system_libs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/system_libs.py b/tools/system_libs.py index 4f22b75a3e87c..55b918c17f171 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -1206,7 +1206,7 @@ class CompilerRTLibrary(Library): force_object_files = True -class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary, MTLibrary): +class libc_rt_wasm(AsanInstrumentedLibrary, CompilerRTLibrary, MuslInternalLibrary): name = 'libc_rt_wasm' def get_files(self): From 44b8dda3eb479e62c2937fcd5de24044b9b18a08 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 11:01:40 -0700 Subject: [PATCH 20/22] fix comment --- system/lib/compiler-rt/emscripten_exception_builtins.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/system/lib/compiler-rt/emscripten_exception_builtins.c b/system/lib/compiler-rt/emscripten_exception_builtins.c index 5d09170a5fac9..0c29c243f4818 100644 --- a/system/lib/compiler-rt/emscripten_exception_builtins.c +++ b/system/lib/compiler-rt/emscripten_exception_builtins.c @@ -3,13 +3,12 @@ * Emscripten is available under two separate licenses, the MIT license and the * University of Illinois/NCSA Open Source License. Both these licenses can be * found in the LICENSE file. + * + * Support functions for emscripten setjmp/longjmp and exception handling + * support. References to the things below are generated in the LLVM backend. + * See: https://llvm.org/doxygen/WebAssemblyLowerEmscriptenEHSjLj_8cpp.html */ -/* - References to these longjmp- and exceptions-supporting things are generated - in the llvm backend. -*/ - #include thread_local int __THREW__ = 0; From 704a676082caeeb08bd8440d7e1e631fecd0432c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 11:02:45 -0700 Subject: [PATCH 21/22] cleaner [ci skip] --- tools/system_libs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/system_libs.py b/tools/system_libs.py index 55b918c17f171..a8cbc684553f2 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -635,7 +635,7 @@ def get_default_variation(cls, **kwargs): return super(AsanInstrumentedLibrary, cls).get_default_variation(is_asan=shared.Settings.USE_ASAN, **kwargs) -class libcompiler_rt(MuslInternalLibrary, MTLibrary): +class libcompiler_rt(MTLibrary): name = 'libcompiler_rt' # compiler_rt files can't currently be part of LTO although we are hoping to remove this # restriction soon: https://reviews.llvm.org/D71738 From 84ab45b451b690276e7fdd63ce95aa465a58f908 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Sep 2020 15:38:52 -0700 Subject: [PATCH 22/22] remove unneeded change after the llvm change --- tests/test_other.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_other.py b/tests/test_other.py index ed563d5f0c8b0..a81b420d84b41 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -9238,8 +9238,6 @@ def test_warning_flags(self): self.assertContained('error: use of legacy setting: TOTAL_MEMORY (setting renamed to INITIAL_MEMORY) [-Wlegacy-settings] [-Werror]', stderr) # check that `-Wno-pthreads-mem` disables USE_PTHREADS + ALLOW_GROWTH_MEMORY warning - # (note that we must build the .o file with atomics support now) - self.run_process([EMCC, '-c', '-o', 'hello.o', path_from_root('tests', 'hello_world.c'), '-pthread']) stderr = self.run_process(cmd + ['-Wno-pthreads-mem-growth', '-s', 'USE_PTHREADS=1', '-s', 'ALLOW_MEMORY_GROWTH=1'], stderr=PIPE).stderr self.assertNotContained('USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271', stderr)