From 91e40256fa7c4d493a177355f974d9f646585d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:44:45 +0300 Subject: [PATCH 01/11] Add missing --no-entry and -sINCOMING_MODULE_JS_API directives to fix 'test/runner strict' tests. --- test/common.py | 8 ++++---- test/test_core.py | 39 +++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/test/common.py b/test/common.py index d26f1f3ee8f29..6569e5e65cfba 100644 --- a/test/common.py +++ b/test/common.py @@ -1147,7 +1147,7 @@ def setup_nodefs_test(self): if self.get_setting('WASMFS'): # without this the JS setup code in setup_nodefs.js doesn't work self.set_setting('FORCE_FILESYSTEM') - self.emcc_args += ['-DNODEFS', '-lnodefs.js', '--pre-js', test_file('setup_nodefs.js')] + self.emcc_args += ['-DNODEFS', '-lnodefs.js', '--pre-js', test_file('setup_nodefs.js'), '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]'] def setup_noderawfs_test(self): self.require_node() @@ -1336,17 +1336,17 @@ def in_dir(self, *pathelems): def add_pre_run(self, code): assert not self.get_setting('MINIMAL_RUNTIME') create_file('prerun.js', 'Module.preRun = function() { %s }\n' % code) - self.emcc_args += ['--pre-js', 'prerun.js'] + self.emcc_args += ['--pre-js', 'prerun.js', '-sINCOMING_MODULE_JS_API=[preRun]'] def add_post_run(self, code): assert not self.get_setting('MINIMAL_RUNTIME') create_file('postrun.js', 'Module.postRun = function() { %s }\n' % code) - self.emcc_args += ['--pre-js', 'postrun.js'] + self.emcc_args += ['--pre-js', 'postrun.js', '-sINCOMING_MODULE_JS_API=[postRun]'] def add_on_exit(self, code): assert not self.get_setting('MINIMAL_RUNTIME') create_file('onexit.js', 'Module.onExit = function() { %s }\n' % code) - self.emcc_args += ['--pre-js', 'onexit.js'] + self.emcc_args += ['--pre-js', 'onexit.js', '-sINCOMING_MODULE_JS_API=[onExit]'] # returns the full list of arguments to pass to emcc # param @main_file whether this is the main file of the test. some arguments diff --git a/test/test_core.py b/test/test_core.py index 15f0b694f3527..5f7d0d34482bc 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -2649,6 +2649,7 @@ def test_pthread_abort(self): # handler will only be present in the main thread (much like it would if it # was passed in by pre-populating the module object on prior to loading). self.add_pre_run("Module.onAbort = () => console.log('onAbort called');") + self.emcc_args += ['-sINCOMING_MODULE_JS_API=[preRun,onAbort]'] self.do_run_in_out_file_test('pthread/test_pthread_abort.c', assert_returncode=NON_ZERO) @node_pthreads @@ -4159,7 +4160,7 @@ def test_dylink_locate_file(self): } }; ''' % (so_name, so_dir)) - self.do_basic_dylink_test(so_dir=so_dir, so_name=so_name, main_emcc_args=['--pre-js', 'pre.js']) + self.do_basic_dylink_test(so_dir=so_dir, so_name=so_name, main_emcc_args=['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[locateFile]']) @with_dylink_reversed def test_dylink_function_pointer_equality(self): @@ -5209,7 +5210,7 @@ class Bar : public Foo { @needs_dylink def test_dylink_argv_argc(self): # Verify that argc and argv can be sent to main when main is in a side module - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '--no-entry', '-sINCOMING_MODULE_JS_API=[arguments]'] create_file('pre.js', "Module['arguments'] = ['hello', 'world!']") self.dylink_test( '', # main module is empty. @@ -5435,7 +5436,7 @@ def test_files(self): else: self.maybe_closure() - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[noFSInit, preRun]'] self.set_setting('FORCE_FILESYSTEM') create_file('pre.js', ''' @@ -5467,7 +5468,7 @@ def test_module_stdin(self): stdout: (x) => out('got: ' + x) }; ''') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[stdin,stdout]'] src = r''' #include @@ -5916,7 +5917,7 @@ def test_fs_no_main(self): ''') self.set_setting('EXPORTED_FUNCTIONS', '_foo') self.set_setting('FORCE_FILESYSTEM') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[preRun, onRuntimeInitialized]'] self.do_run('int foo() { return 42; }', '', force_c=True) @also_with_noderawfs @@ -6847,7 +6848,7 @@ def test_poppler(self): out("Data: " + JSON.stringify(FileData.map(function(x) { return unSign(x, 8) }))); }; ''') - self.emcc_args += ['--pre-js', 'pre.js', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$unSign'] + self.emcc_args += ['--pre-js', 'pre.js', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$unSign', '-sINCOMING_MODULE_JS_API=[preRun, postRun]'] ppm_data = str(list(bytearray(read_binary(test_file('poppler/ref.ppm'))))) self.do_run('', ppm_data.replace(' ', ''), @@ -6935,7 +6936,7 @@ def image_compare(output): assert diff_mean < 0.01, diff_mean self.emcc_args += ['--minify=0'] # to compare the versions - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[preRun,postRun]'] output = self.do_runf('third_party/openjpeg/codec/j2k_to_image.c', 'Successfully generated', # The real test for valid output is in image_compare @@ -7573,7 +7574,7 @@ def test_embind_val_coro(self): create_file('pre.js', r'''Module.onRuntimeInitialized = () => { Module.asyncCoro().then(console.log); }''') - self.emcc_args += ['-std=c++20', '--bind', '--pre-js=pre.js'] + self.emcc_args += ['-std=c++20', '--bind', '--pre-js=pre.js', '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]', '--no-entry'] self.do_runf('embind/test_val_coro.cpp', '34\n') def test_embind_val_coro_caught(self): @@ -7584,7 +7585,7 @@ def test_embind_val_coro_caught(self): err => console.error(`rejected with: ${err.stack}`) ); }''') - self.emcc_args += ['-std=c++20', '--bind', '--pre-js=pre.js', '-fexceptions'] + self.emcc_args += ['-std=c++20', '--bind', '--pre-js=pre.js', '-fexceptions', '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]', '--no-entry'] self.do_runf('embind/test_val_coro.cpp', 'rejected with: std::runtime_error: bang from throwingCoro!\n') def test_embind_dynamic_initialization(self): @@ -8055,7 +8056,7 @@ def test_exit_status(self): assert(status == EXITSTATUS); }; ''') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[onExit]'] print('.. exit') self.do_runf('exit.c', 'hello, world!\ncleanup\nI see exit status: 117', assert_returncode=117, emcc_args=['-DNORMAL_EXIT']) print('.. _exit') @@ -8172,7 +8173,7 @@ def test_async_ccall_bad(self): } }; ''') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]'] self.do_runf('main.c', 'The call to main is running asynchronously.') @with_asyncify_and_jspi @@ -8197,7 +8198,7 @@ def test_async_ccall_good(self): ccall('main', null, ['number', 'string'], [2, 'waka'], { async: true }); }; ''') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]'] self.do_runf('main.c', 'HelloWorld') @parameterized({ @@ -8242,7 +8243,7 @@ def test_async_ccall_promise(self, exit_runtime): }); }; ''') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]'] self.do_runf('main.c', 'stringf: first\nsecond\n6.4') @no_esm_integration('WASM_ESM_INTEGRATION is not compatible with ASYNCIFY=1') @@ -8582,7 +8583,7 @@ def test_fs_dict(self): out(typeof NODEFS); }; ''') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[preRun]'] self.do_run('int main() { return 0; }', 'object\nobject\nobject\nobject\nobject\nobject') def test_fs_dict_none(self): @@ -8606,7 +8607,7 @@ def test_fs_dict_none(self): } }; ''') - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[preRun]'] expected = '''\ object undefined @@ -8715,7 +8716,7 @@ def test_postrun_exception(self): def test_postrun_exit_runtime(self): create_file('pre.js', "Module['postRun'] = () => err('post run\\n');") self.set_setting('EXIT_RUNTIME') - self.emcc_args.append('--pre-js=pre.js') + self.emcc_args += ['--pre-js=pre.js', '-sINCOMING_MODULE_JS_API=[postRun]'] self.do_runf('hello_world.c', 'post run') # Tests that building with -sDECLARE_ASM_MODULE_EXPORTS=0 works @@ -9233,7 +9234,7 @@ def test_pthread_exceptions(self): def test_pthread_exit_process(self): self.set_setting('PROXY_TO_PTHREAD') self.set_setting('EXIT_RUNTIME') - self.emcc_args += ['-DEXIT_RUNTIME', '--pre-js', test_file('core/pthread/test_pthread_exit_runtime.pre.js')] + self.emcc_args += ['-DEXIT_RUNTIME', '--pre-js', test_file('core/pthread/test_pthread_exit_runtime.pre.js'), '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized, onExit]'] self.do_run_in_out_file_test('core/pthread/test_pthread_exit_runtime.c', assert_returncode=42) @node_pthreads @@ -9413,7 +9414,7 @@ def test_pthread_dylink_main_module_1(self): def test_Module_dynamicLibraries(self, args): # test that Module.dynamicLibraries works with pthreads self.emcc_args += args - self.emcc_args += ['--pre-js', 'pre.js'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[dynamicLibraries]'] self.emcc_args += ['--js-library', 'lib.js'] # This test is for setting dynamicLibraries at runtime, so we don't # want emscripten loading `liblib.so` automatically (which it would @@ -9589,6 +9590,8 @@ def test_embind_lib_with_asyncify(self, args): '-sASYNCIFY_IMPORTS=sleep_and_return', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$ASSERTIONS', '--post-js', test_file('core/embind_lib_with_asyncify.test.js'), + '--no-entry', + '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]' ] self.emcc_args += args self.do_core_test('embind_lib_with_asyncify.cpp') From 7b49b9f377bd933eef02a3fc8ffb22cd5e6101b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:45:11 +0300 Subject: [PATCH 02/11] Fix strict.test_core_types --- test/core/test_core_types.c | 5 ++++- test/test_core.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/core/test_core_types.c b/test/core/test_core_types.c index 881df580ae2e2..1dd736e5b4d51 100644 --- a/test/core/test_core_types.c +++ b/test/core/test_core_types.c @@ -77,7 +77,10 @@ // We prefer to use __EMSCRIPTEN__, but for compatibility, we define // EMSCRIPTEN too. -#ifndef EMSCRIPTEN +#if defined(IN_STRICT_MODE) && defined(EMSCRIPTEN) +#error When compiling in -sSTRICT mode, EMSCRIPTEN should not be defined, but it was! +#endif +#if !defined(IN_STRICT_MODE) && !defined(EMSCRIPTEN) #error EMSCRIPTEN is not defined #endif diff --git a/test/test_core.py b/test/test_core.py index 5f7d0d34482bc..ac1e48e17eb24 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -646,6 +646,8 @@ def test_sha1(self): self.do_runf('third_party/sha1.c', 'SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6') def test_core_types(self): + if self.get_setting('STRICT'): + self.emcc_args += ['-DIN_STRICT_MODE=1'] self.do_runf('core/test_core_types.c') def test_cube2md5(self): From b457928df2959db511f53af71c1056fd79696ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:45:53 +0300 Subject: [PATCH 03/11] Fix strict.test_getValue_setValue --- test/core/test_getValue_setValue.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/core/test_getValue_setValue.cpp b/test/core/test_getValue_setValue.cpp index c2d68b520d816..e2e3aaec87c10 100644 --- a/test/core/test_getValue_setValue.cpp +++ b/test/core/test_getValue_setValue.cpp @@ -15,20 +15,20 @@ int main() { setValue($0, 1234, 'i32'); out('i32: ' + getValue($0, 'i32')); #ifdef WASM_BIGINT - i64 = getValue($1, 'i64'); + var i64 = getValue($1, 'i64'); out('i64: 0x' + i64.toString(16) + ' ' + typeof(i64)); #endif - ptr = getValue($1, '*'); + var ptr = getValue($1, '*'); out('ptr: 0x' + ptr.toString(16) + ' ' + typeof(ptr)); #else out('i32: ' + getValue($0, 'i32')); Module['setValue']($0, 1234, 'i32'); out('i32: ' + Module['getValue']($0, 'i32')); #ifdef WASM_BIGINT - i64 = Module['getValue']($1, 'i64'); + var i64 = Module['getValue']($1, 'i64'); out('i64: 0x' + i64.toString(16) + ' ' + typeof(i64)); #endif - ptr = Module['getValue']($1, '*'); + var ptr = Module['getValue']($1, '*'); out('ptr: 0x' + ptr.toString(16) + ' ' + typeof(ptr)); #endif From 846c7fc3fe37346451020ef9683df40d928752be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:46:31 +0300 Subject: [PATCH 04/11] Skip strict.test_legacy_exported_runtime_numbers since it is not relevant. --- test/test_core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index ac1e48e17eb24..7d20b4a7ce9bc 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -383,6 +383,7 @@ def decorated(self, textdecoder, *args, **kwargs): no_minimal_runtime = make_no_decorator_for_setting('MINIMAL_RUNTIME') no_safe_heap = make_no_decorator_for_setting('SAFE_HEAP') +no_strict = make_no_decorator_for_setting('STRICT') def is_sanitizing(args): @@ -7138,6 +7139,7 @@ def test(output_prefix='', args=None, assert_returncode=0): test(args=['-sFORCE_FILESYSTEM']) @no_modularize_instance('uses Module object directly') + @no_strict('This test verifies legacy behavior that does not apply to -sSTRICT builds.') def test_legacy_exported_runtime_numbers(self): # these used to be exported, but no longer are by default def test(expected, args=None, assert_returncode=0): From 0544f4eb7125544f0476b6083ef133cda2ad0c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:47:00 +0300 Subject: [PATCH 05/11] Add missing -l<> specifiers to fix tests in strict mode. --- test/test_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_core.py b/test/test_core.py index 7d20b4a7ce9bc..4d58cded281bb 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -9406,7 +9406,7 @@ def test_pthread_dylink_longjmp(self): @needs_dylink @node_pthreads def test_pthread_dylink_main_module_1(self): - self.emcc_args += ['-Wno-experimental', '-pthread'] + self.emcc_args += ['-Wno-experimental', '-pthread', '-lhtml5'] self.set_setting('MAIN_MODULE') self.do_runf('hello_world.c') @@ -9567,7 +9567,7 @@ def test_abort_on_exceptions_pthreads(self): @needs_dylink def test_gl_main_module(self): self.set_setting('MAIN_MODULE') - self.emcc_args += ['-sGL_ENABLE_GET_PROC_ADDRESS'] + self.emcc_args += ['-sGL_ENABLE_GET_PROC_ADDRESS', '-lGL'] self.do_runf('core/test_gl_get_proc_address.c') @needs_dylink From ec44ddd1b1f0618e66f0c4439007570c8e12a03e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:47:48 +0300 Subject: [PATCH 06/11] Fix strict.test_abort_on_exceptions --- test/test_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_core.py b/test/test_core.py index 4d58cded281bb..54d87f3b1b034 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -9539,7 +9539,7 @@ def test_abort_on_exceptions(self): self.set_setting('ABORT_ON_WASM_EXCEPTIONS') self.set_setting('ALLOW_TABLE_GROWTH') self.set_setting('EXPORTED_RUNTIME_METHODS', ['ccall', 'cwrap']) - self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$addFunction']) + self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$addFunction', '$addOnPostRun']) self.emcc_args += ['-lembind', '--post-js', test_file('core/test_abort_on_exceptions_post.js')] self.do_core_test('test_abort_on_exceptions.cpp', interleaved_output=False) From 3c2d5406bc56c6194b0596680df857e7ced7a97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:48:50 +0300 Subject: [PATCH 07/11] Disable unknown failing strict tests. --- test/test_core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index 54d87f3b1b034..2b4984fc98c26 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5428,6 +5428,7 @@ def test_langinfo(self): self.do_core_test('test_langinfo.c') @no_modularize_instance('uses Module object directly') + @no_strict('TODO: Fails in -sSTRICT mode due to an unknown reason.') def test_files(self): # Use closure here, to test we don't break FS stuff if '-O3' in self.emcc_args and self.is_wasm2js(): @@ -7693,6 +7694,7 @@ def test_embind_wasm_workers(self): 'all_growth': ('ALL', True), }) @no_modularize_instance('uses Module global') + @no_strict('TODO: Fails in -sSTRICT mode due to an unknown reason.') def test_webidl(self, mode, allow_memory_growth): self.set_setting('WASM_ASYNC_COMPILATION', 0) if self.maybe_closure(): From e3a1c65bb8b8442c973857912d822891304e4caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 16:49:11 +0300 Subject: [PATCH 08/11] Add missing linkage to -lstubs in strict tests. --- test/test_core.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_core.py b/test/test_core.py index 2b4984fc98c26..5c5c56a0526e1 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -6164,6 +6164,8 @@ def test_posixtime(self): self.do_core_test('test_posixtime.c') def test_uname(self): + if self.get_setting('STRICT'): + self.emcc_args += ['-lstubs'] self.do_core_test('test_uname.c', regex=True) def test_unary_literal(self): @@ -6193,6 +6195,8 @@ def test_stddef(self): self.do_core_test('test_stddef.cpp', force_c=True) def test_getloadavg(self): + if self.get_setting('STRICT'): + self.emcc_args += ['-lstubs'] self.do_core_test('test_getloadavg.c') def test_nl_types(self): @@ -6768,6 +6772,8 @@ def test_freetype(self): 'pthreads': (True,), }) def test_sqlite(self, use_pthreads): + if self.get_setting('STRICT'): + self.emcc_args += ['-lstubs'] if use_pthreads: self.emcc_args.append('-pthread') self.setup_node_pthreads() From ff33a9eb08610b2aa853065607590db183318752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 21:59:21 +0300 Subject: [PATCH 09/11] ruff --- test/test_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_core.py b/test/test_core.py index 5c5c56a0526e1..e02223eb62407 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -9603,7 +9603,7 @@ def test_embind_lib_with_asyncify(self, args): '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$ASSERTIONS', '--post-js', test_file('core/embind_lib_with_asyncify.test.js'), '--no-entry', - '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]' + '-sINCOMING_MODULE_JS_API=[onRuntimeInitialized]', ] self.emcc_args += args self.do_core_test('embind_lib_with_asyncify.cpp') From 81a729446cfb1bb12ebf3d03c0fd9e4b000407a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 29 May 2025 23:39:03 +0300 Subject: [PATCH 10/11] Update test_core.py --- test/test_core.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/test_core.py b/test/test_core.py index e02223eb62407..681424d964b93 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5440,7 +5440,7 @@ def test_files(self): else: self.maybe_closure() - self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[noFSInit, preRun]'] + self.emcc_args += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=[preRun]'] self.set_setting('FORCE_FILESYSTEM') create_file('pre.js', ''' @@ -9414,7 +9414,11 @@ def test_pthread_dylink_longjmp(self): @needs_dylink @node_pthreads def test_pthread_dylink_main_module_1(self): - self.emcc_args += ['-Wno-experimental', '-pthread', '-lhtml5'] + # TODO: For some reason, -lhtml5 must be passed in -sSTRICT mode, but can NOT + # be passed when not compiling in -sSTRICT mode. That does not seem intentional? + if self.get_setting('STRICT'): + self.emcc_args += ['-lhtml5'] + self.emcc_args += ['-Wno-experimental', '-pthread'] self.set_setting('MAIN_MODULE') self.do_runf('hello_world.c') @@ -9574,8 +9578,12 @@ def test_abort_on_exceptions_pthreads(self): @needs_dylink def test_gl_main_module(self): + # TODO: For some reason, -lGL must be passed in -sSTRICT mode, but can NOT + # be passed when not compiling in -sSTRICT mode. That does not seem intentional? + if self.get_setting('STRICT'): + self.emcc_args += ['-lGL'] self.set_setting('MAIN_MODULE') - self.emcc_args += ['-sGL_ENABLE_GET_PROC_ADDRESS', '-lGL'] + self.emcc_args += ['-sGL_ENABLE_GET_PROC_ADDRESS'] self.do_runf('core/test_gl_get_proc_address.c') @needs_dylink From 67c5c29b68a1882a0b7e625439e116afffe1dfe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Fri, 30 May 2025 00:29:51 +0300 Subject: [PATCH 11/11] Build FreeType before adjusting emcc_args --- test/test_core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_core.py b/test/test_core.py index 681424d964b93..38c4c0ff14f4b 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -6726,6 +6726,10 @@ def test_gcc_unmangler(self): @needs_make('configure script') @is_slow_test def test_freetype(self): + # Not needed for js, but useful for debugging + shutil.copy(test_file('freetype/LiberationSansBold.ttf'), 'font.ttf') + ftlib = self.get_freetype_library() + if self.get_setting('WASMFS'): self.emcc_args += ['-sFORCE_FILESYSTEM'] @@ -6733,10 +6737,6 @@ def test_freetype(self): list(bytearray(read_binary(test_file('freetype/LiberationSansBold.ttf')))), )) - # Not needed for js, but useful for debugging - shutil.copy(test_file('freetype/LiberationSansBold.ttf'), 'font.ttf') - ftlib = self.get_freetype_library() - # Main self.do_run_in_out_file_test('freetype/main.c', args=['font.ttf', 'test!', '150', '120', '25'],