Skip to content

Commit

Permalink
Merge branch 'main' into libunwind_changelog_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aheejin committed Dec 20, 2024
2 parents a8ab80b + 3d4df5b commit 5ee5731
Show file tree
Hide file tree
Showing 68 changed files with 242 additions and 123 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,32 @@ jobs:
cat $EM_CONFIG
- name: Check test expectations on target branch
run: |
echo "Checking out ${{ github.base_ref }}"
git checkout ${{ github.base_ref }}
git rev-parse HEAD
# Hack to honor changes to rebaseline_tests.py in the current PR
git checkout - ./tools/maint/rebaseline_tests.py
./bootstrap
if ! ./tools/maint/rebaseline_tests.py --check-only; then
echo "Test expectations are out-of-date on the target branch."
echo "You can run `./tools/maint/rebaseline_tests.py --new-branch`"
echo "You can run './tools/maint/rebaseline_tests.py --new-branch'"
echo "and use it to create a seperate PR."
echo "-- This failure is only a warning and can be ignored"
exit 1
fi
- name: Check test expectations on PR branch
run: |
echo "Checking out ${{ github.ref }} (${{ github.sha }})"
# For some reason we cannot pass ${{ github.ref }} direclty to git
# since it doesn't recognise it.
git checkout ${{ github.sha }}
git rev-parse HEAD
./bootstrap
if ! ./tools/maint/rebaseline_tests.py --check-only --clear-cache; then
echo "Test expectations are out-of-date on the PR branch."
echo "You can run './tools/maint/rebaseline_tests.py' to"
echo "create a commit updating the expectations."
echo "Be sure to have `emsdk install tot` first."
echo "-- This failure is only a warning and can be ignored"
exit 1
fi
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ See docs/process.md for more on how version tagging works.

