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: 6 additions & 0 deletions system/lib/sbrk.c → system/lib/libc/sbrk.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
*
*/

// libc files are compiled as -std=c99 which doesn't normally declare
// max_align_t.
#if __STDC_VERSION__ < 201112L
#define __NEED_max_align_t
#endif

#ifndef EMSCRIPTEN_NO_ERRNO
#include <errno.h>
#endif
Expand Down
8 changes: 4 additions & 4 deletions test/code_size/hello_wasm_worker_wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"a.html.gz": 433,
"a.js": 733,
"a.js.gz": 463,
"a.wasm": 1854,
"a.wasm.gz": 1034,
"total": 3324,
"total_gz": 1930
"a.wasm": 1859,
"a.wasm.gz": 1033,
"total": 3329,
"total_gz": 1929
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"a.html.gz": 379,
"a.js": 4971,
"a.js.gz": 2430,
"a.wasm": 10451,
"a.wasm.gz": 6680,
"total": 15991,
"total_gz": 9489
"a.wasm": 10459,
"a.wasm.gz": 6689,
"total": 15999,
"total_gz": 9498
}
10 changes: 5 additions & 5 deletions test/code_size/hello_webgl2_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 567,
"a.html.gz": 379,
"a.js": 18201,
"a.js.gz": 8063,
"a.js": 18219,
"a.js.gz": 8059,
"a.mem": 3171,
"a.mem.gz": 2714,
"total": 21939,
"total_gz": 11156
"a.mem.gz": 2713,
"total": 21957,
"total_gz": 11151
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"a.html.gz": 379,
"a.js": 4450,
"a.js.gz": 2250,
"a.wasm": 10451,
"a.wasm.gz": 6680,
"total": 15470,
"total_gz": 9309
"a.wasm": 10459,
"a.wasm.gz": 6689,
"total": 15478,
"total_gz": 9318
}
10 changes: 5 additions & 5 deletions test/code_size/hello_webgl_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 567,
"a.html.gz": 379,
"a.js": 17673,
"a.js.gz": 7885,
"a.js": 17691,
"a.js.gz": 7882,
"a.mem": 3171,
"a.mem.gz": 2714,
"total": 21411,
"total_gz": 10978
"a.mem.gz": 2713,
"total": 21429,
"total_gz": 10974
}
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9486
9488
2 changes: 1 addition & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ def test_emmalloc(self, *args):
self.set_setting('MALLOC', 'none')
self.emcc_args += [
'-fno-builtin',
path_from_root('system/lib/sbrk.c'),
path_from_root('system/lib/libc/sbrk.c'),
path_from_root('system/lib/emmalloc.c')
]
self.emcc_args += args
Expand Down
13 changes: 10 additions & 3 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,8 @@ def get_libcall_files(self):
path='system/lib/libc',
filenames=['emscripten_memcpy.c', 'emscripten_memset.c',
'emscripten_scan_stack.c',
'emscripten_get_heap_size.c', # needed by malloc
'sbrk.c', # needed by malloc
'emscripten_memmove.c'])
# Calls to iprintf can be generated during codegen. Ideally we wouldn't
# compile these with -O2 like we do the rest of compiler-rt since its
Expand All @@ -973,7 +975,12 @@ def get_libcall_files(self):
iprintf_files += files_in_path(
path='system/lib/libc/musl/src/string',
filenames=['strlen.c'])
return math_files + exit_files + other_files + iprintf_files

errno_files = files_in_path(
path='system/lib/libc/musl/src/errno',
filenames=['__errno_location.c'])

return math_files + exit_files + other_files + iprintf_files + errno_files

def get_files(self):
libc_files = []
Expand Down Expand Up @@ -1185,6 +1192,7 @@ def get_files(self):
'sigaction.c',
'sigtimedwait.c',
'wasi-helpers.c',
'sbrk.c',
])

if settings.RELOCATABLE:
Expand Down Expand Up @@ -1587,8 +1595,7 @@ def get_files(self):
malloc = utils.path_from_root('system/lib', {
'dlmalloc': 'dlmalloc.c', 'emmalloc': 'emmalloc.c',
}[malloc_base])
sbrk = utils.path_from_root('system/lib/sbrk.c')
return [malloc, sbrk]
return [malloc]

def get_cflags(self):
cflags = super().get_cflags()
Expand Down