diff --git a/src/library.js b/src/library.js index 44531ee1d910c..010cbff47ed1a 100644 --- a/src/library.js +++ b/src/library.js @@ -398,11 +398,7 @@ addToLibrary({ // ========================================================================== #if !STANDALONE_WASM - // TODO: There are currently two abort() functions that get imported to asm - // module scope: the built-in runtime function abort(), and this library - // function _abort(). Remove one of these, importing two functions for the - // same purpose is wasteful. - abort: () => { + _abort_js: () => { #if ASSERTIONS abort('native code called abort()'); #else diff --git a/system/lib/libc/musl/src/exit/abort.c b/system/lib/libc/musl/src/exit/abort.c index f21f458eca149..4482ab56a3719 100644 --- a/system/lib/libc/musl/src/exit/abort.c +++ b/system/lib/libc/musl/src/exit/abort.c @@ -6,8 +6,15 @@ #include "lock.h" #include "ksigaction.h" +#if __EMSCRIPTEN__ +_Noreturn void _abort_js(); +#endif + _Noreturn void abort(void) { +#if __EMSCRIPTEN__ + _abort_js(); +#else raise(SIGABRT); /* If there was a SIGABRT handler installed and it returned, or if @@ -27,4 +34,5 @@ _Noreturn void abort(void) a_crash(); raise(SIGKILL); _Exit(127); +#endif } diff --git a/tools/system_libs.py b/tools/system_libs.py index 8fe1adecfb9e0..c9c0af8f69942 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -1241,7 +1241,7 @@ def get_files(self): libc_files += files_in_path( path='system/lib/libc/musl/src/exit', - filenames=['_Exit.c', 'atexit.c', 'at_quick_exit.c', 'quick_exit.c']) + filenames=['abort.c', '_Exit.c', 'atexit.c', 'at_quick_exit.c', 'quick_exit.c']) libc_files += files_in_path( path='system/lib/libc/musl/src/ldso',