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 @@ -23,6 +23,10 @@ See docs/process.md for more on how version tagging works.
- The deprecated `EMSCRIPTEN` macro is now defined in `emscripten.h` rather than
on the command line (`__EMSCRIPTEN__`, which is built into LLVM, should be
used instead). (#26417)
- 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.3 - 03/14/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 @@ -1701,7 +1701,6 @@ Set the environment variable EMCC_STRICT=1 or pass -sSTRICT to test that a
codebase builds nicely in forward compatible manner.
Changes enabled by this:

- STRICT_JS is enabled.
- IGNORE_MISSING_MAIN is disabled.
- AUTO_JS_LIBRARIES is disabled.
- AUTO_NATIVE_LIBRARIES is disabled.
Expand Down Expand Up @@ -1732,7 +1731,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 @@ -1160,7 +1160,6 @@ var LINKABLE = false;
// codebase builds nicely in forward compatible manner.
// Changes enabled by this:
//
// - STRICT_JS is enabled.
// - IGNORE_MISSING_MAIN is disabled.
// - AUTO_JS_LIBRARIES is disabled.
// - AUTO_NATIVE_LIBRARIES is disabled.
Expand All @@ -1179,7 +1178,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
20 changes: 8 additions & 12 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,12 @@ def test_preload_caching(self, extra_size):
addToLibrary({
checkPreloadResults: function() {
var cached = 0;
var packages = Object.keys(Module['preloadResults']);
packages.forEach(function(package) {
var fromCache = Module['preloadResults'][package]['fromCache'];
for (var result of Object.values(Module['preloadResults'])) {
var fromCache = result['fromCache'];
if (fromCache) {
cached++;
}
});
}
return cached;
}
});
Expand Down Expand Up @@ -945,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 @@ -1059,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 @@ -4847,8 +4846,6 @@ def test_browser_run_from_different_directory_async(self):
# also also we eval the initial code, so currentScript is not present. That prevents us
# from finding the file in a subdir, but here we at least check we do not regress compared to the
# normal case of finding in the current dir.
# test both modularize (and creating an instance) and modularize-instance
# (which creates by itself)
@parameterized({
'': ([], ['-sMODULARIZE'], 'Module();'),
'subdir': (['subdir'], ['-sMODULARIZE'], 'Module();'),
Expand All @@ -4865,7 +4862,7 @@ def test_browser_modularize_no_current_script(self, path, args, creation):
setTimeout(async () => {
let response = await fetch('test.js');
let text = await response.text();
eval(text);
let Module = eval(text + '; Module');
%s
}, 1);
</script>
Expand Down Expand Up @@ -4953,7 +4950,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 @@ -5425,8 +5421,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
5 changes: 0 additions & 5 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,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 @@ -9729,7 +9728,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('EXPORT_ES6 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 @@ -9738,7 +9736,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('EXPORT_ES6 is not compatible with STRICT_JS')
def test_modularize_instance(self, args):
if args:
self.require_pthreads()
Expand Down Expand Up @@ -9774,7 +9771,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('EXPORT_ES6 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 @@ -9955,7 +9951,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 @@ -3374,7 +3374,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 @@ -9022,11 +9021,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 @@ -13764,9 +13763,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:
default_setting('STRICT_JS', 0)

if settings.STRICT:
if not settings.EXPORT_ES6:
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
Loading