Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@ LibraryManager.library = {
#endif
},

_exit__sig: 'vi',
_exit: 'exit',

_Exit__sig: 'vi',
_Exit: 'exit',

#if MINIMAL_RUNTIME
$exit: function(status) {
throw 'exit(' + status + ')';
Expand Down
4 changes: 4 additions & 0 deletions system/lib/libc/musl/src/exit/_Exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

_Noreturn void _Exit(int ec)
{
#ifdef __EMSCRIPTEN__
__wasi_proc_exit(ec);
#else
__syscall(SYS_exit_group, ec);
for (;;) __syscall(SYS_exit, ec);
#endif
}
5 changes: 0 additions & 5 deletions system/lib/standalone/standalone.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

// libc

void _Exit(int status) {
__wasi_proc_exit(status);
__builtin_unreachable();
}

void abort() {
_Exit(1);
}
Expand Down
32 changes: 27 additions & 5 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ def get_wasm_libc_rt_files():
return math_files + other_files + iprintf_files


def is_case_insensitive(path):
"""Returns True if the filesystem at `path` is case insensitive."""
shared.write_file(os.path.join(path, 'test_file'), '')
case_insensitive = os.path.exists(os.path.join(path, 'TEST_FILE'))
os.remove(os.path.join(path, 'test_file'))
return case_insensitive


class Library:
"""
`Library` is the base class of all system libraries.
Expand Down Expand Up @@ -343,8 +351,20 @@ def build_objects(self, build_dir):
objects = []
cflags = self.get_cflags()
base_flags = get_base_cflags()
case_insensitive = is_case_insensitive(build_dir)
for src in self.get_files():
o = os.path.join(build_dir, shared.unsuffixed_basename(src) + '.o')
object_basename = shared.unsuffixed_basename(src)
# Resolve duplicates by appending unique.
# This is needed on case insensitve filesystem to handle,
# for example, _exit.o and _Exit.o.
if case_insensitive:
object_basename = object_basename.lower()
o = os.path.join(build_dir, object_basename + '.o')
object_uuid = 0
# Find a unique basename
while o in objects:
object_uuid += 1
o = os.path.join(build_dir, f'{object_basename}__{object_uuid}.o')
ext = shared.suffix(src)
if ext in ('.s', '.S', '.c'):
cmd = [shared.EMCC]
Expand Down Expand Up @@ -704,7 +724,7 @@ def get_files(self):
'res_query.c', 'res_querydomain.c', 'gai_strerror.c',
'proto.c', 'gethostbyaddr.c', 'gethostbyaddr_r.c', 'gethostbyname.c',
'gethostbyname2_r.c', 'gethostbyname_r.c', 'gethostbyname2.c',
'alarm.c', 'syscall.c', '_exit.c', 'popen.c',
'alarm.c', 'syscall.c', 'popen.c',
'getgrouplist.c', 'initgroups.c', 'wordexp.c', 'timer_create.c',
'faccessat.c',
# 'process' exclusion
Expand Down Expand Up @@ -825,6 +845,10 @@ def get_files(self):
path_components=['system', 'lib', 'libc', 'musl', 'src', 'sched'],
filenames=['sched_yield.c'])

libc_files += files_in_path(
path_components=['system', 'lib', 'libc', 'musl', 'src', 'exit'],
filenames=['_Exit.c'])

libc_files += files_in_path(
path_components=['system', 'lib', 'libc'],
filenames=[
Expand Down Expand Up @@ -1390,9 +1414,7 @@ def get_files(self):
# including fprintf etc.
exit_files = files_in_path(
path_components=['system', 'lib', 'libc', 'musl', 'src', 'exit'],
filenames=['assert.c', 'atexit.c', 'exit.c']) + files_in_path(
path_components=['system', 'lib', 'libc', 'musl', 'src', 'unistd'],
filenames=['_exit.c'])
filenames=['assert.c', 'atexit.c', 'exit.c'])
return base_files + time_files + exit_files


Expand Down