3.1.75 (in development)
-----------------------
- The Wasm nontrapping-fptoint feature has been enabled by default. clang will
generate nontrapping (saturating) float-to-int conversion instructions for
C typecasts. This should have no effect on programs that do not have
undefined behavior but if the casted floating-point value is outside the range
of the target integer type, the result will be a number of the max or min value
instead of a trap. This also results in a small code size improvement because
of details of the LLVM IR semantics. This feature can be disabled in clang with
the -mno-nontrapping-fptoint flag. (#23007)
- The `WASM_BIGINT` feature has been enabled by default. This has the effect that
Wasm i64 values are passed and returned between Wasm and JS as BigInt values
rather than being split by Binaryen into pairs of Numbers. (#22993)
Expand Down
8 changes: 6 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ def get_clang_flags(user_args):
if not settings.BULK_MEMORY:
flags.append('-mno-bulk-memory')
flags.append('-mno-bulk-memory-opt')
if '-mnontrapping-fptoint' not in user_args and '-mno-nontrapping-fptoint' not in user_args:
flags.append('-mno-nontrapping-fptoint')

if settings.RELOCATABLE and '-fPIC' not in user_args:
flags.append('-fPIC')
Expand Down Expand Up @@ -1435,6 +1433,12 @@ def consume_arg_file():
override=True)
elif arg == '-mno-sign-ext':
feature_matrix.disable_feature(feature_matrix.Feature.SIGN_EXT)
elif arg == '-mnontrappting-fptoint':
feature_matrix.enable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT,
'-mnontrapping-fptoint',
override=True)
elif arg == '-mno-nontrapping-fptoint':
feature_matrix.disable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT)
elif arg == '-fexceptions':
# TODO Currently -fexceptions only means Emscripten EH. Switch to wasm
# exception handling by default when -fexceptions is given when wasm
Expand Down
12 changes: 9 additions & 3 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ FS.staticInit();
if (FS.isLink(node.mode)) {
return {{{ cDefs.ELOOP }}};
} else if (FS.isDir(node.mode)) {
if (FS.flagsToPermissionString(flags) !== 'r' || // opening for write
(flags & {{{ cDefs.O_TRUNC }}})) { // TODO: check for O_SEARCH? (== search for dir only)
if (FS.flagsToPermissionString(flags) !== 'r' // opening for write
|| (flags & ({{{ cDefs.O_TRUNC }}} | {{{ cDefs.O_CREAT }}}))) { // TODO: check for O_SEARCH? (== search for dir only)
return {{{ cDefs.EISDIR }}};
}
}
Expand Down Expand Up @@ -1087,7 +1087,10 @@ FS.staticInit();
throw new FS.ErrnoError({{{ cDefs.EISDIR }}});
} else {
// node doesn't exist, try to create it
node = FS.mknod(path, mode, 0);
// Ignore the permission bits here to ensure we can `open` this new
// file below. We use chmod below the apply the permissions once the
// file is open.
node = FS.mknod(path, mode | 0o777, 0);
created = true;
}
}
Expand Down Expand Up @@ -1137,6 +1140,9 @@ FS.staticInit();
if (stream.stream_ops.open) {
stream.stream_ops.open(stream);
}
if (created) {
FS.chmod(node, mode & 0o777);
}
#if expectToReceiveOnModule('logReadFiles')
if (Module['logReadFiles'] && !(flags & {{{ cDefs.O_WRONLY}}})) {
if (!(path in FS.readFiles)) {
Expand Down
2 changes: 1 addition & 1 deletion src/library_nodefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ addToLibrary({
}
return {
dev: stat.dev,
ino: stat.ino,
ino: node.id,
mode: stat.mode,
nlink: stat.nlink,
uid: stat.uid,
Expand Down
2 changes: 1 addition & 1 deletion src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ var LibraryPThread = {
'$runtimeKeepaliveCounter',
#endif
],
$invokeEntryPoint: {{{ asyncIf(ASYNCIFY == 2) }}} (ptr, arg) => {
$invokeEntryPoint: {{{ asyncIf(ASYNCIFY == 2) }}}(ptr, arg) => {
#if PTHREADS_DEBUG
dbg(`invokeEntryPoint: ${ptrToString(ptr)}`);
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/library_wasmfs_opfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ addToLibrary({

_wasmfs_opfs_read_access__i53abi: true,
_wasmfs_opfs_read_access__deps: ['$wasmfsOPFSAccessHandles'],
_wasmfs_opfs_read_access: {{{ asyncIf(!PTHREADS) }}} function(accessID, bufPtr, len, pos) {
_wasmfs_opfs_read_access: {{{ asyncIf(!PTHREADS) }}}function(accessID, bufPtr, len, pos) {
let accessHandle = wasmfsOPFSAccessHandles.get(accessID);
let data = HEAPU8.subarray(bufPtr, bufPtr + len);
try {
return {{{ awaitIf(!PTHREADS) }}} accessHandle.read(data, {at: pos});
return {{{ awaitIf(!PTHREADS) }}}accessHandle.read(data, {at: pos});
} catch (e) {
if (e.name == "TypeError") {
return -{{{ cDefs.EINVAL }}};
Expand Down Expand Up @@ -367,11 +367,11 @@ addToLibrary({

_wasmfs_opfs_write_access__i53abi: true,
_wasmfs_opfs_write_access__deps: ['$wasmfsOPFSAccessHandles'],
_wasmfs_opfs_write_access: {{{ asyncIf(!PTHREADS) }}} function(accessID, bufPtr, len, pos) {
_wasmfs_opfs_write_access: {{{ asyncIf(!PTHREADS) }}}function(accessID, bufPtr, len, pos) {
let accessHandle = wasmfsOPFSAccessHandles.get(accessID);
let data = HEAPU8.subarray(bufPtr, bufPtr + len);
try {
return {{{ awaitIf(!PTHREADS) }}} accessHandle.write(data, {at: pos});
return {{{ awaitIf(!PTHREADS) }}}accessHandle.write(data, {at: pos});
} catch (e) {
if (e.name == "TypeError") {
return -{{{ cDefs.EINVAL }}};
Expand Down
4 changes: 2 additions & 2 deletions src/parseTools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -972,11 +972,11 @@ function to64(x) {
}

function asyncIf(condition) {
return condition ? 'async' : '';
return condition ? 'async ' : '';
}

function awaitIf(condition) {
return condition ? 'await' : '';
return condition ? 'await ' : '';
}

// Adds a call to runtimeKeepalivePush, if needed by the current build
Expand Down
4 changes: 2 additions & 2 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ var mainArgs = undefined;

#if HAS_MAIN
#if MAIN_READS_PARAMS
{{{ asyncIf(ASYNCIFY == 2) }}} function callMain(args = []) {
{{{ asyncIf(ASYNCIFY == 2) }}}function callMain(args = []) {
#else
{{{ asyncIf(ASYNCIFY == 2) }}} function callMain() {
{{{ asyncIf(ASYNCIFY == 2) }}}function callMain() {
#endif
#if ASSERTIONS
assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
Expand Down
2 changes: 1 addition & 1 deletion src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ function getWasmImports() {

// Create the wasm instance.
// Receives the wasm imports, returns the exports.
{{{ asyncIf(WASM_ASYNC_COMPILATION) }}} function createWasm() {
{{{ asyncIf(WASM_ASYNC_COMPILATION) }}}function createWasm() {
// Load the wasm module and create an instance of using native support in the JS engine.
// handle a generated wasm instance, receiving its exports and
// performing other necessary setup
Expand Down
4 changes: 2 additions & 2 deletions src/runtime_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (ENVIRONMENT_IS_PTHREAD) {
// notified about them.
self.onunhandledrejection = (e) => { throw e.reason || e; };

{{{ asyncIf(ASYNCIFY == 2) }}} function handleMessage(e) {
{{{ asyncIf(ASYNCIFY == 2) }}}function handleMessage(e) {
try {
var msgData = e['data'];
//dbg('msgData: ' + Object.keys(msgData));
Expand Down Expand Up @@ -177,7 +177,7 @@ if (ENVIRONMENT_IS_PTHREAD) {
}

try {
{{{ awaitIf(ASYNCIFY == 2) }}} invokeEntryPoint(msgData.start_routine, msgData.arg);
{{{ awaitIf(ASYNCIFY == 2) }}}invokeEntryPoint(msgData.start_routine, msgData.arg);
} catch(ex) {
if (ex != 'unwind') {
// The pthread "crashed". Do not call `_emscripten_thread_exit` (which
Expand Down
2 changes: 1 addition & 1 deletion system/lib/wasmfs/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static __wasi_fd_t doOpen(path::ParsedParent parsed,
return -EEXIST;
}

if (child->is<Directory>() && accessMode != O_RDONLY) {
if (child->is<Directory>() && (accessMode != O_RDONLY || (flags & O_CREAT))) {
return -EISDIR;
}

Expand Down
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": 328,
"a.js": 4538,
"a.js.gz": 2320,
"a.wasm": 10402,
"a.wasm.gz": 6703,
"total": 15394,
"total_gz": 9351
"a.wasm": 10206,
"a.wasm.gz": 6663,
"total": 15198,
"total_gz": 9311
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 262,
"a.js": 22206,
"a.js.gz": 11589,
"total": 22552,
"total_gz": 11851
"a.js": 22202,
"a.js.gz": 11604,
"total": 22548,
"total_gz": 11866
}
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": 328,
"a.js": 4076,
"a.js.gz": 2163,
"a.wasm": 10402,
"a.wasm.gz": 6703,
"total": 14932,
"total_gz": 9194
"a.wasm": 10206,
"a.wasm.gz": 6663,
"total": 14736,
"total_gz": 9154
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 262,
"a.js": 21732,
"a.js.gz": 11419,
"total": 22078,
"total_gz": 11681
"a.js": 21728,
"a.js.gz": 11435,
"total": 22074,
"total_gz": 11697
}
8 changes: 4 additions & 4 deletions test/code_size/math_wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"a.html.gz": 380,
"a.js": 110,
"a.js.gz": 125,
"a.wasm": 2719,
"a.wasm.gz": 1675,
"total": 3381,
"total_gz": 2180
"a.wasm": 2695,
"a.wasm.gz": 1664,
"total": 3357,
"total_gz": 2169
}
8 changes: 4 additions & 4 deletions test/code_size/random_printf_wasm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a.html": 12597,
"a.html.gz": 6882,
"total": 12597,
"total_gz": 6882
"a.html": 12517,
"a.html.gz": 6871,
"total": 12517,
"total_gz": 6871
}
4 changes: 2 additions & 2 deletions test/code_size/random_printf_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a.html": 17195,
"a.html.gz": 7478,
"a.html.gz": 7480,
"total": 17195,
"total_gz": 7478
"total_gz": 7480
}
15 changes: 2 additions & 13 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,27 +742,16 @@ def make_executable(name):


def make_dir_writeable(dirname):
# Ensure all files are readable and writable by the current user.
permission_bits = stat.S_IWRITE | stat.S_IREAD

def is_writable(path):
return (os.stat(path).st_mode & permission_bits) != permission_bits

def make_writable(path):
new_mode = os.stat(path).st_mode | permission_bits
os.chmod(path, new_mode)

# Some tests make files and subdirectories read-only, so rmtree/unlink will not delete
# them. Force-make everything writable in the subdirectory to make it
# removable and re-attempt.
if not is_writable(dirname):
make_writable(dirname)
os.chmod(dirname, 0o777)

for directory, subdirs, files in os.walk(dirname):
for item in files + subdirs:
i = os.path.join(directory, item)
if not os.path.islink(i):
make_writable(i)
os.chmod(i, 0o777)


def force_delete_dir(dirname):
Expand Down
5 changes: 0 additions & 5 deletions test/export_module.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/fcntl/test_fcntl_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void test() {
if ((flags & O_CREAT) && (flags & O_EXCL)) {
assert(!success);
assert(errno == EEXIST);
} else if ((flags & O_TRUNC) || i != 0 /*mode != O_RDONLY*/) {
} else if ((flags & O_TRUNC) || i != 0 /*mode != O_RDONLY*/ || (flags & O_CREAT)) {
assert(!success);
assert(errno == EISDIR);
} else {
Expand Down
16 changes: 8 additions & 8 deletions test/fcntl/test_fcntl_open.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,1
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,1
Expand Down Expand Up @@ -139,8 +139,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,9
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,9
Expand Down Expand Up @@ -259,8 +259,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,17
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,17
Expand Down Expand Up @@ -379,8 +379,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,25
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,25
Expand Down
Loading

0 comments on commit 5ee5731

Please sign in to comment.