From 4ce8e65fba5a6fe61aac089c5389b1f6d6499d5a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 4 Sep 2026 12:19:27 -0700 Subject: [PATCH] Remove usage of shared.EMCC et al from test code. NFC Move tool paths (such as `EMCC`, `LLVM_COV`, `LLVM_PROFDATA`, and `WASM_LD`) from `tools/shared.py` to `test/common.py` or `tools/building.py`. Also, remove the dead `_is_ar_cache` from `tools/building.py`. Part of the effort to decouple test code from compiler internals. See: #27666 --- test/benchmark/benchmark_sse.py | 4 ++-- test/browser_common.py | 4 ++-- test/common.py | 10 +++++++++- test/sockets_common.py | 4 ++-- test/test_benchmark.py | 5 +++-- test/test_browser.py | 3 ++- test/test_core.py | 12 ++++++++---- test/test_emrun.py | 5 ++--- test/test_jslib.py | 3 +-- test/test_other.py | 12 ++++++------ test/test_sanity.py | 5 +++-- test/test_sockets_node.py | 4 +--- tools/building.py | 3 +-- tools/shared.py | 3 --- 14 files changed, 42 insertions(+), 35 deletions(-) diff --git a/test/benchmark/benchmark_sse.py b/test/benchmark/benchmark_sse.py index 8fe1ba7de64d1..aebca3b827d2a 100644 --- a/test/benchmark/benchmark_sse.py +++ b/test/benchmark/benchmark_sse.py @@ -18,10 +18,10 @@ sys.path.insert(0, __testdir__) import clang_native -from common import EMRUN, test_file +from common import EMCC, EMRUN, test_file from tools import config -from tools.shared import CLANG_CXX, EMCC +from tools.shared import CLANG_CXX from tools.utils import WINDOWS, run_process, write_file # System info diff --git a/test/browser_common.py b/test/browser_common.py index 19d69677f624d..8d15aa1e295b6 100644 --- a/test/browser_common.py +++ b/test/browser_common.py @@ -22,6 +22,7 @@ import common import psutil from common import ( + EMCC, TEST_ROOT, RunnerCore, compiler_for, @@ -37,8 +38,7 @@ from tools import feature_matrix, utils from tools.feature_matrix import OLDEST_SUPPORTED_FIREFOX, UNSUPPORTED -from tools.shared import EMCC, exit_with_error -from tools.utils import LINUX, MACOS, WINDOWS, memoize, path_from_root, read_binary +from tools.utils import LINUX, MACOS, WINDOWS, exit_with_error, memoize, path_from_root, read_binary logger = logging.getLogger('common') diff --git a/test/common.py b/test/common.py index 86dcefeb9a134..c5c7e1532caa9 100644 --- a/test/common.py +++ b/test/common.py @@ -31,7 +31,7 @@ from tools import building, config, shared, utils from tools.feature_matrix import Feature from tools.settings import COMPILE_TIME_SETTINGS -from tools.shared import EMCC, EMXX, get_canonical_temp_dir +from tools.shared import get_canonical_temp_dir from tools.utils import ( WINDOWS, exe_path_from_root, @@ -76,8 +76,16 @@ EMCONFIGURE = exe_path_from_root('emconfigure') EMCONFIG = exe_path_from_root('em-config') EMRUN = exe_path_from_root('emrun') +EMCC = exe_path_from_root('emcc') +EMXX = exe_path_from_root('em++') +EMAR = exe_path_from_root('emar') +EMRANLIB = exe_path_from_root('emranlib') +FILE_PACKAGER = exe_path_from_root('tools/file_packager') WASM_DIS = os.path.join(building.get_binaryen_bin(), 'wasm-dis') +WASM_LD = shared.llvm_tool_path('wasm-ld') +LLVM_COV = shared.llvm_tool_path('llvm-cov') LLVM_OBJDUMP = shared.llvm_tool_path('llvm-objdump') +LLVM_PROFDATA = shared.llvm_tool_path('llvm-profdata') PYTHON = sys.executable diff --git a/test/sockets_common.py b/test/sockets_common.py index d55e25cfa1577..02e42440540e0 100644 --- a/test/sockets_common.py +++ b/test/sockets_common.py @@ -18,11 +18,11 @@ import clang_native import common -from common import PYTHON +from common import EMCC, PYTHON from decorators import test_file from tools import config -from tools.shared import CLANG_CC, EMCC +from tools.shared import CLANG_CC from tools.utils import run_process npm_checked = False diff --git a/test/test_benchmark.py b/test/test_benchmark.py index 3630285a63fc4..890901273cbcc 100644 --- a/test/test_benchmark.py +++ b/test/test_benchmark.py @@ -17,6 +17,7 @@ import zlib from abc import ABC, abstractmethod from pathlib import Path +from subprocess import PIPE if __name__ == '__main__': raise Exception('do not run this file directly; do something like: test/runner.py benchmark') @@ -24,11 +25,11 @@ import clang_native import common import jsrun -from common import compiler_for, copy_asset, read_binary, read_file, test_file +from common import EMCC, compiler_for, copy_asset, read_binary, read_file, test_file from decorators import needs_make, parameterized from tools import utils -from tools.shared import CLANG_CC, CLANG_CXX, EMCC, PIPE, config +from tools.shared import CLANG_CC, CLANG_CXX, config from tools.utils import run_process # standard arguments for timing: diff --git a/test/test_browser.py b/test/test_browser.py index a508c0396dfd6..ce35e41905e63 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -38,6 +38,8 @@ is_safari, ) from common import ( + EMCC, + FILE_PACKAGER, WEBIDL_BINDER, copy_asset, copytree, @@ -72,7 +74,6 @@ from tools import ports, shared, utils from tools.feature_matrix import Feature from tools.link import binary_encode -from tools.shared import EMCC, FILE_PACKAGER from tools.utils import WINDOWS, delete_dir, write_binary, write_file diff --git a/test/test_core.py b/test/test_core.py index 47f160ce17647..ff54c14942cec 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -13,6 +13,7 @@ import time from functools import wraps from pathlib import Path +from subprocess import PIPE if __name__ == '__main__': raise Exception('do not run this file directly; do something like: test/runner') @@ -20,7 +21,13 @@ import clang_native import common from common import ( + EMAR, EMBUILDER, + EMCC, + EMXX, + FILE_PACKAGER, + LLVM_COV, + LLVM_PROFDATA, NON_ZERO, PYTHON, WEBIDL_BINDER, @@ -79,7 +86,6 @@ ) from tools import building, config, shared, utils, webassembly -from tools.shared import EMAR, EMCC, EMXX, FILE_PACKAGER, LLVM_COV, LLVM_PROFDATA, PIPE from tools.utils import LINUX, MACOS, WINDOWS, delete_file, write_file # decorators for limiting which modes a test can run in @@ -6866,9 +6872,7 @@ def test_sse_diagnostics(self): self.cflags.remove('-Werror') src = test_file('sse/test_sse_diagnostic.cpp') - p = self.run_process( - [shared.EMXX, src, '-msse', '-DWASM_SIMD_COMPAT_SLOW'] + self.get_cflags(), - stderr=PIPE) + p = self.run_process([EMXX, src, '-msse', '-DWASM_SIMD_COMPAT_SLOW'] + self.get_cflags(), stderr=PIPE) self.assertContained('Instruction emulated via slow path.', p.stderr) @wasm_relaxed_simd diff --git a/test/test_emrun.py b/test/test_emrun.py index 72c0da0d82826..813507fb49d04 100644 --- a/test/test_emrun.py +++ b/test/test_emrun.py @@ -7,13 +7,12 @@ import os import shlex import subprocess +from subprocess import PIPE from browser_common import BrowserCore, get_browser, has_browser -from common import EMRUN, RunnerCore, path_from_root, read_file, test_file +from common import EMCC, EMRUN, RunnerCore, path_from_root, read_file, test_file from decorators import also_with_pthreads -from tools.shared import EMCC, PIPE - class emrun(RunnerCore): def test_emrun_info(self): diff --git a/test/test_jslib.py b/test/test_jslib.py index 4d210d4716e8e..550b44615ed0f 100644 --- a/test/test_jslib.py +++ b/test/test_jslib.py @@ -5,10 +5,9 @@ from subprocess import PIPE -from common import RunnerCore, copy_asset, create_file, read_file, test_file +from common import EMCC, RunnerCore, copy_asset, create_file, read_file, test_file from decorators import also_with_wasm2js, also_with_wasm64, parameterized, requires_node_25 -from tools.shared import EMCC from tools.utils import delete_file diff --git a/test/test_other.py b/test/test_other.py index bf9886cc547cc..ca4b7f55825c5 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -35,14 +35,20 @@ import jsrun import line_endings from common import ( + EMAR, EMBUILDER, + EMCC, EMCMAKE, EMCONFIG, EMCONFIGURE, EMMAKE, + EMRANLIB, + EMXX, + FILE_PACKAGER, NON_ZERO, PYTHON, TEST_ROOT, + WASM_LD, WEBIDL_BINDER, RunnerCore, check_node_version, @@ -107,16 +113,10 @@ from tools.shared import ( CLANG_CC, CLANG_CXX, - EMAR, - EMCC, - EMRANLIB, - EMXX, - FILE_PACKAGER, LLVM_AR, LLVM_DWARFDUMP, LLVM_DWP, LLVM_NM, - WASM_LD, config, ) from tools.system_libs import DETERMINISTIC_PREFIX diff --git a/test/test_sanity.py b/test/test_sanity.py index c0fa7bc77475a..e599eca77e08f 100644 --- a/test/test_sanity.py +++ b/test/test_sanity.py @@ -15,7 +15,9 @@ from common import ( EMBUILDER, + EMCC, EMCONFIG, + EMXX, RunnerCore, create_file, ensure_dir, @@ -27,9 +29,8 @@ ) from decorators import no_windows, only_windows, parameterized, with_env_modify -from tools import building, cache, ports, response_file, shared, utils +from tools import building, cache, config, ports, response_file, shared, utils from tools.config import EM_CONFIG -from tools.shared import EMCC, EMXX, config from tools.utils import delete_dir, delete_file SANITY_FILE = cache.get_path('sanity.txt') diff --git a/test/test_sockets_node.py b/test/test_sockets_node.py index 16ec7db2815aa..f549d996258e9 100644 --- a/test/test_sockets_node.py +++ b/test/test_sockets_node.py @@ -12,7 +12,7 @@ raise Exception('do not run this file directly; do something like: test/runner sockets_node') import common -from common import NON_ZERO, RunnerCore, create_file +from common import EMCC, NON_ZERO, RunnerCore, create_file from decorators import ( also_with_proxy_to_pthread, crossplatform, @@ -30,8 +30,6 @@ requires_python_dev_packages, ) -from tools.shared import EMCC - def requires_jspi_node(func): # require_jspi() falls back to the d8/SpiderMonkey shells when node is too diff --git a/tools/building.py b/tools/building.py index ea9059e5a61ce..ccd0a011084f0 100644 --- a/tools/building.py +++ b/tools/building.py @@ -40,7 +40,6 @@ LLVM_NM, LLVM_OBJCOPY, LLVM_OBJDUMP, - WASM_LD, asmjs_mangle, check_call, demangle_c_symbol_name, @@ -57,8 +56,8 @@ # Building binaryen_checked = False EXPECTED_BINARYEN_VERSION = 132 +WASM_LD = shared.llvm_tool_path('wasm-ld') -_is_ar_cache: dict[str, bool] = {} # the exports the user requested user_requested_exports: set[str] = set() # JS library symbols exported via the `__export` decorator. diff --git a/tools/shared.py b/tools/shared.py index 5698881bbe3c1..8cb17a97b1201 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -637,9 +637,6 @@ def init(): LLVM_DWARFDUMP = llvm_tool_path('llvm-dwarfdump') LLVM_OBJCOPY = llvm_tool_path('llvm-objcopy') LLVM_OBJDUMP = llvm_tool_path('llvm-objdump') -WASM_LD = llvm_tool_path('wasm-ld') -LLVM_PROFDATA = llvm_tool_path('llvm-profdata') -LLVM_COV = llvm_tool_path('llvm-cov') EMCC = exe_path_from_root('emcc') EMXX = exe_path_from_root('em++')