Skip to content

Commit eb7de01

Browse files
committed
Merge remote-tracking branch 'origin/main' into arsnyder16-fcoverage
2 parents 57521f8 + 279f298 commit eb7de01

28 files changed

+107
-86
lines changed

ChangeLog.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ See docs/process.md for more on how version tagging works.
4343
example, `-sEXPORTED_RUNTIME_METHODS=HEAP8,HEAPU32` (if you need `HEAP8` and
4444
`HEAPU32`). (#24079)
4545
- libjpeg port updated from 9c to 9f. (#24085)
46+
- Missing exports in EXPORTED_RUNTIME_METHODS will now error instead of warn.
4647

4748
4.0.6 - 03/26/25
4849
----------------

emcc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def run(args):
526526
args += shlex.split(EMCC_CFLAGS)
527527

528528
if DEBUG:
529-
logger.warning(f'invocation: {shared.shlex_join(args)} (in {os.getcwd()})')
529+
logger.warning(f'invocation: {shlex.join(args)} (in {os.getcwd()})')
530530

531531
# Strip args[0] (program name)
532532
args = args[1:]
@@ -596,7 +596,7 @@ def run(args):
596596
exit_with_error(f'unable to parse output of `{cmd}`:\n{proc.stderr}')
597597
parts = shlex.split(lines[0].replace('\\', '\\\\'))
598598
parts = [x for x in parts if x not in ['-c', '-o', '-v', '-emit-llvm'] and input_file not in x and temp_target not in x]
599-
print(shared.shlex_join(parts[1:]))
599+
print(shlex.join(parts[1:]))
600600
return 0
601601

602602
if '-dumpmachine' in args or '-print-target-triple' in args or '--print-target-triple' in args:

emcmake.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# found in the LICENSE file.
66

77
import os
8+
import shlex
89
import shutil
910
import sys
1011
from tools import shared
@@ -56,7 +57,7 @@ def has_substr(args, substr):
5657
print('emcmake: no compatible cmake generator found; Please install ninja or mingw32-make, or specify a generator explicitly using -G', file=sys.stderr)
5758
return 1
5859

59-
print('configure: ' + shared.shlex_join(args), file=sys.stderr)
60+
print(f'configure: {shlex.join(args)}', file=sys.stderr)
6061
try:
6162
shared.check_call(args)
6263
return 0

emconfigure.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
tests will work properly.
1717
"""
1818

19+
import shlex
1920
import sys
2021
from tools import building
2122
from tools import shared
@@ -47,7 +48,7 @@ def run():
4748
# compilation with emcc, but instead do builds natively with Clang. This
4849
# is a heuristic emulation that may or may not work.
4950
env['EMMAKEN_JUST_CONFIGURE'] = '1'
50-
print('configure: ' + shared.shlex_join(args), file=sys.stderr)
51+
print(f'configure: {shlex.join(args)}', file=sys.stderr)
5152
try:
5253
shared.check_call(args, env=env)
5354
return 0

src/lib/libegl.js

+2
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ var LibraryEGL = {
507507
eglGetError: () => EGL.errorCode,
508508

509509
// EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
510+
// The allocated strings are cached and never freed.
511+
eglQueryString__noleakcheck: true,
510512
eglQueryString__deps: ['$stringToNewUTF8'],
511513
eglQueryString__proxy: 'sync',
512514
eglQueryString: (display, name) => {

src/lib/libfs.js

+17-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: MIT
55
*/
66

7-
addToLibrary({
7+
var LibraryFS = {
88
$FS__deps: ['$randomFill', '$PATH', '$PATH_FS', '$TTY', '$MEMFS',
99
'$FS_createPreloadedFile',
1010
'$FS_modeStringToFlags',
@@ -38,9 +38,7 @@ addToLibrary({
3838
addAtExit('FS.quit();');
3939
return `
4040
FS.createPreloadedFile = FS_createPreloadedFile;
41-
FS.staticInit();
42-
// Set module methods based on EXPORTED_RUNTIME_METHODS
43-
{{{ EXPORTED_RUNTIME_METHODS.filter((func) => func.startsWith('FS_')).map((func) => "Module['" + func + "'] = FS." + func.slice(3) + ";\n").reduce((str, func) => str + func, '') }}}`;
41+
FS.staticInit();`;
4442
},
4543
$FS: {
4644
root: null,
@@ -1917,22 +1915,23 @@ FS.staticInit();
19171915
#endif
19181916
},
19191917

1920-
$FS_createDataFile__deps: ['$FS'],
1921-
$FS_createDataFile: (parent, name, fileData, canRead, canWrite, canOwn) => {
1922-
FS.createDataFile(parent, name, fileData, canRead, canWrite, canOwn);
1923-
},
1924-
1925-
$FS_unlink__deps: ['$FS'],
1926-
$FS_unlink: (path) => FS.unlink(path),
1927-
19281918
$FS_mkdirTree__docs: `
19291919
/**
19301920
* @param {number=} mode Optionally, the mode to create in. Uses mkdir's
19311921
* default if not set.
19321922
*/`,
1933-
$FS_mkdirTree__deps: ['$FS'],
1934-
$FS_mkdirTree: (path, mode) => FS.mkdirTree(path, mode),
1935-
1936-
$FS_createLazyFile__deps: ['$FS'],
1937-
$FS_createLazyFile: 'FS.createLazyFile',
1938-
});
1923+
$FS_mkdirTree__deps: ['$FS'],
1924+
$FS_mkdirTree: (path, mode) => FS.mkdirTree(path, mode),
1925+
};
1926+
1927+
// Add library aliases for all the FS.<symbol> as FS_<symbol>.
1928+
for (let key in LibraryFS.$FS) {
1929+
const alias = `$FS_${key}`;
1930+
// Skip defining the alias if it already exists or if it's not an API function.
1931+
if (LibraryFS[alias] || key[0] !== key[0].toLowerCase()) {
1932+
continue;
1933+
}
1934+
LibraryFS[alias] = `(...args) => FS.${key}(...args)`;
1935+
LibraryFS[`${alias}__deps`] = ['$FS'];
1936+
}
1937+
addToLibrary(LibraryFS);

src/lib/libhtml5.js

+14
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ var LibraryHTML5 = {
249249
},
250250
},
251251

252+
$registerKeyEventCallback__noleakcheck: true,
252253
$registerKeyEventCallback__deps: ['$JSEvents', '$findEventTarget', '$stringToUTF8', 'malloc'],
253254
$registerKeyEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
254255
#if PTHREADS
@@ -477,6 +478,7 @@ var LibraryHTML5 = {
477478
HEAP32[idx + {{{ C_STRUCTS.EmscriptenMouseEvent.targetY / 4 }}}] = e.clientY - (rect.top | 0);
478479
},
479480

481+
$registerMouseEventCallback__noleakcheck: true,
480482
$registerMouseEventCallback__deps: ['$JSEvents', '$fillMouseEventData', '$findEventTarget', 'malloc'],
481483
$registerMouseEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
482484
#if PTHREADS
@@ -568,6 +570,7 @@ var LibraryHTML5 = {
568570
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
569571
},
570572

573+
$registerWheelEventCallback__noleakcheck: true,
571574
$registerWheelEventCallback__deps: ['$JSEvents', '$fillMouseEventData', 'malloc'],
572575
$registerWheelEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
573576
#if PTHREADS
@@ -619,6 +622,7 @@ var LibraryHTML5 = {
619622
}
620623
},
621624

625+
$registerUiEventCallback__noleakcheck: true,
622626
$registerUiEventCallback__deps: ['$JSEvents', '$findEventTarget', 'malloc'],
623627
$registerUiEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
624628
#if PTHREADS
@@ -691,6 +695,7 @@ var LibraryHTML5 = {
691695
emscripten_set_scroll_callback_on_thread: (target, userData, useCapture, callbackfunc, targetThread) =>
692696
registerUiEventCallback(target, userData, useCapture, callbackfunc, {{{ cDefs.EMSCRIPTEN_EVENT_SCROLL }}}, "scroll", targetThread),
693697

698+
$registerFocusEventCallback__noleakcheck: true,
694699
$registerFocusEventCallback__deps: ['$JSEvents', '$findEventTarget', 'malloc', '$stringToUTF8'],
695700
$registerFocusEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
696701
#if PTHREADS
@@ -754,6 +759,7 @@ var LibraryHTML5 = {
754759
{{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenDeviceOrientationEvent.absolute, 'e.absolute', 'i8') }}};
755760
},
756761

762+
$registerDeviceOrientationEventCallback__noleakcheck: true,
757763
$registerDeviceOrientationEventCallback__deps: ['$JSEvents', '$fillDeviceOrientationEventData', '$findEventTarget'],
758764
$registerDeviceOrientationEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
759765
#if PTHREADS
@@ -823,6 +829,7 @@ var LibraryHTML5 = {
823829
{{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenDeviceMotionEvent.rotationRateGamma, 'rr["gamma"]', 'double') }}};
824830
},
825831

832+
$registerDeviceMotionEventCallback__noleakcheck: true,
826833
$registerDeviceMotionEventCallback__deps: ['$JSEvents', '$fillDeviceMotionEventData', '$findEventTarget', 'malloc'],
827834
$registerDeviceMotionEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
828835
#if PTHREADS
@@ -905,6 +912,7 @@ var LibraryHTML5 = {
905912
{{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenOrientationChangeEvent.orientationAngle, 'orientationAngle', 'i32') }}};
906913
},
907914

915+
$registerOrientationChangeEventCallback__noleakcheck: true,
908916
$registerOrientationChangeEventCallback__deps: ['$JSEvents', '$fillOrientationChangeEventData', 'malloc'],
909917
$registerOrientationChangeEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
910918
#if PTHREADS
@@ -1017,6 +1025,7 @@ var LibraryHTML5 = {
10171025
}
10181026
},
10191027

1028+
$registerFullscreenChangeEventCallback__noleakcheck: true,
10201029
$registerFullscreenChangeEventCallback__deps: ['$JSEvents', '$fillFullscreenChangeEventData', 'malloc'],
10211030
$registerFullscreenChangeEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
10221031
#if PTHREADS
@@ -1556,6 +1565,7 @@ var LibraryHTML5 = {
15561565
stringToUTF8(id, eventStruct + {{{ C_STRUCTS.EmscriptenPointerlockChangeEvent.id }}}, {{{ cDefs.EM_HTML5_LONG_STRING_LEN_BYTES }}});
15571566
},
15581567

1568+
$registerPointerlockChangeEventCallback__noleakcheck: true,
15591569
$registerPointerlockChangeEventCallback__deps: ['$JSEvents', '$fillPointerlockChangeEventData', 'malloc'],
15601570
$registerPointerlockChangeEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
15611571
#if PTHREADS
@@ -1785,6 +1795,7 @@ var LibraryHTML5 = {
17851795
{{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenVisibilityChangeEvent.visibilityState, 'visibilityState', 'i32') }}};
17861796
},
17871797

1798+
$registerVisibilityChangeEventCallback__noleakcheck: true,
17881799
$registerVisibilityChangeEventCallback__deps: ['$JSEvents', '$fillVisibilityChangeEventData', 'malloc'],
17891800
$registerVisibilityChangeEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
17901801
#if PTHREADS
@@ -1839,6 +1850,7 @@ var LibraryHTML5 = {
18391850
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
18401851
},
18411852

1853+
$registerTouchEventCallback__noleakcheck: true,
18421854
$registerTouchEventCallback__deps: ['$JSEvents', '$findEventTarget', '$getBoundingClientRect', 'malloc'],
18431855
$registerTouchEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
18441856
#if PTHREADS
@@ -1987,6 +1999,7 @@ var LibraryHTML5 = {
19871999
stringToUTF8(e.mapping, eventStruct + {{{ C_STRUCTS.EmscriptenGamepadEvent.mapping }}}, {{{ cDefs.EM_HTML5_MEDIUM_STRING_LEN_BYTES }}});
19882000
},
19892001

2002+
$registerGamepadEventCallback__noleakcheck: true,
19902003
$registerGamepadEventCallback__deps: ['$JSEvents', '$fillGamepadEventData', '$findEventTarget', 'malloc'],
19912004
$registerGamepadEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
19922005
#if PTHREADS
@@ -2127,6 +2140,7 @@ var LibraryHTML5 = {
21272140

21282141
$battery: () => navigator.battery || navigator.mozBattery || navigator.webkitBattery,
21292142

2143+
$registerBatteryEventCallback__noleakcheck: true,
21302144
$registerBatteryEventCallback__deps: ['$JSEvents', '$fillBatteryEventData', '$battery', '$findEventTarget', 'malloc'],
21312145
$registerBatteryEventCallback: (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString, targetThread) => {
21322146
#if PTHREADS

src/lib/libwebgl.js

+2
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,8 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
12871287
GLctx.pixelStorei(pname, param);
12881288
},
12891289

1290+
// The allocated strings are cached and never freed.
1291+
glGetString__noleakcheck: true,
12901292
glGetString__deps: ['$stringToNewUTF8', '$webglGetExtensions'],
12911293
glGetString: (name_) => {
12921294
var ret = GL.stringCache[name_];

src/modules.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
isJsOnlySymbol,
1414
error,
1515
readFile,
16-
warn,
1716
pushCurrentFile,
1817
popCurrentFile,
1918
printErr,
@@ -512,11 +511,11 @@ function exportRuntimeSymbols() {
512511
}
513512
}
514513

515-
// check all exported things exist, warn about typos
514+
// check all exported things exist, error when missing
516515
runtimeElementsSet = new Set(runtimeElements);
517516
for (const name of EXPORTED_RUNTIME_METHODS) {
518517
if (!runtimeElementsSet.has(name)) {
519-
warn(`invalid item in EXPORTED_RUNTIME_METHODS: ${name}`);
518+
error(`undefined exported symbol: "${name}" in EXPORTED_RUNTIME_METHODS`);
520519
}
521520
}
522521

system/lib/libc/musl/src/fcntl/fcntl.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@
33
#include <stdarg.h>
44
#include <errno.h>
55
#include "syscall.h"
6+
#include <emscripten/console.h>
67

7-
#ifdef __EMSCRIPTEN__
8-
__attribute__((no_sanitize("address")))
9-
#endif
108
int fcntl(int fd, int cmd, ...)
119
{
12-
unsigned long arg;
10+
#ifdef __EMSCRIPTEN__
1311
// XXX Emscripten: According to the va_arg man page it is undefined behaviour to
1412
// read arguments that are not passed. This can lead to a false positive
1513
// in SAFE_HEAP, so avoid it.
14+
unsigned long arg = 0;
1615
if (cmd != F_GETFL && cmd != F_GETFD && cmd != F_GETOWN) {
1716
va_list ap;
1817
va_start(ap, cmd);
1918
arg = va_arg(ap, unsigned long);
2019
va_end(ap);
2120
}
21+
#else
22+
unsigned long arg;
23+
va_list ap;
24+
va_start(ap, cmd);
25+
arg = va_arg(ap, unsigned long);
26+
va_end(ap);
27+
#endif
2228
if (cmd == F_SETFL) arg |= O_LARGEFILE;
2329
if (cmd == F_SETLKW) return syscall_cp(SYS_fcntl, fd, cmd, (void *)arg);
2430
if (cmd == F_GETOWN) {

system/lib/libcxx/include/__config_site

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#define _LIBCPP_ABI_NAMESPACE __2
77
// Emscripten doesn't use PSTL at the moment.
88
#define _LIBCPP_PSTL_BACKEND_SERIAL
9-
#define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_NONE
9+
#define _LIBCPP_HARDENING_MODE_DEFAULT _LIBCPP_HARDENING_MODE_NONE
1010
#define _LIBCPP_HAS_NO_TIME_ZONE_DATABASE

test/common.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
EMCMAKE = shared.bat_suffix(path_from_root('emcmake'))
8989
EMCONFIGURE = shared.bat_suffix(path_from_root('emconfigure'))
9090
EMRUN = shared.bat_suffix(shared.path_from_root('emrun'))
91-
WASM_DIS = Path(building.get_binaryen_bin(), 'wasm-dis')
91+
WASM_DIS = os.path.join(building.get_binaryen_bin(), 'wasm-dis')
9292
LLVM_OBJDUMP = os.path.expanduser(shared.build_llvm_tool_path(shared.exe_suffix('llvm-objdump')))
9393
PYTHON = sys.executable
9494
if not config.NODE_JS_TEST:
@@ -1406,7 +1406,7 @@ def build(self, filename, libraries=None, includes=None, force_c=False, emcc_arg
14061406
output = output_basename + output_suffix
14071407
else:
14081408
output = shared.unsuffixed_basename(filename) + output_suffix
1409-
cmd = compiler + [filename, '-o', output] + all_emcc_args
1409+
cmd = compiler + [str(filename), '-o', output] + all_emcc_args
14101410
if libraries:
14111411
cmd += libraries
14121412
if includes:
@@ -1755,7 +1755,7 @@ def run_process(self, cmd, check=True, **args):
17551755
if check and e.returncode != 0:
17561756
print(e.stdout)
17571757
print(e.stderr)
1758-
self.fail(f'subprocess exited with non-zero return code({e.returncode}): `{shared.shlex_join(cmd)}`')
1758+
self.fail(f'subprocess exited with non-zero return code({e.returncode}): `{shlex.join(cmd)}`')
17591759

17601760
def emcc(self, filename, args=[], output_filename=None, **kwargs): # noqa
17611761
compile_only = '-c' in args or '-sSIDE_MODULE' in args

test/jsrun.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import common
77
import logging
88
import os
9+
import shlex
910
import subprocess
1011
import sys
1112
from subprocess import PIPE, CalledProcessError
@@ -97,7 +98,7 @@ def run_js(filename, engine, args=None,
9798

9899
command = make_command(os.path.abspath(filename), engine, args)
99100
if common.EMTEST_VERBOSE:
100-
print(f"Running: '{shared.shlex_join(command)}'")
101+
print(f"Running: '{shlex.join(command)}'")
101102
try:
102103
proc = subprocess.run(
103104
command,
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7785
1+
8292
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20761
1+
22165
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6099
1+
6595
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16143
1+
17534

test/other/embind_tsgen_ignore_1.d.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// TypeScript bindings for emscripten-generated code. Automatically generated at compile time.
22
declare namespace RuntimeExports {
3-
let FS_createPath: any;
4-
function FS_createDataFile(parent: any, name: any, fileData: any, canRead: any, canWrite: any, canOwn: any): void;
3+
function FS_createPath(...args: any[]): any;
4+
function FS_createDataFile(...args: any[]): any;
55
function FS_createPreloadedFile(parent: any, name: any, url: any, canRead: any, canWrite: any, onload: any, onerror: any, dontCreateFile: any, canOwn: any, preFinish: any): void;
6-
function FS_unlink(path: any): any;
7-
let FS_createLazyFile: any;
8-
let FS_createDevice: any;
6+
function FS_unlink(...args: any[]): any;
7+
function FS_createLazyFile(...args: any[]): any;
8+
function FS_createDevice(...args: any[]): any;
99
let addRunDependency: any;
1010
let removeRunDependency: any;
1111
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
51593
1+
53547
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
49661
1+
51597

0 commit comments

Comments
 (0)