From 77448a918c9004e43470c251d0d8d33ce7b5fce3 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 20 Jun 2024 09:59:48 -0700 Subject: [PATCH] Fix for `-pthread` + `-sRELOCATABLE` (#22110) Fixes: #22108 --- src/library_pthread.js | 6 ++++++ test/test_other.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/library_pthread.js b/src/library_pthread.js index 41877b1c212b7..414be3e9eea27 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -1242,6 +1242,12 @@ var LibraryPThread = { } } }, +#elif RELOCATABLE + // Provide a dummy version of _emscripten_thread_exit_joinable when + // RELOCATABLE is used without MAIN_MODULE. This is because the call + // site in pthread_create.c is not able to distinguish between these + // two cases. + _emscripten_thread_exit_joinable: (thread) => {}, #endif // MAIN_MODULE $checkMailbox__deps: ['$callUserCallback', diff --git a/test/test_other.py b/test/test_other.py index dad05a14252d7..7dbd652875d2e 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -11922,6 +11922,10 @@ def test_pthread_reuse(self): self.set_setting('PTHREAD_POOL_SIZE', 1) self.do_run_in_out_file_test('other/test_pthread_reuse.c') + @node_pthreads + def test_pthread_relocatable(self): + self.do_runf('hello_world.c', 'hello, world!', emcc_args=['-sRELOCATABLE']) + def test_stdin_preprocess(self): create_file('temp.h', '#include ') outputStdin = self.run_process([EMCC, '-x', 'c++', '-dM', '-E', '-'], input="#include ", stdout=PIPE).stdout