Add pthread support for Emscripten build. #841
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When trying to load the built .js and .wasm files in current browsers (Chrome, Safari, Firefox), an error is triggered relating to pthreads. Adding the compiler and linker flags for Emscripten resolve the issue.
Chrome provides the most detailed error, and it is related to the TaskScheduler and pthread use:
test.js:546 Aborted(native code called abort())
test.js:564 Uncaught (in promise) RuntimeError: Aborted(native code called abort())
at abort (http://localhost:3000/js/test.js:564:11)
at __abort_js (http://localhost:3000/js/test.js:1060:7)
at test.wasm.abort (http://localhost:3000/js/test.wasm:wasm-function[1175]:0xdb538)
at test.wasm.std::__2::__throw_system_error(int, char const*) (http://localhost:3000/js/test.wasm:wasm-function[1180]:0xdb60f)
at test.wasm.std::__2::thread::thread<void (&)(enki::ThreadArgs const&), enki::ThreadArgs, void>(void (&)(enki::ThreadArgs const&), enki::ThreadArgs&&) (http://localhost:3000/js/test.wasm:wasm-function[885]:0xca7b9)
at test.wasm.enki::TaskScheduler::StartThreads() (http://localhost:3000/js/test.wasm:wasm-function[877]:0xc9c89)
at test.wasm.enki::TaskScheduler::Initialize(enki::TaskSchedulerConfig) (http://localhost:3000/js/test.wasm:wasm-function[967]:0xd0794)
at test.wasm.enkiInitTaskSchedulerWithConfig (http://localhost:3000/js/test.wasm:wasm-function[1044]:0xd3a59)
at test.wasm.TiltedStacks (http://localhost:3000/js/test.wasm:wasm-function[21]:0x3bcc)
at test.wasm.MultithreadingTest (http://localhost:3000/js/test.wasm:wasm-function[19]:0x2321)