From b4d8041be6c08361a3bb3a01b2d01297859de10a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 18 Feb 2025 09:52:45 -0800 Subject: [PATCH] Fix -sMODULARIZE + -sLEGACY_VM_SUPPORT When we run babel in `-sMODULARIZE` mode the input to babel contains `await` calls. This code appears to be top-level code at the point at which we run babel since we have yet to perform the modularization process which wraps the output in a factory function. Fixes: #23687 --- src/lib/libglemu.js | 5 ----- test/test_other.py | 3 +++ tools/building.py | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/libglemu.js b/src/lib/libglemu.js index e84ea0b9f7b62..765652215e7c1 100644 --- a/src/lib/libglemu.js +++ b/src/lib/libglemu.js @@ -61,11 +61,6 @@ var LibraryGLEmulation = { '/**@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: { diff --git a/test/test_other.py b/test/test_other.py index 1275cfcb75678..2820d21844262 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -7098,6 +7098,9 @@ class Descriptor { self.run_process([EMXX, 'src.cpp', '-O2', '-sEXPORT_ALL']) self.assertExists('a.out.js') + def test_modularize_legacy(self): + self.do_runf('hello_world.c', emcc_args=['-sMODULARIZE', '-sLEGACY_VM_SUPPORT']) + def test_emmake_emconfigure(self): def check(what, args, fail=True, expect=''): args = [what] + args diff --git a/tools/building.py b/tools/building.py index 6e0af701f2c20..9f30275e32de3 100644 --- a/tools/building.py +++ b/tools/building.py @@ -511,7 +511,7 @@ def version_split(v): @ToolchainProfiler.profile() def transpile(filename): config = { - 'sourceType': 'script', + 'sourceType': 'module', 'targets': {} } if settings.MIN_CHROME_VERSION != UNSUPPORTED: