mirror of https://github.com/pyodide/pyodide.git
Use emscripten 3.1.13 (#2679)
This commit is contained in:
parent
52f27f06ad
commit
c834085995
2
Makefile
2
Makefile
|
@ -172,7 +172,7 @@ clean:
|
|||
clean-python: clean
|
||||
make -C cpython clean
|
||||
|
||||
clean-all:
|
||||
clean-all: clean
|
||||
make -C emsdk clean
|
||||
make -C cpython clean-all
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export PYVERSION ?= 3.10.2
|
||||
# Note: when updating EMSCRIPTEN_VERSION make sure to update
|
||||
# the version number in the "uname" patch.
|
||||
export PYODIDE_EMSCRIPTEN_VERSION ?= 3.1.6
|
||||
export PYODIDE_EMSCRIPTEN_VERSION ?= 3.1.13
|
||||
|
||||
export PLATFORM_TRIPLET=wasm32-emscripten
|
||||
export SYSCONFIG_NAME=_sysconfigdata__emscripten_$(PLATFORM_TRIPLET)
|
||||
|
@ -99,7 +99,6 @@ export SIDE_MODULE_LDFLAGS= $(LDFLAGS_BASE) -s SIDE_MODULE=1
|
|||
export MAIN_MODULE_LDFLAGS= $(LDFLAGS_BASE) \
|
||||
-s MAIN_MODULE=1 \
|
||||
-s EXPORT_NAME="'_createPyodideModule'" \
|
||||
-s EXPORTED_FUNCTIONS='["___cxa_guard_acquire", "__ZNSt3__28ios_base4initEPv", "_main"]' \
|
||||
-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \
|
||||
-s DEMANGLE_SUPPORT=1 \
|
||||
-s USE_FREETYPE=1 \
|
||||
|
|
|
@ -34,3 +34,5 @@
|
|||
|
||||
#define CONFIG_32
|
||||
#define ANSI
|
||||
|
||||
#undef HAVE_MEMFD_CREATE
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
From c3e9df0738648c47cd3246a491cc324bf2afa2c5 Mon Sep 17 00:00:00 2001
|
||||
From 314d9d1c6405cc197a2022d3176a225c9d70b9e9 Mon Sep 17 00:00:00 2001
|
||||
From: Hood <hood@mit.edu>
|
||||
Date: Thu, 24 Jun 2021 04:08:02 -0700
|
||||
Subject: [PATCH 1/8] Throw away errors in minify_wasm_js
|
||||
Subject: [PATCH 1/4] Throw away errors in minify_wasm_js
|
||||
|
||||
---
|
||||
emcc.py | 13 ++++++++-----
|
||||
1 file changed, 8 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/emcc.py b/emcc.py
|
||||
index 81da47f68..f1550ed96 100755
|
||||
index d67aa5414..b97321cde 100755
|
||||
--- a/emcc.py
|
||||
+++ b/emcc.py
|
||||
@@ -3326,11 +3326,14 @@ def phase_binaryen(target, options, wasm_target):
|
||||
@@ -3409,11 +3409,14 @@ def phase_binaryen(target, options, wasm_target):
|
||||
# Closure can print out readable error messages (Closure will then
|
||||
# minify whitespace afterwards)
|
||||
save_intermediate_with_wasm('preclean', wasm_target)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From cff825cdcba9e0571e5a025b5878fb82d3d79e17 Mon Sep 17 00:00:00 2001
|
||||
From 458c78230e6dd45d724b04904f15628c570ae904 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Wed, 8 Jun 2022 19:08:18 -0700
|
||||
Subject: [PATCH 6/8] Add BigInt64Array shim for Safari 14
|
||||
Subject: [PATCH 2/4] Add BigInt64Array shim for Safari 14
|
||||
|
||||
---
|
||||
src/polyfill/bigint64array.js | 94 +++++++++++++++++++++++++++++++++++
|
||||
|
@ -112,10 +112,10 @@ index 000000000..448a2d2a4
|
|||
+ var BigInt64Array = createBigIntArrayShim(partsToBigIntSigned);
|
||||
+}
|
||||
diff --git a/src/preamble.js b/src/preamble.js
|
||||
index 430ac5568..62f215ab4 100644
|
||||
index ce24d8456..618ccd2ac 100644
|
||||
--- a/src/preamble.js
|
||||
+++ b/src/preamble.js
|
||||
@@ -267,7 +267,7 @@ function updateGlobalBufferAndViews(buf) {
|
||||
@@ -297,7 +297,7 @@ function updateGlobalBufferAndViews(buf) {
|
||||
#if WASM_BIGINT
|
||||
Module['HEAP64'] = HEAP64 = new BigInt64Array(buf);
|
||||
Module['HEAPU64'] = HEAPU64 = new BigUint64Array(buf);
|
||||
|
@ -125,10 +125,10 @@ index 430ac5568..62f215ab4 100644
|
|||
|
||||
var TOTAL_STACK = {{{ TOTAL_STACK }}};
|
||||
diff --git a/src/settings.js b/src/settings.js
|
||||
index a3d45c7a3..162d026e5 100644
|
||||
index 1a8b7f1fe..be5964519 100644
|
||||
--- a/src/settings.js
|
||||
+++ b/src/settings.js
|
||||
@@ -1334,6 +1334,10 @@ var DYNCALLS = 0;
|
||||
@@ -1341,6 +1341,10 @@ var DYNCALLS = false;
|
||||
// WebAssembly integration with JavaScript BigInt. When enabled we don't need
|
||||
// to legalize i64s into pairs of i32s, as the wasm VM will use a BigInt where
|
||||
// an i64 is used.
|
||||
|
@ -137,10 +137,10 @@ index a3d45c7a3..162d026e5 100644
|
|||
+// with Safari >= v14.0, in that case Emscripten will polyfill BigInt64Array.
|
||||
+// Use `-sMIN_SAFARI_VERSION=140000` to request this.
|
||||
// [link]
|
||||
var WASM_BIGINT = 0;
|
||||
var WASM_BIGINT = false;
|
||||
|
||||
diff --git a/src/shell.js b/src/shell.js
|
||||
index 021d7cf5f..774a7f411 100644
|
||||
index 22fac7f69..9d7558340 100644
|
||||
--- a/src/shell.js
|
||||
+++ b/src/shell.js
|
||||
@@ -51,7 +51,12 @@ var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {
|
|
@ -1,31 +0,0 @@
|
|||
From e9f1c08431ed75bc1bf5bb949bc409d3407d0bef Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Wed, 2 Mar 2022 13:44:14 -0800
|
||||
Subject: [PATCH 2/8] Fix lookupPath when applied to a symlink loop
|
||||
|
||||
The following code leads to an infinite loop in lookupPath:
|
||||
|
||||
FS.symlink("linkX/inside","/linkX");
|
||||
FS.lookupPath("/linkX", {follow:true});
|
||||
|
||||
This patch fixes it.
|
||||
---
|
||||
src/library_fs.js | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/library_fs.js b/src/library_fs.js
|
||||
index bc5cc412c..d722d7449 100644
|
||||
--- a/src/library_fs.js
|
||||
+++ b/src/library_fs.js
|
||||
@@ -166,7 +166,7 @@ FS.staticInit();` +
|
||||
var link = FS.readlink(current_path);
|
||||
current_path = PATH_FS.resolve(PATH.dirname(current_path), link);
|
||||
|
||||
- var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
|
||||
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count + 1 });
|
||||
current = lookup.node;
|
||||
|
||||
if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
From cedb7b1a5a341103707da7fbea435a7f4ed719f1 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Wed, 8 Jun 2022 22:06:54 -0700
|
||||
Subject: [PATCH 3/4] Fix dup again
|
||||
|
||||
---
|
||||
src/library_fs.js | 40 ++++++++++++++++++++++++++--------------
|
||||
1 file changed, 26 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/library_fs.js b/src/library_fs.js
|
||||
index 88f3bd98c..693a1988a 100644
|
||||
--- a/src/library_fs.js
|
||||
+++ b/src/library_fs.js
|
||||
@@ -400,32 +400,44 @@ FS.staticInit();` +
|
||||
// SOCKFS is completed.
|
||||
createStream: (stream, fd_start, fd_end) => {
|
||||
if (!FS.FSStream) {
|
||||
- FS.FSStream = /** @constructor */ function() {
|
||||
- this.shared = { };
|
||||
+ FS.FSStream = function FSStream() {
|
||||
+ this.shared = {flags : 0, position : 0};
|
||||
};
|
||||
- FS.FSStream.prototype = {
|
||||
+ FS.FSStream.prototype = Object.create(Object.prototype);
|
||||
+ FS.FSStream.prototype.constructor = FS.FSStream;
|
||||
+ Object.defineProperties(FS.FSStream.prototype, {
|
||||
object: {
|
||||
- get: function() { return this.node; },
|
||||
- set: function(val) { this.node = val; }
|
||||
+ get: function () {
|
||||
+ return this.node;
|
||||
+ },
|
||||
+ set: function (val) {
|
||||
+ this.node = val;
|
||||
+ },
|
||||
+ enumerable : true,
|
||||
},
|
||||
isRead: {
|
||||
- get: function() { return (this.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; }
|
||||
+ get: function() { return (this.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; },
|
||||
+ enumerable : true,
|
||||
},
|
||||
isWrite: {
|
||||
- get: function() { return (this.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; }
|
||||
+ get: function() { return (this.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; },
|
||||
+ enumerable : true,
|
||||
},
|
||||
isAppend: {
|
||||
- get: function() { return (this.flags & {{{ cDefine('O_APPEND') }}}); }
|
||||
+ get: function() { return (this.flags & {{{ cDefine('O_APPEND') }}}); },
|
||||
+ enumerable : true,
|
||||
},
|
||||
flags: {
|
||||
- get: function() { return this.shared.flags; },
|
||||
- set: function(val) { this.shared.flags = val; },
|
||||
+ get: function () { return this.shared.flags; },
|
||||
+ set: function (val) { this.shared.flags = val; },
|
||||
+ enumerable : true,
|
||||
},
|
||||
- position : {
|
||||
- get function() { return this.shared.position; },
|
||||
- set: function(val) { this.shared.position = val; },
|
||||
+ position: {
|
||||
+ get: function() { return this.shared.position; },
|
||||
+ set: function (val) { this.shared.position = val; },
|
||||
+ enumerable : true,
|
||||
},
|
||||
- };
|
||||
+ });
|
||||
}
|
||||
// clone it, so we can return an instance of FSStream
|
||||
stream = Object.assign(new FS.FSStream(), stream);
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
From 9fead8aabbf3418ac1422cd4867815f9eb49e6e6 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Heimes <christian@python.org>
|
||||
Date: Thu, 10 Mar 2022 18:30:11 +0200
|
||||
Subject: [PATCH 3/8] Fix utime() syscall (#16460)
|
||||
|
||||
Fix off by factor 1000: ``FS.utime()`` expects mtime and atime in seconds.
|
||||
|
||||
``times == NULL`` is now correctly handled. ``utimes(path, NULL)``
|
||||
updates atime and mtime to current time.
|
||||
|
||||
https://nodejs.org/api/fs.html#fsutimespath-atime-mtime-callback
|
||||
|
||||
Fixes: #16458
|
||||
Signed-off-by: Christian Heimes <christian@python.org>
|
||||
---
|
||||
src/library_noderawfs.js | 2 +-
|
||||
src/library_syscall.js | 19 ++++++++++++-------
|
||||
system/lib/wasmfs/syscalls.cpp | 14 +++++++++++---
|
||||
tests/utime/test_utime.c | 27 +++++++++++++++++++++++----
|
||||
4 files changed, 47 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/library_noderawfs.js b/src/library_noderawfs.js
|
||||
index 78f995830..f252e3a64 100644
|
||||
--- a/src/library_noderawfs.js
|
||||
+++ b/src/library_noderawfs.js
|
||||
@@ -81,7 +81,7 @@ mergeInto(LibraryManager.library, {
|
||||
}
|
||||
fs.ftruncateSync.apply(void 0, arguments);
|
||||
},
|
||||
- utime: function() { fs.utimesSync.apply(void 0, arguments); },
|
||||
+ utime: function(path, atime, mtime) { fs.utimesSync(path, atime/1000, mtime/1000); },
|
||||
open: function(path, flags, mode, suggestFD) {
|
||||
if (typeof flags == "string") {
|
||||
flags = VFS.modeStringToFlags(flags)
|
||||
diff --git a/src/library_syscall.js b/src/library_syscall.js
|
||||
index 8a59a0442..072d4cde3 100644
|
||||
--- a/src/library_syscall.js
|
||||
+++ b/src/library_syscall.js
|
||||
@@ -1046,13 +1046,18 @@ var SyscallsLibrary = {
|
||||
assert(flags === 0);
|
||||
#endif
|
||||
path = SYSCALLS.calculateAt(dirfd, path, true);
|
||||
- var seconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_sec, 'i32') }}};
|
||||
- var nanoseconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_nsec, 'i32') }}};
|
||||
- var atime = (seconds*1000) + (nanoseconds/(1000*1000));
|
||||
- times += {{{ C_STRUCTS.timespec.__size__ }}};
|
||||
- seconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_sec, 'i32') }}};
|
||||
- nanoseconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_nsec, 'i32') }}};
|
||||
- var mtime = (seconds*1000) + (nanoseconds/(1000*1000));
|
||||
+ if (!times) {
|
||||
+ var atime = Date.now();
|
||||
+ var mtime = atime;
|
||||
+ } else {
|
||||
+ var seconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_sec, 'i32') }}};
|
||||
+ var nanoseconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_nsec, 'i32') }}};
|
||||
+ atime = (seconds*1000) + (nanoseconds/(1000*1000));
|
||||
+ times += {{{ C_STRUCTS.timespec.__size__ }}};
|
||||
+ seconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_sec, 'i32') }}};
|
||||
+ nanoseconds = {{{ makeGetValue('times', C_STRUCTS.timespec.tv_nsec, 'i32') }}};
|
||||
+ mtime = (seconds*1000) + (nanoseconds/(1000*1000));
|
||||
+ }
|
||||
FS.utime(path, atime, mtime);
|
||||
return 0;
|
||||
},
|
||||
diff --git a/system/lib/wasmfs/syscalls.cpp b/system/lib/wasmfs/syscalls.cpp
|
||||
index a004b02dd..48f9b4677 100644
|
||||
--- a/system/lib/wasmfs/syscalls.cpp
|
||||
+++ b/system/lib/wasmfs/syscalls.cpp
|
||||
@@ -992,9 +992,17 @@ long __syscall_utimensat(int dirFD,
|
||||
return err;
|
||||
}
|
||||
|
||||
- // TODO: tv_nsec (nanoseconds) as well? but time_t is seconds as an integer
|
||||
- auto aSeconds = times[0].tv_sec;
|
||||
- auto mSeconds = times[1].tv_sec;
|
||||
+ // TODO: Set tv_nsec (nanoseconds) as well.
|
||||
+ // TODO: Handle tv_nsec being UTIME_NOW or UTIME_OMIT.
|
||||
+ // TODO: Check for write access to the file (see man page for specifics).
|
||||
+ time_t aSeconds, mSeconds;
|
||||
+ if (times == NULL) {
|
||||
+ aSeconds = time(NULL);
|
||||
+ mSeconds = aSeconds;
|
||||
+ } else {
|
||||
+ aSeconds = times[0].tv_sec;
|
||||
+ mSeconds = times[1].tv_sec;
|
||||
+ }
|
||||
|
||||
auto locked = parsedPath.child->locked();
|
||||
locked.setATime(aSeconds);
|
||||
diff --git a/tests/utime/test_utime.c b/tests/utime/test_utime.c
|
||||
index b0f28bc4d..3a04100ce 100644
|
||||
--- a/tests/utime/test_utime.c
|
||||
+++ b/tests/utime/test_utime.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -32,20 +33,38 @@ void test() {
|
||||
// will fail
|
||||
struct utimbuf t = {1000000000, 1000000000};
|
||||
|
||||
- utime("writeable", &t);
|
||||
+ errno = 0;
|
||||
+ int rv = utime("writeable", &t);
|
||||
+ assert(rv == 0);
|
||||
assert(!errno);
|
||||
memset(&s, 0, sizeof s);
|
||||
- stat("writeable", &s);
|
||||
+ rv = stat("writeable", &s);
|
||||
+ assert(rv == 0);
|
||||
assert(s.st_atime == t.actime);
|
||||
assert(s.st_mtime == t.modtime);
|
||||
|
||||
+ // NULL sets atime and mtime to current time.
|
||||
+ long now = time(NULL);
|
||||
+ rv = utime("writeable", NULL);
|
||||
+ assert(rv == 0);
|
||||
+ memset(&s, 0, sizeof s);
|
||||
+ stat("writeable", &s);
|
||||
+ assert(s.st_atime == s.st_mtime);
|
||||
+ long diff = s.st_atime - now;
|
||||
+ if (abs(diff) > 5) {
|
||||
+ fprintf(stderr, "st_atime: %li, now: %li, diff: %li\n ", s.st_atime, now, diff);
|
||||
+ assert(abs(diff) <= 5);
|
||||
+ }
|
||||
+
|
||||
// write permissions aren't checked when setting node
|
||||
// attributes unless the user uid isn't the owner (so
|
||||
// therefor, this should work fine)
|
||||
- utime("unwriteable", &t);
|
||||
+ rv = utime("unwriteable", &t);
|
||||
+ assert(rv == 0);
|
||||
assert(!errno);
|
||||
memset(&s, 0, sizeof s);
|
||||
- stat("unwriteable", &s);
|
||||
+ rv = stat("unwriteable", &s);
|
||||
+ assert(rv == 0);
|
||||
assert(s.st_atime == t.actime);
|
||||
assert(s.st_mtime == t.modtime);
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
From b4140512b840263ca2f44f0b639e67b0928db601 Mon Sep 17 00:00:00 2001
|
||||
From c250eb29047c4341cdc1d13f3706eb6991cf0f9b Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Thu, 6 Jan 2022 09:40:39 -0800
|
||||
Subject: [PATCH 7/8] Disable whole-archive when linking rust
|
||||
Subject: [PATCH 4/4] Disable whole-archive when linking rust
|
||||
|
||||
Rust .rlib archives contain an extra metadata file called lib.rmeta.
|
||||
Emscripten sets `--whole-archive` by default if LINKABLE is set.
|
||||
|
@ -16,10 +16,10 @@ https://github.com/emscripten-core/emscripten/issues/17109
|
|||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tools/building.py b/tools/building.py
|
||||
index c69f9ec56..5de0b50ce 100644
|
||||
index 24ddaa13f..cb015e18f 100644
|
||||
--- a/tools/building.py
|
||||
+++ b/tools/building.py
|
||||
@@ -372,7 +372,7 @@ def link_lld(args, target, external_symbols=None):
|
||||
@@ -360,7 +360,7 @@ def link_lld(args, target, external_symbols=None):
|
||||
|
||||
# Emscripten currently expects linkable output (SIDE_MODULE/MAIN_MODULE) to
|
||||
# include all archive contents.
|
|
@ -1,91 +0,0 @@
|
|||
From d1ddf4947fa923219a388540605420916375f8a5 Mon Sep 17 00:00:00 2001
|
||||
From: Hood <hood@mit.edu>
|
||||
Date: Wed, 8 Sep 2021 17:49:15 -0700
|
||||
Subject: [PATCH 4/8] Fix dup
|
||||
|
||||
This fixes two problems with the `dup` system calls:
|
||||
1. `dup` expects that every file descriptor has a corresponding file (so pipes and (https://github.com/emscripten-core/emscripten/issues/14640)
|
||||
files that have been unlinked (https://github.com/emscripten-core/emscripten/issues/15012) cannot be duplicated ).
|
||||
2. The dup'd file descriptor does not share flags and position with the original file desciptor.
|
||||
|
||||
This is a simplification of an upstream pull request that would fix this problem.
|
||||
https://github.com/emscripten-core/emscripten/pull/9396/files
|
||||
This patch is simpler than the upstream one but leaves NODERAWFS broken.
|
||||
---
|
||||
src/library_fs.js | 8 ++++++--
|
||||
src/library_syscall.js | 10 +++++-----
|
||||
2 files changed, 11 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/library_fs.js b/src/library_fs.js
|
||||
index d722d7449..47da3c67c 100644
|
||||
--- a/src/library_fs.js
|
||||
+++ b/src/library_fs.js
|
||||
@@ -404,7 +404,7 @@ FS.staticInit();` +
|
||||
// SOCKFS is completed.
|
||||
createStream: (stream, fd_start, fd_end) => {
|
||||
if (!FS.FSStream) {
|
||||
- FS.FSStream = /** @constructor */ function(){};
|
||||
+ FS.FSStream = /** @constructor */ function(){ this.shared = {}; };
|
||||
FS.FSStream.prototype = {
|
||||
object: {
|
||||
get: function() { return this.node; },
|
||||
@@ -418,7 +418,11 @@ FS.staticInit();` +
|
||||
},
|
||||
isAppend: {
|
||||
get: function() { return (this.flags & {{{ cDefine('O_APPEND') }}}); }
|
||||
- }
|
||||
+ },
|
||||
+ get flags() { return this.shared.flags; },
|
||||
+ set flags(value) { this.shared.flags = value; },
|
||||
+ get position() { return this.shared.position; },
|
||||
+ set position(value) { this.shared.position = value; },
|
||||
};
|
||||
}
|
||||
// clone it, so we can return an instance of FSStream
|
||||
diff --git a/src/library_syscall.js b/src/library_syscall.js
|
||||
index 072d4cde3..47eab24aa 100644
|
||||
--- a/src/library_syscall.js
|
||||
+++ b/src/library_syscall.js
|
||||
@@ -131,10 +131,10 @@ var SyscallsLibrary = {
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
- doDup: function(path, flags, suggestFD) {
|
||||
+ doDup: function(stream, suggestFD, flags) {
|
||||
var suggest = FS.getStream(suggestFD);
|
||||
if (suggest) FS.close(suggest);
|
||||
- return FS.open(path, flags, 0, suggestFD, suggestFD).fd;
|
||||
+ return FS.createStream(stream, suggestFD, suggestFD).fd;
|
||||
},
|
||||
doReadv: function(stream, iov, iovcnt, offset) {
|
||||
var ret = 0;
|
||||
@@ -303,7 +303,7 @@ var SyscallsLibrary = {
|
||||
},
|
||||
__syscall_dup: function(fd) {
|
||||
var old = SYSCALLS.getStreamFromFD(fd);
|
||||
- return FS.open(old.path, old.flags, 0).fd;
|
||||
+ return FS.createStream(old, 0).fd;
|
||||
},
|
||||
__syscall_pipe__deps: ['$PIPEFS'],
|
||||
__syscall_pipe: function(fdPtr) {
|
||||
@@ -853,7 +853,7 @@ var SyscallsLibrary = {
|
||||
return -{{{ cDefine('EINVAL') }}};
|
||||
}
|
||||
var newStream;
|
||||
- newStream = FS.open(stream.path, stream.flags, 0, arg);
|
||||
+ newStream = FS.createStream(stream, arg);
|
||||
return newStream.fd;
|
||||
}
|
||||
case {{{ cDefine('F_GETFD') }}}:
|
||||
@@ -1077,7 +1077,7 @@ var SyscallsLibrary = {
|
||||
assert(!flags);
|
||||
#endif
|
||||
if (old.fd === suggestFD) return -{{{ cDefine('EINVAL') }}};
|
||||
- return SYSCALLS.doDup(old.path, old.flags, suggestFD);
|
||||
+ return SYSCALLS.doDup(old, suggestFD, flags);
|
||||
},
|
||||
};
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
From 03a31e67f42161ed920e9a8a00094ce2d49fd667 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Clegg <sbc@chromium.org>
|
||||
Date: Mon, 23 May 2022 15:25:21 -0700
|
||||
Subject: [PATCH 5/8] Fix version reported by uname (#17026)
|
||||
|
||||
Fixes: #16977
|
||||
---
|
||||
system/lib/libc/emscripten_syscall_stubs.c | 10 +++++++++-
|
||||
tests/core/test_uname.out | 2 +-
|
||||
tests/test_core.py | 2 +-
|
||||
3 files changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/system/lib/libc/emscripten_syscall_stubs.c b/system/lib/libc/emscripten_syscall_stubs.c
|
||||
index 0a59d1a3d..68b1a2f11 100644
|
||||
--- a/system/lib/libc/emscripten_syscall_stubs.c
|
||||
+++ b/system/lib/libc/emscripten_syscall_stubs.c
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <time.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <emscripten/console.h>
|
||||
+#include <emscripten/version.h>
|
||||
|
||||
static int g_pid = 42;
|
||||
static int g_pgid = 42;
|
||||
@@ -42,15 +43,22 @@ static mode_t g_umask = S_IRWXU | S_IRWXG | S_IRWXO;
|
||||
return -ENOSYS; \
|
||||
}
|
||||
|
||||
+#define STRINGIFY(s) #s
|
||||
+#define STR(s) STRINGIFY(s)
|
||||
+
|
||||
long __syscall_uname(long buf) {
|
||||
if (!buf) {
|
||||
return -EFAULT;
|
||||
}
|
||||
+ const char* full_version = STR(__EMSCRIPTEN_major__) "." \
|
||||
+ STR(__EMSCRIPTEN_minor__) "." \
|
||||
+ STR(__EMSCRIPTEN_tiny__);
|
||||
+
|
||||
struct utsname *utsname = (struct utsname *)buf;
|
||||
|
||||
strcpy(utsname->sysname, "Emscripten");
|
||||
strcpy(utsname->nodename, "emscripten");
|
||||
- strcpy(utsname->release, "1.0");
|
||||
+ strcpy(utsname->release, full_version);
|
||||
strcpy(utsname->version, "#1");
|
||||
#ifdef __wams64__
|
||||
strcpy(utsname->machine, "wasm64");
|
||||
diff --git a/tests/core/test_uname.out b/tests/core/test_uname.out
|
||||
index 879d445a3..3806f84db 100644
|
||||
--- a/tests/core/test_uname.out
|
||||
+++ b/tests/core/test_uname.out
|
||||
@@ -1,6 +1,6 @@
|
||||
ret: 0
|
||||
sysname: Emscripten
|
||||
nodename: emscripten
|
||||
-release: 1.0
|
||||
+release: \d+.\d+.\d+
|
||||
version: #1
|
||||
machine: wasm32
|
||||
diff --git a/tests/test_core.py b/tests/test_core.py
|
||||
index c334c8398..5800b6a72 100644
|
||||
--- a/tests/test_core.py
|
||||
+++ b/tests/test_core.py
|
||||
@@ -5773,7 +5773,7 @@ Module['onRuntimeInitialized'] = function() {
|
||||
self.do_core_test('test_posixtime.c')
|
||||
|
||||
def test_uname(self):
|
||||
- self.do_core_test('test_uname.c')
|
||||
+ self.do_core_test('test_uname.c', regex=True)
|
||||
|
||||
def test_unary_literal(self):
|
||||
self.do_core_test('test_unary_literal.cpp')
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
From 65d4028693bd59bfe75813043b2470342c6a5fe5 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Wed, 1 Jun 2022 10:54:08 -0700
|
||||
Subject: [PATCH 8/8] Add signature to emscripten_get_now
|
||||
|
||||
Upstream PR:
|
||||
https://github.com/emscripten-core/emscripten/pull/17123/files
|
||||
---
|
||||
src/library.js | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/library.js b/src/library.js
|
||||
index b1947fc69..65bd4718c 100644
|
||||
--- a/src/library.js
|
||||
+++ b/src/library.js
|
||||
@@ -2405,6 +2405,7 @@ LibraryManager.library = {
|
||||
},
|
||||
|
||||
emscripten_get_now__import: true,
|
||||
+ emscripten_get_now__sig: 'd',
|
||||
emscripten_get_now: ';' +
|
||||
#if ENVIRONMENT_MAY_BE_NODE
|
||||
"if (ENVIRONMENT_IS_NODE) {\n" +
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#include "jsproxy.h"
|
||||
#include "pyproxy.h"
|
||||
#include <emscripten.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static PyObject* tbmod = NULL;
|
||||
|
||||
|
@ -15,13 +16,12 @@ _Py_IDENTIFIER(last_value);
|
|||
_Py_IDENTIFIER(last_traceback);
|
||||
|
||||
void
|
||||
_Py_DumpTraceback(int fd, void* tstate);
|
||||
_Py_DumpTraceback(int fd, PyThreadState* tstate);
|
||||
|
||||
// We need this b/c otherwise Emscripten will eliminate the symbol.
|
||||
EMSCRIPTEN_KEEPALIVE void
|
||||
dump_traceback(int fd, void* tstate)
|
||||
dump_traceback()
|
||||
{
|
||||
_Py_DumpTraceback(fd, tstate);
|
||||
_Py_DumpTraceback(fileno(stdout), PyGILState_GetThisThreadState());
|
||||
}
|
||||
|
||||
EM_JS(void, console_error, (char* msg), {
|
||||
|
|
|
@ -4,16 +4,6 @@ declare var Hiwire: any;
|
|||
declare var API: any;
|
||||
declare var Tests: any;
|
||||
|
||||
/**
|
||||
* Dump the Python traceback to the browser console.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
API.dump_traceback = function () {
|
||||
const fd_stdout = 1;
|
||||
Module._dump_traceback(fd_stdout, Module._PyGILState_GetThisThreadState());
|
||||
};
|
||||
|
||||
function ensureCaughtObjectIsError(e: any): Error {
|
||||
if (typeof e === "string") {
|
||||
// Sometimes emscripten throws a raw string...
|
||||
|
@ -90,7 +80,7 @@ API.fatal_error = function (e: any) {
|
|||
console.error(e);
|
||||
}
|
||||
try {
|
||||
API.dump_traceback();
|
||||
Module._dump_traceback();
|
||||
for (let key of Object.keys(API.public_api)) {
|
||||
if (key.startsWith("_") || key === "version") {
|
||||
continue;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <emscripten.h>
|
||||
#include <exception>
|
||||
#include <typeinfo>
|
||||
using namespace std;
|
||||
|
@ -5,16 +6,19 @@ using namespace std;
|
|||
extern "C"
|
||||
{
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
const char* exc_what(exception& e)
|
||||
{
|
||||
return e.what();
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
const std::type_info* exc_type()
|
||||
{
|
||||
return &typeid(exception);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
const char* exc_typename(std::type_info* type)
|
||||
{
|
||||
return type->name();
|
||||
|
|
|
@ -3,3 +3,6 @@ Module.UTF8ToString = UTF8ToString;
|
|||
Module.wasmTable = wasmTable;
|
||||
// Emscripten has a bug where it accidentally exposes an empty object as Module.ERRNO_CODES
|
||||
Module.ERRNO_CODES = ERRNO_CODES;
|
||||
// preloadedWasm isn't exposed on Module by default anymore. TODO: We should use
|
||||
// a less hacky approach via the fs argument to loadDynamicLibrary
|
||||
Module.preloadedWasm = preloadedWasm;
|
||||
|
|
Loading…
Reference in New Issue