Repository navigation
perf(wasm): bump clang-tool-chain to 1.4.0 and wire ctc-emar native launcher - #2489
Conversation
…auncher The 1.3.1 release added a native ctc-emar launcher (emtool family, which also produces ctc-emranlib / ctc-emnm / ctc-emstrip aliases). PR #2487 explicitly noted that the WASM cross-file's "ar" field could not be wired to a native binary because no ctc-emar launcher existed yet — that gap is now closed. Bumps the pin to >=1.4.0 to also pick up: - 1.3.2 Linux libunwind injection fix - 1.3.3 macOS strip -lunwind fix in zccache shim - 1.4.0 PyPI entry-point rename (++ -> -cpp); does NOT affect us since no FastLED reference uses the renamed ++ entry points. Changes: - pyproject.toml: clang-tool-chain>=1.2.9 -> >=1.4.0 - ci/meson/build_config.py: _ensure_emcc_native_launcher now also returns the ctc-emar path; resolve_wasm_native_entries wires it into the WasmNativeEntries.ar slot, falling back to the Python clang-tool-chain-emar wrapper if the native binary is missing. - ci/wasm_build.py: log whether ctc-emar resolved or fell back. Benchmark (single-iteration clean WASM build of examples/Blink): - Before (PR #2487, Python emar): 61.36s - After (native ctc-emar): 44.41s (~28% reduction) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughAdds an EmccNativeLaunchers dataclass and updates launcher resolution to return optional paths for ctc-emcc, ctc-em++, and ctc-emar; resolve_wasm_native_entries now uses that result and enables mixed native/python fallbacks, wasm cross-file generation validates ar selection, and pyproject bumps clang-tool-chain to >=1.4.0. ChangesNative WASM Archiver Launcher Support
Sequence DiagramsequenceDiagram
participant Meson
participant BuildConfig
participant Launcher
participant WasmBuild
participant CrossFile
Meson->>BuildConfig: request native entries
BuildConfig->>Launcher: resolve native launchers
Launcher->>Launcher: compile/cache ctc-emcc, ctc-em++, ctc-emar
Launcher-->>BuildConfig: return EmccNativeLaunchers
BuildConfig->>BuildConfig: decide entries and ar selection
BuildConfig-->>WasmBuild: return entries dict
WasmBuild->>WasmBuild: validate entries.ar name
WasmBuild->>CrossFile: write validated ar path or fallback
CrossFile-->>Meson: cross-file configured
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/meson/build_config.py`:
- Around line 108-110: Create a small frozen dataclass (e.g., EmccLauncherInfo)
with explicit fields for the three launcher return values (name the fields to
match semantics used in _ensure_emcc_native_launcher, e.g., launcher_path,
shim_path, native_path), update _ensure_emcc_native_launcher to return that
dataclass instead of tuple and change its return type hint accordingly, and
update every call site that currently unpacks the tuple (search for tuple
assignments from _ensure_emcc_native_launcher and similar functions) to use
attribute access (instance.launcher_path, etc.); also adjust any
isinstance/tuple checks and import the dataclass type in modules that consume it
so type hints remain correct.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 22fb78fe-6e97-415f-a879-f63a32797ccc
📒 Files selected for processing (3)
ci/meson/build_config.pyci/wasm_build.pypyproject.toml
…aunchers dataclass Addresses CodeRabbit review on PR #2489. Project guideline is to return dataclass structs instead of tuples or dicts for functions with multiple return values; the previous 3-tuple return was positionally fragile and caller-unfriendly. No behavior change: same fields, same fallback semantics. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ci/meson/build_config.py (1)
52-63: ⚡ Quick winAdd
@typecheckeddecorator for runtime type validation.The new dataclass should use the
@typecheckeddecorator to enable runtime validation of field types, catching incorrect assignments early.♻️ Proposed enhancement
First, add the import at the top of the file with other imports:
from typeguard import typecheckedThen apply the decorator:
+@typechecked `@dataclass`(slots=True) class EmccNativeLaunchers: """Compiled emscripten-tool launcher paths produced by ``compile_native()``.As per coding guidelines, "Use
@typecheckeddecorator with@dataclassfor runtime type validation".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/meson/build_config.py` around lines 52 - 63, The EmccNativeLaunchers dataclass lacks the required runtime type validation decorator; import typechecked from typeguard and apply `@typechecked` to the EmccNativeLaunchers class definition (keeping the existing `@dataclass`(slots=True) decorator) so field assignments (emcc, empp, emar) are validated at runtime; add the import `from typeguard import typechecked` alongside the other imports and place `@typechecked` directly above the class declaration.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ci/meson/build_config.py`:
- Around line 52-63: The EmccNativeLaunchers dataclass lacks the required
runtime type validation decorator; import typechecked from typeguard and apply
`@typechecked` to the EmccNativeLaunchers class definition (keeping the existing
`@dataclass`(slots=True) decorator) so field assignments (emcc, empp, emar) are
validated at runtime; add the import `from typeguard import typechecked`
alongside the other imports and place `@typechecked` directly above the class
declaration.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a0fae87c-4244-4d89-9942-9db64693344d
📒 Files selected for processing (1)
ci/meson/build_config.py
Summary
Follow-up to #2487. clang-tool-chain 1.3.1 added a native
ctc-emarlauncher (along withctc-emranlib/ctc-emnm/ctc-emstripaliases via theemtoolTOOL_REGISTRY entry). PR #2487 explicitly notedarcould not be wired to a native binary because no such launcher existed yet — that gap is now closed.Changes
pyproject.toml:clang-tool-chain>=1.2.9→>=1.4.0ci/meson/build_config.py:_ensure_emcc_native_launchernow also returns thectc-emarpath;resolve_wasm_native_entrieswires it intoWasmNativeEntries.ar, falling back to the Pythonclang-tool-chain-emarwrapper if the native binary is missing for any reason.ci/wasm_build.py: log whetherctc-emarresolved or fell back, so the optimization is visible at build time.What else is in 1.4.0 (and why none of it breaks us)
emtoollauncher (ctc-emar + aliases)-lunwindfix in zccache shim++→-cpp(e.g.clang-tool-chain-em++→clang-tool-chain-em-cpp)clang-tool-chain-cpp,clang-tool-chain-emcc,clang-tool-chain-emar). The compiled native binary aliases (ctc-em++.exe,ctc-clang++.exe) still have++— unchanged.Benchmark
Single-iteration clean WASM build of
examples/Blinkon Windows:clang-tool-chain-emar)ctc-emar.exe)What's still on the table (not in this PR)
ctc-wasm-ldnative launcher (also in TOOL_REGISTRY) is invoked by emcc internally during link, not directly from the meson cross-file. Wiring it would require passing-fuse-ld=<path>into the emcc invocation rather than a cross-file change. Separate PR.ctc-emstripfor the cross-filestripfield. We currently usestrip = 'true'(no-op). Switching to actual stripping could regress binary size analysis tooling or change debug behavior — needs an explicit decision, not a drive-by.ctc-emranlib/ctc-emnm. The meson WASM cross-file does not declareranlibornmfields, so there is nothing to wire today. If a future change adds them, the launchers are already available.Test plan
bash lint— passbash compile wasm --examples Blink— pass, log confirms both[WASM] Using native ctc-emcc launcherand[WASM] Using native ctc-emar launcherbash test --cpp— pass except for the pre-existingfl_channels_all_driversduplicate-symbol linker failure (verified failing on master with these changes stashed)++PyPI entry points🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Chores