diff --git a/ChangeLog.md b/ChangeLog.md index 0b001a962adab..74590949c67e2 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works. 4.0.21 (in development) ----------------------- +- The emscripten tools will now warn if they are not run via the launcher + scripts. i.e. it is no longer officially supported to run `python emcc.py`. + Instead, `emcc` should be run directly (via the provided `.bat` or shell + script). (#20437) - The `-sPROXY_TO_WORKER` setting (along with the corresponding `--proxy-to-worker` flag) was removed due to lack of usage. If you were depending on this feature but missed the PSA, please let us know about your diff --git a/bootstrap b/bootstrap index 26334343d9eaa..782bfa2e1132f 100755 --- a/bootstrap +++ b/bootstrap @@ -30,4 +30,5 @@ if [ -z "$_EM_PY" ]; then exit 1 fi +export _EM_LAUNCHER=1 exec "$_EM_PY" -E "$0.py" "$@" diff --git a/bootstrap.bat b/bootstrap.bat index e9080623b77f0..e370c8b30c51f 100644 --- a/bootstrap.bat +++ b/bootstrap.bat @@ -10,6 +10,9 @@ :: All env. vars specified in this file are to be local only to this script. @setlocal + +@set _EM_LAUNCHER=1 + :: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal :: of cpython used in cross compilation via setup.py. @set _PYTHON_SYSCONFIGDATA_NAME= diff --git a/em++ b/em++ index bdbda2fbb9244..c0d052e945a15 100755 --- a/em++ +++ b/em++ @@ -30,6 +30,7 @@ if [ -z "$_EM_PY" ]; then exit 1 fi +export _EM_LAUNCHER=1 if [ -z "$_EMCC_CCACHE" ]; then exec "$_EM_PY" -E "$0.py" "$@" else diff --git a/em++.bat b/em++.bat index dd5aa6565a35b..82ca72491b085 100644 --- a/em++.bat +++ b/em++.bat @@ -10,9 +10,13 @@ :: All env. vars specified in this file are to be local only to this script. @setlocal + +@set _EM_LAUNCHER=1 + :: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal :: of cpython used in cross compilation via setup.py. @set _PYTHON_SYSCONFIGDATA_NAME= + @set _EM_PY=%EMSDK_PYTHON% @if "%_EM_PY%"=="" ( set _EM_PY=python diff --git a/emcc b/emcc index bdbda2fbb9244..c0d052e945a15 100755 --- a/emcc +++ b/emcc @@ -30,6 +30,7 @@ if [ -z "$_EM_PY" ]; then exit 1 fi +export _EM_LAUNCHER=1 if [ -z "$_EMCC_CCACHE" ]; then exec "$_EM_PY" -E "$0.py" "$@" else diff --git a/emcc.bat b/emcc.bat index dd5aa6565a35b..82ca72491b085 100644 --- a/emcc.bat +++ b/emcc.bat @@ -10,9 +10,13 @@ :: All env. vars specified in this file are to be local only to this script. @setlocal + +@set _EM_LAUNCHER=1 + :: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal :: of cpython used in cross compilation via setup.py. @set _PYTHON_SYSCONFIGDATA_NAME= + @set _EM_PY=%EMSDK_PYTHON% @if "%_EM_PY%"=="" ( set _EM_PY=python diff --git a/test/runner b/test/runner index 26334343d9eaa..782bfa2e1132f 100755 --- a/test/runner +++ b/test/runner @@ -30,4 +30,5 @@ if [ -z "$_EM_PY" ]; then exit 1 fi +export _EM_LAUNCHER=1 exec "$_EM_PY" -E "$0.py" "$@" diff --git a/test/runner.bat b/test/runner.bat index e9080623b77f0..e370c8b30c51f 100644 --- a/test/runner.bat +++ b/test/runner.bat @@ -10,6 +10,9 @@ :: All env. vars specified in this file are to be local only to this script. @setlocal + +@set _EM_LAUNCHER=1 + :: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal :: of cpython used in cross compilation via setup.py. @set _PYTHON_SYSCONFIGDATA_NAME= diff --git a/test/test_other.py b/test/test_other.py index deed55ef59e96..c35345ce48000 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -15210,3 +15210,7 @@ def test_binary_encode(self): console.log('OK');''' write_file('test.js', read_file(path_from_root('src/binaryDecode.js')) + '\nvar src = ' + binary_encoded + ';\n' + test_js) self.assertContained('OK', self.run_js('test.js')) + + def test_direct_usage_warning(self): + err = self.run_process([sys.executable, path_from_root('emcc.py'), '--version'], stderr=PIPE).stderr + self.assertContained('emcc: warning: python script (`emcc.py`) was run directly rather than run via launcher', err) diff --git a/tools/maint/run_python.bat b/tools/maint/run_python.bat index e9080623b77f0..e370c8b30c51f 100644 --- a/tools/maint/run_python.bat +++ b/tools/maint/run_python.bat @@ -10,6 +10,9 @@ :: All env. vars specified in this file are to be local only to this script. @setlocal + +@set _EM_LAUNCHER=1 + :: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal :: of cpython used in cross compilation via setup.py. @set _PYTHON_SYSCONFIGDATA_NAME= diff --git a/tools/maint/run_python.sh b/tools/maint/run_python.sh index 26334343d9eaa..782bfa2e1132f 100755 --- a/tools/maint/run_python.sh +++ b/tools/maint/run_python.sh @@ -30,4 +30,5 @@ if [ -z "$_EM_PY" ]; then exit 1 fi +export _EM_LAUNCHER=1 exec "$_EM_PY" -E "$0.py" "$@" diff --git a/tools/maint/run_python_compiler.bat b/tools/maint/run_python_compiler.bat index dd5aa6565a35b..82ca72491b085 100644 --- a/tools/maint/run_python_compiler.bat +++ b/tools/maint/run_python_compiler.bat @@ -10,9 +10,13 @@ :: All env. vars specified in this file are to be local only to this script. @setlocal + +@set _EM_LAUNCHER=1 + :: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal :: of cpython used in cross compilation via setup.py. @set _PYTHON_SYSCONFIGDATA_NAME= + @set _EM_PY=%EMSDK_PYTHON% @if "%_EM_PY%"=="" ( set _EM_PY=python diff --git a/tools/maint/run_python_compiler.sh b/tools/maint/run_python_compiler.sh index bdbda2fbb9244..c0d052e945a15 100644 --- a/tools/maint/run_python_compiler.sh +++ b/tools/maint/run_python_compiler.sh @@ -30,6 +30,7 @@ if [ -z "$_EM_PY" ]; then exit 1 fi +export _EM_LAUNCHER=1 if [ -z "$_EMCC_CCACHE" ]; then exec "$_EM_PY" -E "$0.py" "$@" else diff --git a/tools/shared.py b/tools/shared.py index a51ca7974e26c..221df62f61f14 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -620,6 +620,13 @@ def get_llvm_target(): def init(): utils.set_version_globals() setup_temp_dirs() + if '_EM_LAUNCHER' not in os.environ: + actual = bat_suffix(os.path.basename(sys.argv[0])) + launcher = os.path.splitext(actual)[0] + diagnostics.warning('unsupported', f'python script (`{actual}`) was run directly rather than run via launcher. Running via `{launcher}` is recommended') + else: + # We don't want subprocesses to inherit this environment variable. + del os.environ['_EM_LAUNCHER'] # ============================================================================