Skip to content

Commit

Permalink
Change ino_t/off_t to 64-bits (emscripten-core#8467)
Browse files Browse the repository at this point in the history
Related to emscripten-core#7649 (point 5) and subset of emscripten-core#7799

* Update python.bc

* Update output wasm sizes

* Update wasm backend tests
  • Loading branch information
rianhunter authored and belraquib committed Dec 23, 2020
1 parent cb5e82d commit dc29b97
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion emscripten-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"1.38.30"
"1.38.31"
16 changes: 10 additions & 6 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var SyscallsLibrary = {
{{{ makeSetValue('buf', C_STRUCTS.stat.st_gid, 'stat.gid', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_rdev, 'stat.rdev', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.__st_rdev_padding, '0', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_size, 'stat.size', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_size, 'stat.size', 'i64') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_blksize, '4096', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_blocks, 'stat.blocks', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_atim.tv_sec, '(stat.atime.getTime() / 1000)|0', 'i32') }}};
Expand All @@ -66,7 +66,7 @@ var SyscallsLibrary = {
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mtim.tv_nsec, '0', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_sec, '(stat.ctime.getTime() / 1000)|0', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_nsec, '0', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ino, 'stat.ino', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ino, 'stat.ino', 'i64') }}};
return 0;
},
doMsync: function(addr, stream, len, flags) {
Expand Down Expand Up @@ -745,11 +745,15 @@ var SyscallsLibrary = {
},
__syscall140: function(which, varargs) { // llseek
var stream = SYSCALLS.getStreamFromFD(), offset_high = SYSCALLS.get(), offset_low = SYSCALLS.get(), result = SYSCALLS.get(), whence = SYSCALLS.get();
// NOTE: offset_high is unused - Emscripten's off_t is 32-bit
#if SYSCALLS_REQUIRE_FILESYSTEM
// Can't handle 64-bit integers
if (!(offset_high == -1 && offset_low < 0) &&
!(offset_high == 0 && offset_low >= 0)) {
return -ERRNO_CODES.EOVERFLOW;
}
var offset = offset_low;
FS.llseek(stream, offset, whence);
{{{ makeSetValue('result', '0', 'stream.position', 'i32') }}};
{{{ makeSetValue('result', '0', 'stream.position', 'i64') }}};
if (stream.getdents && offset === 0 && whence === {{{ cDefine('SEEK_SET') }}}) stream.getdents = null; // reset readdir state
#else
#if ASSERTIONS
Expand Down Expand Up @@ -1091,8 +1095,8 @@ var SyscallsLibrary = {
FS.isLink(child.mode) ? 10 : // DT_LNK, symbolic link.
8; // DT_REG, regular file.
}
{{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_ino, 'id', 'i32') }}};
{{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_off, 'stream.position', 'i32') }}};
{{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_ino, 'id', 'i64') }}};
{{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_off, 'stream.position', 'i64') }}};
{{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_reclen, C_STRUCTS.dirent.__size__, 'i16') }}};
{{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_type, 'type', 'i8') }}};
stringToUTF8(name, dirp + pos + {{{ C_STRUCTS.dirent.d_name }}}, 256);
Expand Down
4 changes: 2 additions & 2 deletions system/lib/libc/musl/arch/emscripten/bits/alltypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ typedef unsigned _Reg nlink_t;
#endif

#if defined(__NEED_off_t) && !defined(__DEFINED_off_t)
typedef int off_t;
typedef _Int64 off_t;
#define __DEFINED_off_t
#endif

#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t)
typedef unsigned int ino_t;
typedef unsigned _Int64 ino_t;
#define __DEFINED_ino_t
#endif

Expand Down
Binary file modified tests/python/python.bc
Binary file not shown.
28 changes: 14 additions & 14 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7983,7 +7983,7 @@ def run(*args):
run(['-Os'], 0, [], [], 85, 0, 2, 2) # noqa
run(['-Oz'], 0, [], [], 54, 0, 1, 1) # noqa
else:
run([], 20, ['abort'], ['waka'], 22712, 20, 14, 27) # noqa
run([], 21, ['abort'], ['waka'], 22712, 22, 15, 30) # noqa
run(['-O1'], 10, ['abort'], ['waka'], 10450, 7, 11, 11) # noqa
run(['-O2'], 10, ['abort'], ['waka'], 10440, 7, 11, 11) # noqa
# in -O3, -Os and -Oz we metadce, and they shrink it down to the minimal output we want
Expand All @@ -7997,33 +7997,33 @@ def run(*args):

# test on libc++: see effects of emulated function pointers
if self.is_wasm_backend():
run(['-O2'], 32, [], ['waka'], 226582, 20, 34, 561) # noqa
run(['-O2'], 33, [], ['waka'], 226582, 21, 35, 562) # noqa
else:
run(['-O2'], 34, ['abort'], ['waka'], 186423, 28, 37, 537) # noqa
run(['-O2'], 34, ['abort'], ['waka'], 186423, 29, 38, 539) # noqa
run(['-O2', '-s', 'EMULATED_FUNCTION_POINTERS=1'],
34, ['abort'], ['waka'], 186423, 28, 38, 518) # noqa
34, ['abort'], ['waka'], 186423, 29, 39, 519) # noqa

def test_binaryen_metadce_hello(self):
def run(*args):
self.run_metadce_test(path_from_root('tests', 'hello_world.cpp'), *args)

if self.is_wasm_backend():
run([], 16, [], ['waka'], 22185, 10, 17, 55) # noqa
run(['-O1'], 14, [], ['waka'], 10415, 8, 14, 29) # noqa
run(['-O2'], 14, [], ['waka'], 10183, 8, 14, 24) # noqa
run([], 17, [], ['waka'], 22185, 11, 18, 57) # noqa
run(['-O1'], 15, [], ['waka'], 10415, 9, 15, 31) # noqa
run(['-O2'], 15, [], ['waka'], 10183, 9, 15, 25) # noqa
run(['-O3'], 5, [], [], 2353, 7, 3, 14) # noqa; in -O3, -Os and -Oz we metadce
run(['-Os'], 5, [], [], 2310, 7, 3, 15) # noqa
run(['-Oz'], 5, [], [], 2272, 7, 2, 14) # noqa
# finally, check what happens when we export nothing. wasm should be almost empty
run(['-Os', '-s', 'EXPORTED_FUNCTIONS=[]'],
0, [], [], 61, 0, 1, 1) # noqa
else:
run([], 22, ['abort'], ['waka'], 42701, 22, 16, 54) # noqa
run(['-O1'], 15, ['abort'], ['waka'], 12630, 14, 13, 30) # noqa
run(['-O2'], 15, ['abort'], ['waka'], 12616, 14, 13, 26) # noqa
run(['-O3'], 6, [], [], 2443, 9, 2, 14) # noqa; in -O3, -Os and -Oz we metadce
run(['-Os'], 6, [], [], 2412, 9, 2, 16) # noqa
run(['-Oz'], 6, [], [], 2389, 9, 2, 15) # noqa
run([], 23, ['abort'], ['waka'], 42701, 24, 17, 57) # noqa
run(['-O1'], 15, ['abort'], ['waka'], 13199, 15, 14, 33) # noqa
run(['-O2'], 15, ['abort'], ['waka'], 12425, 15, 14, 28) # noqa
run(['-O3'], 6, [], [], 2443, 9, 2, 15) # noqa; in -O3, -Os and -Oz we metadce
run(['-Os'], 6, [], [], 2412, 9, 2, 17) # noqa
run(['-Oz'], 6, [], [], 2389, 9, 2, 16) # noqa
# finally, check what happens when we export nothing. wasm should be almost empty
run(['-Os', '-s', 'EXPORTED_FUNCTIONS=[]'],
0, [], [], 8, 0, 0, 0) # noqa; totally empty!
Expand Down Expand Up @@ -8288,7 +8288,7 @@ def test_clear_error_on_massive_static_data(self):
if self.is_wasm_backend():
self.assertContained('wasm-ld: error: initial memory too small', err)
else:
self.assertContained('Memory is not large enough for static data (133984) plus the stack (1024), please increase TOTAL_MEMORY (65536)', err)
self.assertContained('Memory is not large enough for static data (134016) plus the stack (1024), please increase TOTAL_MEMORY (65536)', err)

def test_o_level_clamp(self):
for level in [3, 4, 20]:
Expand Down
2 changes: 1 addition & 1 deletion tests/zlib/ref.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zlib version 1.2.5 = 4688, compile flags = 85
zlib version 1.2.5 = 4688, compile flags = 149
uncompress(): hello, hello!
inflate(): hello, hello!
large_inflate(): OK
Expand Down
2 changes: 1 addition & 1 deletion tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def get_emscripten_version(path):
# change, increment EMSCRIPTEN_ABI_MINOR if EMSCRIPTEN_ABI_MAJOR == 0
# or the ABI change is backwards compatible, otherwise increment
# EMSCRIPTEN_ABI_MAJOR and set EMSCRIPTEN_ABI_MINOR = 0
(EMSCRIPTEN_ABI_MAJOR, EMSCRIPTEN_ABI_MINOR) = (0, 2)
(EMSCRIPTEN_ABI_MAJOR, EMSCRIPTEN_ABI_MINOR) = (0, 3)


def generate_sanity():
Expand Down

0 comments on commit dc29b97

Please sign in to comment.