Skip to content

perf(wasm): bump clang-tool-chain to 1.4.0 and wire ctc-emar native launcher - #2489

Merged
zackees merged 2 commits into
masterfrom
bump-clang-tool-chain-1-4-0
May 19, 2026
Merged

zackees merged 2 commits into
masterfrom
bump-clang-tool-chain-1-4-0

Conversation

@zackees

@zackees zackees commented May 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #2487. clang-tool-chain 1.3.1 added a native ctc-emar launcher (along with ctc-emranlib / ctc-emnm / ctc-emstrip aliases via the emtool TOOL_REGISTRY entry). PR #2487 explicitly noted ar could 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.0
  • ci/meson/build_config.py: _ensure_emcc_native_launcher now also returns the ctc-emar path; resolve_wasm_native_entries wires it into WasmNativeEntries.ar, falling back to the Python clang-tool-chain-emar wrapper if the native binary is missing for any reason.
  • ci/wasm_build.py: log whether ctc-emar resolved 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)

Version Change Impact
1.3.1 New emtool launcher (ctc-emar + aliases) ✅ Wired in this PR
1.3.2 Linux libunwind injection fix Cosmetic; helps native Linux builds
1.3.3 macOS strip -lunwind fix in zccache shim Cosmetic; helps native macOS builds
1.4.0 Renamed PyPI entry points ++ → -cpp (e.g. clang-tool-chain-em++ → clang-tool-chain-em-cpp) Does NOT affect us — grepped the codebase, every FastLED reference uses unrenamed names (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/Blink on Windows:

Variant Total
Before (#2487, Python clang-tool-chain-emar) 61.36s
After (native ctc-emar.exe) 44.41s (~28% reduction)

What's still on the table (not in this PR)

  • ctc-wasm-ld native 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-emstrip for the cross-file strip field. We currently use strip = '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 declare ranlib or nm fields, so there is nothing to wire today. If a future change adds them, the launchers are already available.

Test plan

  • bash lint — pass
  • bash compile wasm --examples Blink — pass, log confirms both [WASM] Using native ctc-emcc launcher and [WASM] Using native ctc-emar launcher
  • bash test --cpp — pass except for the pre-existing fl_channels_all_drivers duplicate-symbol linker failure (verified failing on master with these changes stashed)
  • Verified no FastLED reference uses any of the 1.4.0 renamed ++ PyPI entry points

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Enhanced WebAssembly build flow: unified detection of native emcc/em++/emar launchers, improved "all-or-none" presence checks with safer fallback when native tools are missing, and preference for a native archiver when available while falling back to the wrapper otherwise.
  • Chores

    • Updated clang-tool-chain dependency requirement to version 1.4.0 or later

Review Change Stack

…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]>
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds 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.

Changes

Native WASM Archiver Launcher Support

Layer / File(s) Summary
EmccNativeLaunchers dataclass
ci/meson/build_config.py
Adds EmccNativeLaunchers to hold optional absolute paths for ctc-emcc, ctc-em++, and ctc-emar.
Ensure native launcher binaries
ci/meson/build_config.py
_ensure_emcc_native_launcher() now resolves/compiles all three launchers and returns an EmccNativeLaunchers with per-binary presence reporting and an all-None failure return.
Integrate native entries resolution
ci/meson/build_config.py
resolve_wasm_native_entries() consumes the EmccNativeLaunchers, returns Python wrapper entries unless both native compilers are present, and prefers native ctc-emar for ar when available (else clang-tool-chain-emar).
WASM cross-file archiver validation
ci/wasm_build.py
_render_wasm_cross_file() guards selection of native ctc-emar: it uses native ctc-emar only when entries.ar matches expected executable names, otherwise logs and falls back to the Python ar wrapper.
Dependency version requirement
pyproject.toml
Raise clang-tool-chain minimum from >=1.2.9 to >=1.4.0.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2487: Modifies the same launcher resolution and wasm cross-file selection logic; this PR extends that wiring to include ctc-emar.

Poem

🐰 I hopped through builds to find an emar,
emcc and em++ leapt in from afar,
If native archiver shows its face, we pick it with cheer,
Else Python wraps tidy, no error to fear,
A small bump in tools and the pipeline is clear.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the two main changes: bumping clang-tool-chain to 1.4.0 and integrating the ctc-emar native launcher into the WASM build system.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bump-clang-tool-chain-1-4-0

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b94ab3a and 5f38e2d.

📒 Files selected for processing (3)
  • ci/meson/build_config.py
  • ci/wasm_build.py
  • pyproject.toml

Comment thread ci/meson/build_config.py Resolved
…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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ci/meson/build_config.py (1)

52-63: ⚡ Quick win

Add @typechecked decorator for runtime type validation.

The new dataclass should use the @typechecked decorator 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 typechecked

Then apply the decorator:

+@typechecked
 `@dataclass`(slots=True)
 class EmccNativeLaunchers:
     """Compiled emscripten-tool launcher paths produced by ``compile_native()``.

As per coding guidelines, "Use @typechecked decorator with @dataclass for 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f38e2d and 24d12f3.

📒 Files selected for processing (1)
  • ci/meson/build_config.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant