Repository navigation
Description
Background
The native build pipeline already replaced the slow clang-tool-chain-*-cpp.EXE Python entry points (~828ms startup each) with raw clang++.exe resolved by _resolve_fast_native_entries() in ci/meson/build_config.py. That single change cut Meson setup from 27.60s → 10.13s (-63%) and total build from 47.58s → 21.66s (-54%).
The WASM build path was not migrated and still pays the Python-wrapper cost on every compile.
Current state
ci/meson/wasm_cross_file.ini:17-19:
c = 'clang-tool-chain-emcc'
cpp = 'clang-tool-chain-emcc'
ar = 'clang-tool-chain-emar'
These are Python entry points (clang_tool_chain.wrapper:emcc_main, etc.). Each invocation pays the ~800ms+ Python startup tax.
What already exists
The native C++ launchers are already built and sitting in the cache directory:
.build/native-tools/ctc-emcc.exe— three-tier strategy compiled fromlauncher_emcc.cpp(inclang_tool_chain/native_tools/):- User template (
--compile-commands/--link-args): pre-cached clang/wasm-ld command with{input}/{output}substitution. - Auto-cache: on first compile with
EMCC_VERBOSE=1, captures the real clang command from stderr, templatizes it, caches by flag hash; subsequent same-flag compiles call clang directly. - Python fallback: link/preprocess/uncached invocations exec the Python
emcc.py.
- User template (
.build/native-tools/ctc-wasm-ld.exe— same idea for the linker.clang-tool-chainships the launcher source;clang-tool-chain-bins(already installed, 0.4.1) ships the underlying emcc/node binaries;clang_tool_chain.commands.compile_native.compile_native()builds the launcher on demand.
The integration plumbing (_ensure_native_launcher(), _resolve_fast_native_entries()) already exists for ctc-clang/ctc-clang++. The WASM launchers are just not wired in yet.
Proposed change
Three files:
ci/meson/wasm_cross_file.ini— pointc/cpp/arat the compiledctc-emcc.exe/ctc-emar(or template variables resolved at generation time) instead of the Python entry points.ci/meson/build_config.py— extend_resolve_fast_native_entries()(line 186) and_ensure_native_launcher()(line 52) to also build/cache the emcc launchers, mirroring the clang++ path.ci/wasm_build.py— generate a WASM-flavored native file (or supplement the cross-file) so meson picks up the resolved binaries duringensure_meson_configured().
Fallback: if the native launcher build fails, keep the Python wrapper as the resolved value so the WASM build doesn't break.
Expected payoff
Similar magnitude to the native build win — likely 50–60% reduction in WASM meson setup time and a meaningful drop in compilation wall-clock from removing per-invocation Python startup.
Acceptance
- WASM
meson setupinvokesctc-emcc.exe(verifiable in the generated cross-file or native file). - A clean WASM build (
bash compile wasm --examples Blink) runs end-to-end with the native launcher. - Benchmark: before/after timings recorded in the PR description.
- Python-wrapper fallback path is exercised at least once (e.g., simulated by removing the cached native binary).
Activity
perf(wasm): wire ctc-emcc native launcher into WASM cross-file (#2487)