Skip to content

Commit 9d0c79a

Browse files
committed
Merge branch 'main' into anonymous-file-descriptors
2 parents 6a4dfc2 + a6ecc86 commit 9d0c79a

File tree

185 files changed

+797
-994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+797
-994
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ jobs:
799799
EMTEST_SKIP_NODE_CANARY: "1"
800800
EMTEST_SKIP_RUST: "1"
801801
EMTEST_SKIP_WASM64: "1"
802+
EMTEST_SKIP_NEW_CMAKE: "1"
802803
steps:
803804
- install-rust
804805
- run: apt-get install -q -y ninja-build scons ccache

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.74 (in development)
2222
-----------------------
23+
- The file system was updated to independently track atime, mtime and ctime
24+
instead of using the same time for all three. (#22998)
25+
- The minimum supported chrome version was bumped from 32 to 33. (#23077)
2326

2427
3.1.73 - 11/28/24
2528
-----------------

cmake/Modules/Platform/Emscripten.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1)
279279
set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@")
280280
set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")
281281

282+
# Enable $<LINK_LIBRARY:WHOLE_ARCHIVE,static_lib> for CMake 3.24+
283+
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "-Wl,--whole-archive" "<LINK_ITEM>" "-Wl,--no-whole-archive")
284+
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED True)
285+
282286
# Set a global EMSCRIPTEN variable that can be used in client CMakeLists.txt to
283287
# detect when building using Emscripten.
284288
set(EMSCRIPTEN 1 CACHE INTERNAL "If true, we are targeting Emscripten output.")

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2939,7 +2939,7 @@ This setting also applies to modern Chromium-based Edge, which shares version
29392939
numbers with Chrome.
29402940
Chrome 85 was released on 2020-08-25.
29412941
MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported.
2942-
Minimum supported value is 32, which was released on 2014-01-04.
2942+
Minimum supported value is 33, which was released on 2014-02-18.
29432943

29442944
Default value: 85
29452945

src/library.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,25 +2182,19 @@ addToLibrary({
21822182
},
21832183

21842184
$asyncLoad__docs: '/** @param {boolean=} noRunDep */',
2185-
$asyncLoad: (url, onload, onerror, noRunDep) => {
2186-
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
2187-
readAsync(url).then(
2188-
(arrayBuffer) => {
2189-
#if ASSERTIONS
2190-
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
2191-
#endif
2192-
onload(new Uint8Array(arrayBuffer));
2193-
if (dep) removeRunDependency(dep);
2194-
},
2195-
(err) => {
2196-
if (onerror) {
2197-
onerror();
2198-
} else {
2199-
throw `Loading data file "${url}" failed.`;
2200-
}
2201-
}
2202-
);
2203-
if (dep) addRunDependency(dep);
2185+
$asyncLoad: (url, noRunDep) => {
2186+
return new Promise((resolve, reject) => {
2187+
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
2188+
if (dep) addRunDependency(dep);
2189+
readAsync(url).then(
2190+
(arrayBuffer) => {
2191+
#if ASSERTIONS
2192+
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
2193+
#endif
2194+
resolve(new Uint8Array(arrayBuffer));
2195+
if (dep) removeRunDependency(dep);
2196+
}, reject);
2197+
});
22042198
},
22052199

22062200
$alignMemory: (size, alignment) => {

src/library_async.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ addToLibrary({
470470
emscripten_wget_data__async: true,
471471
emscripten_wget_data: (url, pbuffer, pnum, perror) => {
472472
return Asyncify.handleSleep((wakeUp) => {
473-
asyncLoad(UTF8ToString(url), (byteArray) => {
473+
/* no need for run dependency, this is async but will not do any prepare etc. step */
474+
asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => {
474475
// can only allocate the buffer after the wakeUp, not during an asyncing
475476
var buffer = _malloc(byteArray.length); // must be freed by caller!
476477
HEAPU8.set(byteArray, buffer);
@@ -481,7 +482,7 @@ addToLibrary({
481482
}, () => {
482483
{{{ makeSetValue('perror', 0, '1', 'i32') }}};
483484
wakeUp();
484-
}, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
485+
});
485486
});
486487
},
487488

@@ -519,9 +520,7 @@ addToLibrary({
519520
var imports = {'primary': wasmExports};
520521
// Replace '.wasm' suffix with '.deferred.wasm'.
521522
var deferred = wasmBinaryFile.slice(0, -5) + '.deferred.wasm';
522-
await new Promise((resolve) => {
523-
instantiateAsync(null, deferred, imports, resolve);
524-
});
523+
await instantiateAsync(null, deferred, imports);
525524
},
526525

527526
$Fibers__deps: ['$Asyncify', 'emscripten_stack_set_limits', '$stackRestore'],

src/library_dylink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ var LibraryDylink = {
10241024

10251025
var libFile = locateFile(libName);
10261026
if (flags.loadAsync) {
1027-
return new Promise((resolve, reject) => asyncLoad(libFile, resolve, reject));
1027+
return asyncLoad(libFile);
10281028
}
10291029

10301030
// load the binary synchronously

src/library_fs.js

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ FS.staticInit();
146146
this.name = name;
147147
this.mode = mode;
148148
this.rdev = rdev;
149+
this.atime = this.mtime = this.ctime = Date.now();
149150
}
150151
get read() {
151152
return (this.mode & this.readMode) === this.readMode;
@@ -174,60 +175,46 @@ FS.staticInit();
174175
path = PATH_FS.resolve(path);
175176

176177
if (!path) return { path: '', node: null };
178+
opts.follow_mount ??= true
177179

178-
var defaults = {
179-
follow_mount: true,
180-
recurse_count: 0
181-
};
182-
opts = Object.assign(defaults, opts)
183-
184-
if (opts.recurse_count > 8) { // max recursive lookup of 8
185-
throw new FS.ErrnoError({{{ cDefs.ELOOP }}});
186-
}
187-
188-
// split the absolute path
189-
var parts = path.split('/').filter((p) => !!p);
180+
// limit max consecutive symlinks to 40 (SYMLOOP_MAX).
181+
linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
182+
// split the absolute path
183+
var parts = path.split('/').filter((p) => !!p);
190184

191-
// start at the root
192-
var current = FS.root;
193-
var current_path = '/';
185+
// start at the root
186+
var current = FS.root;
187+
var current_path = '/';
194188

195-
for (var i = 0; i < parts.length; i++) {
196-
var islast = (i === parts.length-1);
197-
if (islast && opts.parent) {
198-
// stop resolving
199-
break;
200-
}
189+
for (var i = 0; i < parts.length; i++) {
190+
var islast = (i === parts.length-1);
191+
if (islast && opts.parent) {
192+
// stop resolving
193+
break;
194+
}
201195

202-
current = FS.lookupNode(current, parts[i]);
203-
current_path = PATH.join2(current_path, parts[i]);
196+
current = FS.lookupNode(current, parts[i]);
197+
current_path = PATH.join2(current_path, parts[i]);
204198

205-
// jump to the mount's root node if this is a mountpoint
206-
if (FS.isMountpoint(current)) {
207-
if (!islast || (islast && opts.follow_mount)) {
199+
// jump to the mount's root node if this is a mountpoint
200+
if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) {
208201
current = current.mounted.root;
209202
}
210-
}
211-
212-
// by default, lookupPath will not follow a symlink if it is the final path component.
213-
// setting opts.follow = true will override this behavior.
214-
if (!islast || opts.follow) {
215-
var count = 0;
216-
while (FS.isLink(current.mode)) {
217-
var link = FS.readlink(current_path);
218-
current_path = PATH_FS.resolve(PATH.dirname(current_path), link);
219203

220-
var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count + 1 });
221-
current = lookup.node;
222-
223-
if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
224-
throw new FS.ErrnoError({{{ cDefs.ELOOP }}});
204+
// by default, lookupPath will not follow a symlink if it is the final path component.
205+
// setting opts.follow = true will override this behavior.
206+
if (FS.isLink(current.mode) && (!islast || opts.follow)) {
207+
if (!current.node_ops.readlink) {
208+
throw new FS.ErrnoError({{{ cDefs.ENOSYS }}});
225209
}
210+
var link = current.node_ops.readlink(current);
211+
path = PATH_FS.resolve(PATH.dirname(current_path), link, ...parts.slice(i + 1));
212+
continue linkloop;
226213
}
227214
}
215+
return { path: current_path, node: current };
228216
}
229-
230-
return { path: current_path, node: current };
217+
throw new FS.ErrnoError({{{ cDefs.ELOOP }}});
231218
},
232219
getPath(node) {
233220
var path;
@@ -372,6 +359,9 @@ FS.staticInit();
372359
return 0;
373360
},
374361
mayCreate(dir, name) {
362+
if (!FS.isDir(dir.mode)) {
363+
return {{{ cDefs.ENOTDIR }}};
364+
}
375365
try {
376366
var node = FS.lookupNode(dir, name);
377367
return {{{ cDefs.EEXIST }}};
@@ -964,7 +954,7 @@ FS.staticInit();
964954
}
965955
node.node_ops.setattr(node, {
966956
mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (node.mode & ~{{{ cDefs.S_IALLUGO }}}),
967-
timestamp: Date.now()
957+
ctime: Date.now()
968958
});
969959
},
970960
lchmod(path, mode) {
@@ -1068,7 +1058,8 @@ FS.staticInit();
10681058
var lookup = FS.lookupPath(path, { follow: true });
10691059
var node = lookup.node;
10701060
node.node_ops.setattr(node, {
1071-
timestamp: Math.max(atime, mtime)
1061+
atime: atime,
1062+
mtime: mtime
10721063
});
10731064
},
10741065
open(path, flags, mode = 0o666) {
@@ -1443,6 +1434,9 @@ FS.staticInit();
14431434
FS.mount({
14441435
mount() {
14451436
var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR | 0o777 }}}, {{{ cDefs.S_IXUGO }}});
1437+
node.stream_ops = {
1438+
llseek: MEMFS.stream_ops.llseek,
1439+
};
14461440
node.node_ops = {
14471441
lookup(parent, name) {
14481442
var fd = +name;
@@ -1451,9 +1445,15 @@ FS.staticInit();
14511445
parent: null,
14521446
mount: { mountpoint: 'fake' },
14531447
node_ops: { readlink: () => stream.path },
1448+
id: fd + 1,
14541449
};
14551450
ret.parent = ret; // make it look like a simple root node
14561451
return ret;
1452+
},
1453+
readdir() {
1454+
return Array.from(FS.streams.entries())
1455+
.filter(([k, v]) => v)
1456+
.map(([k, v]) => k.toString());
14571457
}
14581458
};
14591459
return node;
@@ -1670,7 +1670,7 @@ FS.staticInit();
16701670
buffer[offset+i] = result;
16711671
}
16721672
if (bytesRead) {
1673-
stream.node.timestamp = Date.now();
1673+
stream.node.atime = Date.now();
16741674
}
16751675
return bytesRead;
16761676
},
@@ -1683,7 +1683,7 @@ FS.staticInit();
16831683
}
16841684
}
16851685
if (length) {
1686-
stream.node.timestamp = Date.now();
1686+
stream.node.mtime = stream.node.ctime = Date.now();
16871687
}
16881688
return i;
16891689
}

src/library_fs_shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ addToLibrary({
7676
}
7777
addRunDependency(dep);
7878
if (typeof url == 'string') {
79-
asyncLoad(url, processData, onerror);
79+
asyncLoad(url).then(processData, onerror);
8080
} else {
8181
processData(url);
8282
}

src/library_lz4.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ addToLibrary({
7070
node.mode = mode;
7171
node.node_ops = LZ4.node_ops;
7272
node.stream_ops = LZ4.stream_ops;
73-
node.timestamp = (mtime || new Date).getTime();
73+
this.atime = this.mtime = this.ctime = (mtime || new Date).getTime();
7474
assert(LZ4.FILE_MODE !== LZ4.DIR_MODE);
7575
if (mode === LZ4.FILE_MODE) {
7676
node.size = contents.end - contents.start;
@@ -95,19 +95,18 @@ addToLibrary({
9595
gid: 0,
9696
rdev: 0,
9797
size: node.size,
98-
atime: new Date(node.timestamp),
99-
mtime: new Date(node.timestamp),
100-
ctime: new Date(node.timestamp),
98+
atime: new Date(node.atime),
99+
mtime: new Date(node.mtime),
100+
ctime: new Date(node.ctime),
101101
blksize: 4096,
102102
blocks: Math.ceil(node.size / 4096),
103103
};
104104
},
105105
setattr(node, attr) {
106-
if (attr.mode !== undefined) {
107-
node.mode = attr.mode;
108-
}
109-
if (attr.timestamp !== undefined) {
110-
node.timestamp = attr.timestamp;
106+
for (const key of ['mode', 'atime', 'mtime', 'ctime']) {
107+
if (attr[key]) {
108+
node[key] = attr[key];
109+
}
111110
}
112111
},
113112
lookup(parent, name) {

0 commit comments

Comments
 (0)