Skip to content

Commit 85ca54a

Browse files
authored
Merge branch 'main' into cw-audio-memory64
2 parents 788d7cf + a8385bf commit 85ca54a

25 files changed

+116
-114
lines changed

emcc.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ def __init__(self):
183183
self.dash_S = False
184184
self.dash_M = False
185185
self.input_language = None
186+
self.nostdlib = False
187+
self.nostdlibxx = False
188+
self.nodefaultlibs = False
189+
self.nolibc = False
190+
self.nostartfiles = False
191+
self.sanitize_minimal_runtime = False
192+
self.sanitize = set()
186193

187194

188195
def create_reproduce_file(name, args):
@@ -973,8 +980,8 @@ def compile_source_file(i, input_file):
973980
if get_file_suffix(input_file) in ['.pcm']:
974981
cmd = [c for c in cmd if not c.startswith('-fprebuilt-module-path=')]
975982
cmd += compile_args + ['-c', input_file, '-o', output_file]
976-
if state.mode == Mode.COMPILE_AND_LINK and options.requested_debug == '-gsplit-dwarf':
977-
# When running in COMPILE_AND_LINK mode we compile to temporary location
983+
if options.requested_debug == '-gsplit-dwarf':
984+
# When running in COMPILE_AND_LINK mode we compile objects to a temporary location
978985
# but we want the `.dwo` file to be generated in the current working directory,
979986
# like it is under clang. We could avoid this hack if we use the clang driver
980987
# to generate the temporary files, but that would also involve using the clang
@@ -1421,6 +1428,22 @@ def consume_arg_file():
14211428
# SSEx is implemented on top of SIMD128 instruction set, but do not pass SSE flags to LLVM
14221429
# so it won't think about generating native x86 SSE code.
14231430
newargs[i] = ''
1431+
elif arg == '-nostdlib':
1432+
options.nostdlib = True
1433+
elif arg == '-nostdlibxx':
1434+
options.nostdlibxx = True
1435+
elif arg == '-nodefaultlibs':
1436+
options.nodefaultlibs = True
1437+
elif arg == '-nolibc':
1438+
options.nolibc = True
1439+
elif arg == '-nostartfiles':
1440+
options.nostartfiles = True
1441+
elif arg == '-fsanitize-minimal-runtime':
1442+
options.sanitize_minimal_runtime = True
1443+
elif arg.startswith('-fsanitize='):
1444+
options.sanitize.update(arg.split('=', 1)[1].split(','))
1445+
elif arg.startswith('-fno-sanitize='):
1446+
options.sanitize.difference_update(arg.split('=', 1)[1].split(','))
14241447
elif arg and (arg == '-' or not arg.startswith('-')):
14251448
options.input_files.append(arg)
14261449

eslint.config.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export default [{
5959
'src/proxyWorker.js',
6060
'src/proxyClient.js',
6161
'src/IDBStore.js',
62-
'src/URIUtils.js',
6362
'tools/experimental',
6463
],
6564
}, ...compat.extends('prettier'), js.configs.recommended, {
@@ -90,11 +89,8 @@ export default [{
9089
files: ['**/*.mjs'],
9190

9291
rules: {
93-
'no-undef': 'error',
9492
'no-unused-vars': ['error', {
95-
vars: 'all',
96-
args: 'none',
97-
ignoreRestSiblings: false,
93+
argsIgnorePattern: '^_',
9894
destructuredArrayIgnorePattern: '^_',
9995
}],
10096
},

src/URIUtils.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/jsifier.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function mangleCSymbolName(f) {
5151
if (f === '__main_argc_argv') {
5252
f = 'main';
5353
}
54-
return f[0] == '$' ? f.substr(1) : '_' + f;
54+
return f[0] == '$' ? f.slice(1) : '_' + f;
5555
}
5656

5757
// Splits out items that pass filter. Returns also the original sans the filtered
@@ -112,7 +112,7 @@ function resolveAlias(symbol) {
112112
return symbol;
113113
}
114114

115-
function getTransitiveDeps(symbol, debug) {
115+
function getTransitiveDeps(symbol) {
116116
// TODO(sbc): Use some kind of cache to avoid quadratic behaviour here.
117117
const transitiveDeps = new Set();
118118
const seen = new Set();
@@ -284,7 +284,7 @@ ${argConversions}
284284

285285
// apply LIBRARY_DEBUG if relevant
286286
if (LIBRARY_DEBUG && !isJsOnlySymbol(symbol)) {
287-
snippet = modifyJSFunction(snippet, (args, body, async, oneliner) => {
287+
snippet = modifyJSFunction(snippet, (args, body, _async, oneliner) => {
288288
var run_func;
289289
if (oneliner) {
290290
run_func = `var ret = ${body}`;
@@ -637,7 +637,7 @@ function(${args}) {
637637
// emits
638638
// 'var foo = [value];'
639639
if (typeof snippet == 'string' && snippet[0] == '=') {
640-
snippet = snippet.substr(1);
640+
snippet = snippet.slice(1);
641641
}
642642
contentText = `var ${mangled} = ${snippet};`;
643643
}

src/modules.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ if (!BOOTSTRAPPING_STRUCT_INFO) {
334334
// Use proxy objects for C_DEFINES and C_STRUCTS so that we can give useful
335335
// error messages.
336336
const C_STRUCTS = new Proxy(structs, {
337-
get(target, prop, receiver) {
337+
get(target, prop) {
338338
if (!(prop in target)) {
339339
throw new Error(
340340
`Missing C struct ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`,
@@ -345,7 +345,7 @@ const C_STRUCTS = new Proxy(structs, {
345345
});
346346

347347
const C_DEFINES = new Proxy(defines, {
348-
get(target, prop, receiver) {
348+
get(target, prop) {
349349
if (!(prop in target)) {
350350
throw new Error(
351351
`Missing C define ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`,
@@ -374,7 +374,7 @@ function getUnusedLibrarySymbols() {
374374
for (const [ident, value] of Object.entries(LibraryManager.library)) {
375375
if (typeof value === 'function' || typeof value === 'number') {
376376
if (isJsOnlySymbol(ident) && !isDecorator(ident) && !isInternalSymbol(ident)) {
377-
const name = ident.substr(1);
377+
const name = ident.slice(1);
378378
if (!librarySymbolSet.has(name)) {
379379
missingSyms.add(name);
380380
}
@@ -492,7 +492,7 @@ function exportRuntime() {
492492
let runtimeElementsSet = new Set(runtimeElements);
493493
for (const ident of Object.keys(LibraryManager.library)) {
494494
if (isJsOnlySymbol(ident) && !isDecorator(ident) && !isInternalSymbol(ident)) {
495-
const jsname = ident.substr(1);
495+
const jsname = ident.slice(1);
496496
// Note that this assertion may be hit when a function is moved into the
497497
// JS library. In that case the function should be removed from the list
498498
// of runtime elements above.

src/parseTools.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ export function preprocess(filename) {
141141
showStack.push(truthy ? SHOW : IGNORE);
142142
} else if (first === '#include') {
143143
if (showCurrentLine()) {
144-
let includeFile = line.substr(line.indexOf(' ') + 1);
144+
let includeFile = line.slice(line.indexOf(' ') + 1);
145145
if (includeFile.startsWith('"')) {
146-
includeFile = includeFile.substr(1, includeFile.length - 2);
146+
includeFile = includeFile.slice(1, -1);
147147
}
148148
const absPath = findIncludeFile(includeFile, path.dirname(filename));
149149
if (!absPath) {
@@ -214,7 +214,7 @@ no matching #endif found (${showStack.length$}' unmatched preprocessing directiv
214214
}
215215

216216
// Returns true if ident is a niceIdent (see toNiceIdent). Also allow () and spaces.
217-
function isNiceIdent(ident, loose) {
217+
function isNiceIdent(ident) {
218218
return /^\(?[$_]+[\w$_\d ]*\)?$/.test(ident);
219219
}
220220

@@ -328,7 +328,7 @@ function getNativeTypeSize(type) {
328328
return POINTER_SIZE;
329329
}
330330
if (type[0] === 'i') {
331-
const bits = Number(type.substr(1));
331+
const bits = Number(type.slice(1));
332332
assert(bits % 8 === 0, `getNativeTypeSize invalid bits ${bits}, ${type} type`);
333333
return bits / 8;
334334
}
@@ -360,7 +360,7 @@ function ensureDot(value) {
360360
if (value.includes('.') || /[IN]/.test(value)) return value;
361361
const e = value.indexOf('e');
362362
if (e < 0) return value + '.0';
363-
return value.substr(0, e) + '.0' + value.substr(e);
363+
return value.slice(0, e) + '.0' + value.slice(e);
364364
}
365365

366366
export function isNumber(x) {
@@ -406,7 +406,7 @@ function asmFloatToInt(x) {
406406
}
407407

408408
// See makeSetValue
409-
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
409+
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, _ignore, align) {
410410
assert(typeof align === 'undefined', 'makeGetValue no longer supports align parameter');
411411
assert(
412412
typeof noNeedFirst === 'undefined',
@@ -551,7 +551,7 @@ function getFastValue(a, op, b) {
551551

552552
if (b[0] === '-') {
553553
op = '-';
554-
b = b.substr(1);
554+
b = b.slice(1);
555555
}
556556

557557
return `(${a})${op}(${b})`;
@@ -785,14 +785,14 @@ export function modifyJSFunction(text, func) {
785785
if (match) {
786786
async_ = match[1] || '';
787787
args = match[3];
788-
rest = text.substr(match[0].length);
788+
rest = text.slice(match[0].length);
789789
} else {
790790
// Match an arrow function
791791
let match = text.match(/^\s*(var (\w+) = )?(async\s+)?\(([^)]*)\)\s+=>\s+/);
792792
if (match) {
793793
async_ = match[3] || '';
794794
args = match[4];
795-
rest = text.substr(match[0].length);
795+
rest = text.slice(match[0].length);
796796
rest = rest.trim();
797797
oneliner = rest[0] != '{';
798798
} else {
@@ -802,7 +802,7 @@ export function modifyJSFunction(text, func) {
802802
assert(match, `could not match function:\n${text}\n`);
803803
async_ = match[1] || '';
804804
args = match[2];
805-
rest = text.substr(match[0].length);
805+
rest = text.slice(match[0].length);
806806
}
807807
}
808808
let body = rest;
@@ -970,7 +970,7 @@ function from64(x) {
970970

971971
// Like from64 above but generate an expression instead of an assignment
972972
// statement.
973-
function from64Expr(x, assign = true) {
973+
function from64Expr(x) {
974974
if (!MEMORY64) return x;
975975
return `Number(${x})`;
976976
}

src/preamble.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,20 @@ var runtimeInitialized = false;
140140
var runtimeExited = false;
141141
#endif
142142

143-
#include "URIUtils.js"
143+
// Prefix of data URIs emitted by SINGLE_FILE and related options.
144+
var dataURIPrefix = 'data:application/octet-stream;base64,';
145+
146+
/**
147+
* Indicates whether filename is a base64 data URI.
148+
* @noinline
149+
*/
150+
var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
151+
152+
/**
153+
* Indicates whether filename is delivered via file protocol (as opposed to http/https)
154+
* @noinline
155+
*/
156+
var isFileURI = (filename) => filename.startsWith('file://');
144157

145158
#include "runtime_shared.js"
146159

test/common.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ def parameterize(func, parameters):
792792
test functions.
793793
"""
794794
prev = getattr(func, '_parameterize', None)
795+
assert not any(p.startswith('_') for p in parameters)
795796
if prev:
796797
# If we're parameterizing 2nd time, construct a cartesian product for various combinations.
797798
func._parameterize = {
@@ -1333,21 +1334,19 @@ def verify_es5(self, filename):
13331334
self.fail('es-check failed to verify ES5 output compliance')
13341335

13351336
# Build JavaScript code from source code
1336-
def build(self, filename, libraries=None, includes=None, force_c=False, js_outfile=True, emcc_args=None, output_basename=None):
1337+
def build(self, filename, libraries=None, includes=None, force_c=False, output_suffix='.js', emcc_args=None, output_basename=None):
13371338
if not os.path.exists(filename):
13381339
filename = test_file(filename)
1339-
suffix = '.js' if js_outfile else '.wasm'
13401340
compiler = [compiler_for(filename, force_c)]
13411341

13421342
if force_c:
13431343
assert shared.suffix(filename) != '.c', 'force_c is not needed for source files ending in .c'
13441344
compiler.append('-xc')
13451345

13461346
if output_basename:
1347-
output = output_basename + suffix
1347+
output = output_basename + output_suffix
13481348
else:
1349-
basename = os.path.basename(filename)
1350-
output = shared.unsuffixed(basename) + suffix
1349+
output = shared.unsuffixed_basename(filename) + output_suffix
13511350
cmd = compiler + [filename, '-o', output] + self.get_emcc_args(main_file=True)
13521351
if emcc_args:
13531352
cmd += emcc_args
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
129211
1+
129155
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
128623
1+
128567

0 commit comments

Comments
 (0)