Skip to content

Commit 88ac28e

Browse files
authored
Merge branch 'main' into cw-audio-tweaks-3
2 parents 8fd7016 + 4c14f1f commit 88ac28e

Some content is hidden

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

61 files changed

+667
-255
lines changed

.circleci/config.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ jobs:
425425
- checkout
426426
- pip-install
427427
- run: ruff check
428-
# TODO (cclauss): When ruff supports rule E303 without --preview, remove following line
429-
- run: ruff check --preview --select=E303
428+
# TODO (cclauss): When ruff supports rules E20,E30 without --preview, remove following line
429+
- run: ruff check --preview --select=E20,E30
430430
mypy:
431431
executor: focal
432432
steps:
@@ -642,7 +642,7 @@ jobs:
642642
# version of node (node canary) when running the compiler output (e.g.
643643
# in configure tests.
644644
- run:
645-
name: configure node canary
645+
name: configure compiler to use node-canary
646646
command: echo "NODE_JS = NODE_JS_TEST" >> ~/emsdk/.emscripten
647647
- run-tests:
648648
title: "wasm64"
@@ -746,6 +746,18 @@ jobs:
746746
command: git submodule update --init
747747
- pip-install
748748
- install-emsdk
749+
# `install-node-version` only changes the NODE_JS_TEST (the version of
750+
# node used to run test), not NODE_JS (the version of node used to run the
751+
# compiler itself).
752+
# In order to test that the compiler itself can run under the oldest
753+
# supported version of node, we run all the tests in the runner under that
754+
# version.
755+
# Keep this in sync with MINIMUM_NODE_VERSION in tools/shared.py.
756+
- install-node-version:
757+
node_version: "18.0.0"
758+
- run:
759+
name: configure compiler to use 18.0.0
760+
command: echo "NODE_JS = '$(which node)'" >> ~/emsdk/.emscripten
749761
- install-node-canary
750762
- run-tests:
751763
title: "node (canary)"
@@ -760,7 +772,8 @@ jobs:
760772
core0.test_async_ccall_promise_exit_runtime_jspi
761773
core0.test_cubescript_jspi"
762774
# Run some basic tests with the minimum version of node that we currently
763-
# support.
775+
# support in the generated code.
776+
# Keep this in sync with `OLDEST_SUPPORTED_NODE` in `feature_matrix.py`
764777
- install-node-version:
765778
node_version: "10.19.0"
766779
- run-tests:

ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Note that version numbers do not necessarily reflect the amount of changes
44
between versions. A version number reflects a release that is known to pass all
55
tests, and versions may be tagged more or less frequently at different times.
66

