Skip to content

chore: add clang-format wrapper script for linux arm64 - #75

Draft
floco-af wants to merge 2 commits into
mainfrom
floco/clang-format-arm64
Draft

floco-af wants to merge 2 commits into
mainfrom
floco/clang-format-arm64

Conversation

@floco-af

@floco-af floco-af commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

yarn format:write / yarn format:check fail on Linux arm64 (and any platform other than macOS, Linux x64 and Windows): the clang-format@1.8.0 npm package only bundles binaries for those, and its wrapper throws for linux_arm64. The bundled binary is clang-format 13.0.1.

Instead of patching the package, this adds a small script, scripts/clang-format.mjs, that the format:clang:* scripts now call. The clang-format devDependency stays a plain ^1.8.0 (for its bundled binaries), and the Yarn patch is gone.

The script does what the package wrapper does for our use:

  • expands --glob=<pattern> args with Node's built-in fs.globSync (.nvmrc is Node 22.20), and passes the remaining args plus the matched files to the binary, exiting with its exit code. It errors if the glob matches nothing, since clang-format would otherwise read stdin.
  • picks the binary from, in order:
    1. $CLANG_FORMAT_BINARY, if set,
    2. the bundled binary for the platform (darwin arm64 uses darwin_x64, as the package does),
    3. the first native clang-format on PATH. Anything inside a node_modules directory or starting with #! is skipped, so it never picks a package manager shim and can't call itself.
  • if nothing is found, exits with a hint to pip install clang-format==13.0.1 or set CLANG_FORMAT_BINARY.
  • warns on stderr if a non-bundled binary isn't version 13.0.1, since other versions format differently.

It calls the native binary directly and never the package's JS wrapper. scripts/ is not in the npm package files. CONTRIBUTING.md documents the lookup order.

Test Plan

Dev tooling only, no app behavior change, so no device evidence. On a Linux arm64 machine with clang-format 13.0.1 at ~/.local/bin/clang-format, with ulimit -u capped to guard against recursion:

  • yarn install --immutable: passes; yarn.lock has no clang-format patch entry
  • yarn format:check and yarn format:write: pass, no diff afterwards
  • the glob matches the same 2 files (identical lists) as the package's own glob for both the check and write patterns
  • yarn lint, yarn test (3 suites, 90 tests), yarn build: pass
  • npm pack --dry-run: no scripts/ entries
  • CLANG_FORMAT_BINARY=<path> yarn format:clang:check: passes; CLANG_FORMAT_BINARY=/nonexistent: clear error, exit 1
  • no binary on PATH: clear error with install hint, exit 1
  • a #! shim that re-invokes the script placed first on PATH: skipped, no recursion
  • a badly formatted file with --dry-run --Werror: reports the violation, exit 1
  • unmatched glob: error, exit 1
  • fake clang-format 99.0.0 via CLANG_FORMAT_BINARY: version warning printed

@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
react-native-ease Ignored Ignored Preview Nov 13, 2026 7:16pm UTC

Request Review

@floco-af floco-af changed the title chore: support clang-format on linux arm64 chore: add clang-format wrapper script for linux arm64 Nov 13, 2026

This branch has not been deployed

No deployments
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