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 may 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
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
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
}
9 changes: 4 additions & 5 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=['-sSTRICT_JS', '-sLEGACY_GL_EMULATION', '-lSDL', '-lGL'] + args)
self.btest_exit('test_sdl_canvas.c', cflags=['-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', '-sSTRICT_JS'])
self.btest_exit('glut_touchevents.c', cflags=['-lglut'])

def test_glut_wheelevents(self):
self.btest_exit('glut_wheelevents.c', cflags=['-lglut'])
Expand Down Expand Up @@ -4938,7 +4938,6 @@ def test_no_declare_asm_module_exports_wasm2js(self, args):

@parameterized({
'': ([],),
'strict_js': (['-sSTRICT_JS'],),
'minimal_runtime': (['-sMINIMAL_RUNTIME=1'],),
'minimal_runtime_2': (['-sMINIMAL_RUNTIME=2'],),
})
Expand Down Expand Up @@ -5401,8 +5400,8 @@ def test_pthread_unhandledrejection(self):
def test_pthread_key_recreation(self):
self.btest_exit('pthread/test_pthread_key_recreation.c', cflags=['-pthread', '-sPTHREAD_POOL_SIZE=1'])

def test_full_js_library_strict(self):
self.btest_exit('hello_world.c', cflags=['-sINCLUDE_FULL_LIBRARY', '-sSTRICT_JS'])
def test_full_js_library(self):
self.btest_exit('hello_world.c', cflags=['-sINCLUDE_FULL_LIBRARY'])

# Tests the AudioWorklet demo
@parameterized({
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
8 changes: 2 additions & 6 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,6 @@ def test_embind_subclass_pointer(self):
'o2': ['-O2'],
'o2_mem_growth': ['-O2', '-sALLOW_MEMORY_GROWTH', test_file('embind/isMemoryGrowthEnabled=true.cpp')],
'o2_closure': ['-O2', '--closure=1', '--closure-args', '--externs ' + shlex.quote(test_file('embind/underscore-externs.js')), '-sASSERTIONS=1'],
'strict_js': ['-sSTRICT_JS'],
# DYNCALLS tests the legacy native function API (ASYNCIFY implicitly enables DYNCALLS)
'dyncalls': ['-sDYNCALLS=1'],
})
Expand Down Expand Up @@ -9083,11 +9082,11 @@ def test(check, extra):
'embind': (['-lembind'],),
})
def test_full_js_library(self, args):
self.run_process([EMCC, test_file('hello_world.c'), '-sSTRICT_JS', '-sINCLUDE_FULL_LIBRARY'] + args)
self.run_process([EMCC, test_file('hello_world.c'), '-sINCLUDE_FULL_LIBRARY'] + args)

def test_full_js_library_undefined(self):
create_file('main.c', 'void foo(); int main() { foo(); return 0; }')
self.assert_fail([EMCC, 'main.c', '-sSTRICT_JS', '-sINCLUDE_FULL_LIBRARY'], 'undefined symbol: foo')
self.assert_fail([EMCC, 'main.c', '-sINCLUDE_FULL_LIBRARY'], 'undefined symbol: foo')

def test_full_js_library_except(self):
self.set_setting('INCLUDE_FULL_LIBRARY', 1)
Expand Down Expand Up @@ -13830,9 +13829,6 @@ def test_std_filesystem_tempdir(self):
self.skipTest('https://github.com/emscripten-core/emscripten/issues/24830')
self.do_other_test('test_std_filesystem_tempdir.cpp', cflags=['-g'])

def test_strict_js_closure(self):
self.do_runf('hello_world.c', cflags=['-sSTRICT_JS', '-Werror=closure', '--closure=1', '-O3'])

def test_em_js_deps(self):
# Check that EM_JS_DEPS works. Specifically, multiple different instances in different
# object files.
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