7-
nNote that there is *no* ABI compatibility guarantee between versions - the ABI
7+
Note that there is *no* ABI compatibility guarantee between versions - the ABI
88
may change, so that we can keep improving and optimizing it. The compiler will
99
automatically invalidate system caches when the version number updates, so that
1010
libc etc. are rebuilt for you. You should also rebuild object files and
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.1 (in development)
2222
----------------------
23+
- The minimum version of node required to run emscripten was bumped from v16.20
24+
to v18. Version 4.0 was mistakenly shipped with a change that required v20,
25+
but that was reverted. (#23410)
2326

2427
4.0.0 - 01/14/25
2528
----------------

emcc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def run(args):
644644
print(compiler_rt.get_path(absolute=True))
645645
return 0
646646

647-
print_file_name = [a for a in newargs if a.startswith('-print-file-name=') or a.startswith('--print-file-name=')]
647+
print_file_name = [a for a in newargs if a.startswith(('-print-file-name=', '--print-file-name='))]
648648
if print_file_name:
649649
libname = print_file_name[-1].split('=')[1]
650650
system_libpath = cache.get_lib_dir(absolute=True)
@@ -1541,7 +1541,7 @@ def parse_value(text, expected_type):
15411541
# places here.
15421542
def parse_string_value(text):
15431543
first = text[0]
1544-
if first == "'" or first == '"':
1544+
if first in {"'", '"'}:
15451545
text = text.rstrip()
15461546
if text[-1] != text[0] or len(text) < 2:
15471547
raise ValueError(f'unclosed quoted string. expected final character to be "{text[0]}" and length to be greater than 1 in "{text[0]}"')
@@ -1558,7 +1558,7 @@ def parse_string_list_members(text):
15581558
if not len(current):
15591559
raise ValueError('empty value in string list')
15601560
first = current[0]
1561-
if not (first == "'" or first == '"'):
1561+
if first not in {"'", '"'}:
15621562
result.append(current.rstrip())
15631563
else:
15641564
start = index

emrun.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ def find_gpu_model(model):
817817
return gpu
818818
return None
819819

820-
for i in range(0, 16):
820+
for i in range(16):
821821
try:
822822
hHardwareReg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'HARDWARE')
823823
hDeviceMapReg = winreg.OpenKey(hHardwareReg, 'DEVICEMAP')
@@ -1398,7 +1398,7 @@ def get_system_info(format_json):
13981398
if len(gpus) == 1:
13991399
info += 'GPU: ' + gpus[0]['model'] + ' with ' + str(gpus[0]['ram'] // 1024 // 1024) + " MB of VRAM\n"
14001400
elif len(gpus) > 1:
1401-
for i in range(0, len(gpus)):
1401+
for i in range(len(gpus)):
14021402
info += 'GPU' + str(i) + ": " + gpus[i]['model'] + ' with ' + str(gpus[i]['ram'] // 1024 // 1024) + ' MBs of VRAM\n'
14031403
info += 'UUID: ' + unique_system_id
14041404
return info.strip()
@@ -1427,7 +1427,6 @@ def list_processes_by_name(exe_full_path):
14271427
except Exception:
14281428
# Fail gracefully if psutil not available
14291429
logv('import psutil failed, unable to detect browser processes')
1430-
pass
14311430

14321431
logv('Searching for processes by full path name "' + exe_full_path + '".. found ' + str(len(pids)) + ' entries')
14331432

@@ -1637,15 +1636,15 @@ def run(args): # noqa: C901, PLR0912, PLR0915
16371636
file_to_serve = options.serve
16381637
else:
16391638
file_to_serve = '.'
1640-
file_to_serve_is_url = file_to_serve.startswith('file://') or file_to_serve.startswith('http://') or file_to_serve.startswith('https://')
1639+
file_to_serve_is_url = file_to_serve.startswith(('file://', 'http://', 'https://'))
16411640

16421641
if options.serve_root:
16431642
serve_dir = os.path.abspath(options.serve_root)
16441643
else:
16451644
if file_to_serve == '.' or file_to_serve_is_url:
16461645
serve_dir = os.path.abspath('.')
16471646
else:
1648-
if file_to_serve.endswith('/') or file_to_serve.endswith('\\') or os.path.isdir(file_to_serve):
1647+
if file_to_serve.endswith(('/', '\\')) or os.path.isdir(file_to_serve):
16491648
serve_dir = file_to_serve
16501649
else:
16511650
serve_dir = os.path.dirname(os.path.abspath(file_to_serve))
@@ -1684,7 +1683,7 @@ def run(args): # noqa: C901, PLR0912, PLR0915
16841683
return 1
16851684
elif options.browser == 'firefox':
16861685
browser_app = 'org.mozilla.firefox/org.mozilla.gecko.BrowserApp'
1687-
elif options.browser == 'firefox_nightly' or options.browser == 'fenix':
1686+
elif options.browser in {'firefox_nightly', 'fenix'}:
16881687
browser_app = 'org.mozilla.fenix/org.mozilla.gecko.BrowserApp'
16891688
elif options.browser == 'chrome':
16901689
browser_app = 'com.android.chrome/com.google.android.apps.chrome.Main'

eslint.config.mjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import globals from 'globals';
22
import js from '@eslint/js';
33
import { FlatCompat } from '@eslint/eslintrc';
4+
import { loadDefaultSettings } from './src/utility.mjs';
45

56
const compat = new FlatCompat({
67
baseDirectory: import.meta.dirname,
78
recommendedConfig: js.configs.recommended,
89
allConfig: js.configs.all
910
});
1011

12+
13+
// Emscripten settings are made available to the compiler as global
14+
// variables. Make sure eslint knows about them.
15+
const settings = loadDefaultSettings();
16+
const settingsGlobals = {};
17+
for (const name of Object.keys(settings)) {
18+
settingsGlobals[name] = 'writable';
19+
}
20+
1121
export default [{
1222
ignores: [
1323
'**/out/',
@@ -56,9 +66,10 @@ export default [{
5666
globals: {
5767
...globals.browser,
5868
...globals.node,
69+
...settingsGlobals,
5970
},
6071

61-
ecmaVersion: 13,
72+
ecmaVersion: 'latest',
6273
sourceType: 'module',
6374
},
6475

@@ -77,6 +88,7 @@ export default [{
7788
files: ['**/*.mjs'],
7889

7990
rules: {
91+
'no-undef': 'error',
8092
'no-unused-vars': ['error', {
8193
vars: 'all',
8294
args: 'none',

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ lint.select = [
2020
"E",
2121
"F",
2222
"PERF",
23+
"PIE",
2324
"PL",
2425
"W",
2526
"YTT",
@@ -42,7 +43,6 @@ lint.ignore = [
4243
"PERF203",
4344
"PERF401",
4445
"PLR1704",
45-
"PLR1714",
4646
"PLR5501",
4747
"PLW0602",
4848
"PLW0603",

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
coverage[toml]==5.5
88
mypy==0.971
9-
ruff==0.8.2
9+
ruff==0.9.1
1010
types-requests==2.27.14
1111
unittest-xml-reporting==3.1.0
1212

src/compiler.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77

88
// LLVM => JavaScript compiler, main entry point
99

10-
import {Benchmarker, applySettings, assert, loadSettingsFile, printErr, read} from './utility.mjs';
11-
12-
// Load default settings
13-
loadSettingsFile('settings.js');
14-
loadSettingsFile('settings_internal.js');
10+
import {
11+
Benchmarker,
12+
applySettings,
13+
assert,
14+
loadDefaultSettings,
15+
printErr,
16+
read,
17+
} from './utility.mjs';
18+
19+
loadDefaultSettings();
1520

1621
const argv = process.argv.slice(2);
1722
const symbolsOnlyArg = argv.indexOf('--symbols-only');

src/parseTools.mjs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -893,23 +893,6 @@ function buildStringArray(array) {
893893
}
894894
}
895895

896-
function _asmjsDemangle(symbol) {
897-
if (symbol.startsWith('dynCall_')) {
898-
return symbol;
899-
}
900-
// Strip leading "_"
901-
assert(symbol.startsWith('_'), `expected mangled symbol: ${symbol}`);
902-
return symbol.substr(1);
903-
}
904-
905-
// TODO(sbc): Remove this function along with _asmjsDemangle.
906-
function hasExportedFunction(func) {
907-
warnOnce(
908-
'hasExportedFunction has been replaced with hasExportedSymbol, which takes and unmangled (no leading underscore) symbol name',
909-
);
910-
return WASM_EXPORTS.has(_asmjsDemangle(func));
911-
}
912-
913896
function hasExportedSymbol(sym) {
914897
return WASM_EXPORTS.has(sym);
915898
}
@@ -1109,7 +1092,6 @@ addToCompileTimeContext({
11091092
getNativeTypeSize,
11101093
getPerformanceNow,
11111094
getUnsharedTextDecoderView,
1112-
hasExportedFunction,
11131095
hasExportedSymbol,
11141096
implicitSelf,
11151097
isSymbolNeeded,

src/parseTools_legacy.mjs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77
import {warn, addToCompileTimeContext} from './utility.mjs';
88
import {ATMAINS, POINTER_SIZE, runIfMainThread} from './parseTools.mjs';
99

10-
// Takes a pair of return values, stashes one in tempRet0 and returns the other.
11-
// Should probably be renamed to `makeReturn64` but keeping this old name in
12-
// case external JS library code uses this name.
13-
function makeStructuralReturn(values) {
14-
warn('use of legacy parseTools function: makeStructuralReturn');
15-
assert(values.length == 2);
16-
return 'setTempRet0(' + values[1] + '); return ' + asmCoercion(values[0], 'i32');
17-
}
18-
1910
// Replaced (at least internally) with receiveI64ParamAsI53 that does
2011
// bounds checking.
2112
function receiveI64ParamAsDouble(name) {
@@ -42,44 +33,18 @@ function makeMalloc(source, param) {
4233
return `_malloc(${param})`;
4334
}
4435

45-
function getNativeFieldSize(type) {
46-
warn('use of legacy parseTools function: getNativeFieldSize');
47-
return Math.max(getNativeTypeSize(type), POINTER_SIZE);
48-
}
49-
5036
const Runtime = {
51-
getNativeFieldSize,
5237
POINTER_SIZE,
5338
QUANTUM_SIZE: POINTER_SIZE,
5439
};
5540

56-
function addAtMain(code) {
57-
warn('use of legacy parseTools function: addAtMain');
58-
assert(HAS_MAIN, 'addAtMain called but program has no main function');
59-
ATMAINS.push(code);
60-
}
61-
62-
function ensureValidFFIType(type) {
63-
return type === 'float' ? 'double' : type; // ffi does not tolerate float XXX
64-
}
65-
66-
// FFI return values must arrive as doubles, and we can force them to floats afterwards
67-
function asmFFICoercion(value, type) {
68-
value = asmCoercion(value, ensureValidFFIType(type));
69-
if (type === 'float') value = asmCoercion(value, 'float');
70-
return value;
71-
}
72-
7341
// Legacy name for runIfMainThread.
7442
const runOnMainThread = runIfMainThread;
7543

7644
addToCompileTimeContext({
7745
ATMAINS,
7846
Runtime,
79-
addAtMain,
80-
asmFFICoercion,
8147
makeMalloc,
82-
makeStructuralReturn,
8348
receiveI64ParamAsDouble,
8449
receiveI64ParamAsI32s,
8550
runOnMainThread,

0 commit comments

Comments
 (0)