Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ See docs/process.md for more on how version tagging works.
- SDL2 port updated to include stub functions for `SDL_hid_init()` and related
functions. (#26297)
- libpng port updated from 1.6.39 to 1.6.55. (#26388)
- The `STRICT_JS` setting is now on by default. Previously it was enabled by
default in `STRICT` mode. If you have EM_ASM or EM_JS or `--pre-js` code
that does not conform to JS strict mode then you maybe need to disable this
with `-sSTRICT_JS=0`. (#26421)

5.0.2 - 02/25/26
----------------
Expand Down
3 changes: 1 addition & 2 deletions site/source/docs/tools_reference/settings_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,6 @@ Changes enabled by this:

- The C define EMSCRIPTEN is not defined (__EMSCRIPTEN__ always is, and
is the correct thing to use).
- STRICT_JS is enabled.
- IGNORE_MISSING_MAIN is disabled.
- AUTO_JS_LIBRARIES is disabled.
- AUTO_NATIVE_LIBRARIES is disabled.
Expand Down Expand Up @@ -1734,7 +1733,7 @@ STRICT_JS

Add ``"use strict;"`` to generated JS

Default value: false
Default value: true

.. _warn_on_undefined_symbols:

Expand Down
72 changes: 35 additions & 37 deletions src/lib/libglemu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,41 @@ var LibraryGLEmulation = {
'glVertexAttribPointer', 'glActiveTexture', '$stringToNewUTF8',
'$ptrToString', '$getEmscriptenSupportedExtensions',
],
$GLEmulation__postset:
#if MAYBE_CLOSURE_COMPILER
// Forward declare GL functions that are overridden by GLEmulation here to appease Closure compiler.
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawArrays;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawElements;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glActiveTexture;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnable;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisable;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvf;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvi;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvfv;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetIntegerv;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glIsEnabled;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetBooleanv;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetString;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCreateShader;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glShaderSource;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCompileShader;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glAttachShader;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDetachShader;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glUseProgram;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDeleteProgram;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindAttribLocation;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glLinkProgram;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindBuffer;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetFloatv;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glHint;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnableVertexAttribArray;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisableVertexAttribArray;' +
'/**@suppress {duplicate, undefinedVars}*/var _emscripten_glVertexAttribPointer;' +
'/**@suppress {duplicate, undefinedVars}*/var _glTexEnvf;' +
'/**@suppress {duplicate, undefinedVars}*/var _glTexEnvi;' +
'/**@suppress {duplicate, undefinedVars}*/var _glTexEnvfv;' +
'/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnviv;' +
'/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnvfv;' +
#endif
'GLEmulation.init();',
$GLEmulation__postset: `
// Forward declare GL functions that are overridden by GLEmulation.
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawArrays;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDrawElements;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glActiveTexture;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnable;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisable;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvf;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvi;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glTexEnvfv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetIntegerv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glIsEnabled;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetBooleanv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetString;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCreateShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glShaderSource;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glCompileShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glAttachShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDetachShader;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glUseProgram;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDeleteProgram;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindAttribLocation;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glLinkProgram;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glBindBuffer;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glGetFloatv;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glHint;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glEnableVertexAttribArray;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glDisableVertexAttribArray;
/**@suppress {duplicate, undefinedVars}*/var _emscripten_glVertexAttribPointer;
/**@suppress {duplicate, undefinedVars}*/var _glTexEnvf;
/**@suppress {duplicate, undefinedVars}*/var _glTexEnvi;
/**@suppress {duplicate, undefinedVars}*/var _glTexEnvfv;
/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnviv;
/**@suppress {duplicate, undefinedVars}*/var _glGetTexEnvfv;
GLEmulation.init();`,
$GLEmulation: {
// Fog support. Partial, we assume shaders are used that implement fog. We just pass them uniforms
fogStart: 0,
Expand Down
3 changes: 1 addition & 2 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,6 @@ var LINKABLE = false;
//
// - The C define EMSCRIPTEN is not defined (__EMSCRIPTEN__ always is, and
// is the correct thing to use).
// - STRICT_JS is enabled.
// - IGNORE_MISSING_MAIN is disabled.
// - AUTO_JS_LIBRARIES is disabled.
// - AUTO_NATIVE_LIBRARIES is disabled.
Expand All @@ -1181,7 +1180,7 @@ var IGNORE_MISSING_MAIN = true;

// Add ``"use strict;"`` to generated JS
// [link]
var STRICT_JS = false;
var STRICT_JS = true;

// If set to 1, we will warn on any undefined symbols that are not resolved by
// the ``library_*.js`` files. Note that it is common in large projects to not
Expand Down
1 change: 0 additions & 1 deletion test/browser/glut_touchevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ int main(int argc, char *argv[])
touches.item = function(i) { return this[i]; };

var event = document.createEvent('UIEvent');
event.target = Module['canvas'];
event.button = 0;
event.changedTouches = touches;
event.initUIEvent(eventType, true, true, window, 1);
Expand Down
12 changes: 6 additions & 6 deletions test/codesize/test_unoptimized_code_size.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"hello_world.js": 57007,
"hello_world.js.gz": 17736,
"hello_world.js": 57022,
"hello_world.js.gz": 17744,
"hello_world.wasm": 15138,
"hello_world.wasm.gz": 7455,
"no_asserts.js": 26576,
"no_asserts.js.gz": 8881,
"no_asserts.js": 26591,
"no_asserts.js.gz": 8894,
"no_asserts.wasm": 12187,
"no_asserts.wasm.gz": 5984,
"strict.js": 54825,
"strict.js.gz": 17039,
"strict.wasm": 15138,
"strict.wasm.gz": 7450,
"total": 180871,
"total_gz": 64545
"total": 180901,
"total_gz": 64566
}
2 changes: 1 addition & 1 deletion test/embind/test_pthreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace emscripten;

void thread(void) {
EM_ASM({
globalProperty = {
globalThis.globalProperty = {
foo: function(value) {
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion test/other/test_runtime_keepalive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main() {
Module["onExit"] = () => { out("onExit"); };
runtimeKeepalivePush();
out("runtimeKeepalivePush done");
counter = 0;
var counter = 0;
function timerCallback() {
if (counter < 5) {
runtimeKeepalivePush();
Expand Down
4 changes: 2 additions & 2 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ def test_sdl_stb_image_cleanup(self):
'safe_heap_O2': (['-sSAFE_HEAP', '-O2'],),
})
def test_sdl_canvas(self, args):
self.btest_exit('test_sdl_canvas.c', cflags=['-sLEGACY_GL_EMULATION', '-lSDL', '-lGL'] + args)
self.btest_exit('test_sdl_canvas.c', cflags=['-sSTRICT_JS', '-sLEGACY_GL_EMULATION', '-lSDL', '-lGL'] + args)

def test_sdl_canvas_alpha(self):
# N.B. On Linux with Intel integrated graphics cards, this test needs Firefox 49 or newer.
Expand Down Expand Up @@ -1058,7 +1058,7 @@ def test_sdl_mouse_offsets(self):
self.run_browser('page.html', '', '/report_result?exit:0')

def test_glut_touchevents(self):
self.btest_exit('glut_touchevents.c', cflags=['-lglut'])
self.btest_exit('glut_touchevents.c', cflags=['-lglut', '-sSTRICT_JS'])

def test_glut_wheelevents(self):
self.btest_exit('glut_wheelevents.c', cflags=['-lglut'])
Expand Down
8 changes: 0 additions & 8 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ def decorated(self, textdecoder, *args, **kwargs):

no_safe_heap = make_no_decorator_for_setting('SAFE_HEAP')
no_strict = make_no_decorator_for_setting('STRICT')
no_strict_js = make_no_decorator_for_setting('STRICT_JS')
no_big_endian = make_no_decorator_for_setting('SUPPORT_BIG_ENDIAN')
no_omit_asm_module_exports = make_no_decorator_for_setting('DECLARE_ASM_MODULE_EXPORTS=0')
no_js_math = make_no_decorator_for_setting('JS_MATH')
Expand Down Expand Up @@ -6306,7 +6305,6 @@ def test_jslib(self):
@with_env_modify({'LC_ALL': 'latin-1', 'PYTHONUTF8': '0', 'PYTHONCOERCECLOCALE': '0'})
@crossplatform
@no_modularize_instance('uses MODULARIZE')
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
def test_unicode_js_library(self):
# First verify that we have correct overridden the default python file encoding.
Expand Down Expand Up @@ -8038,7 +8036,6 @@ def get_wat_addr(call_index):

@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
@no_modularize_instance('uses -sMODULARIZE')
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
def test_modularize_closure_pre(self):
# test that the combination of modularize + closure + pre-js works. in that mode,
# closure should not minify the Module object in a way that the pre-js cannot use it.
Expand Down Expand Up @@ -8985,7 +8982,6 @@ def test_asan_api(self):
self.do_core_test('test_asan_api.c', cflags=['-fsanitize=address'])

@asan
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
@no_modularize_instance('uses MODULARIZE')
def test_asan_modularized_with_closure(self):
Expand Down Expand Up @@ -9680,7 +9676,6 @@ def test_esm_integration(self):
self.assertFileContents(test_file('core/test_esm_integration.expected.mjs'), read_file('hello_world.mjs'))

@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
def test_modularize_instance_hello(self):
self.do_core_test('test_hello_world.c', cflags=['-sMODULARIZE=instance', '-Wno-experimental'])

Expand All @@ -9689,7 +9684,6 @@ def test_modularize_instance_hello(self):
'pthreads': (['-pthread'],),
})
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
def test_modularize_instance(self, args):
if args:
self.require_pthreads()
Expand Down Expand Up @@ -9725,7 +9719,6 @@ def test_modularize_instance(self, args):

@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
@no_4gb('EMBIND_AOT can\'t lower 4gb')
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
def test_modularize_instance_embind(self):
self.run_process([EMXX, test_file('modularize_instance_embind.cpp'),
'-sMODULARIZE=instance',
Expand Down Expand Up @@ -9905,7 +9898,6 @@ def setUp(self):

# Add DEFAULT_TO_CXX=0
strict = make_run('strict', cflags=[], settings={'STRICT': 1})
strict_js = make_run('strict_js', cflags=[], settings={'STRICT_JS': 1})

ubsan = make_run('ubsan', cflags=['-fsanitize=undefined', '--profiling'])
lsan = make_run('lsan', cflags=['-fsanitize=leak', '--profiling'], settings={'ALLOW_MEMORY_GROWTH': 1})
Expand Down
5 changes: 3 additions & 2 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,9 +1147,10 @@ def limit_incoming_module_api():
elif options.shell_html:
diagnostics.warning('unused-command-line-argument', '--shell-file ignored when not generating html output')

if settings.EXPORT_ES6 or settings.MODULARIZE:
default_setting('STRICT_JS', 0)

if settings.STRICT:
if not settings.MODULARIZE:
default_setting('STRICT_JS', 1)
default_setting('DEFAULT_TO_CXX', 0)
default_setting('IGNORE_MISSING_MAIN', 0)
default_setting('AUTO_NATIVE_LIBRARIES', 0)
Expand Down