Repository navigation
feat(ci): cross-build the Intel macOS binary on the arm64 runner - #1289
Conversation
Build the x86_64 (Intel) macOS binary by cross-compiling on the existing aarch64 macOS runner instead of a dedicated Intel runner. macOS↔macOS cross works without a pkgsCross stdenv: the native arm64 toolchain targets x86_64-apple-darwin, Apple clang is multi-arch (the cc crate auto-passes -arch x86_64 for bundled sqlite), and the Apple SDK ships multi-arch stubs. The result links only /usr/lib/libSystem.B.dylib, so it is portable to Intel Macs (gated by the otool dylib check), and builds in ~50s with no cross stdenv. - nix/darwin-x64-package.nix: `ccusage-darwin-x64` (native toolchain + x86_64 target + Apple SDK, no pkgsCross). - build-macos-nix-native-package: pick the flake attr by arch (arm64 -> ccusage, x64 -> ccusage-darwin-x64). - ci.yaml: add build-mac-x64 to the native matrix (same arm64 runner), publish it via pkg-pr-new, and add a macos-15-intel preview E2E to exercise the cross-built binary on real Intel hardware. - release.yaml: build mac-x64 via the arm64 runner cross instead of the Intel cargo path; drop the now-unused build-macos-cargo-native-package action. Note: nixpkgs deprecates x86_64-darwin after 26.05, so this path will need a revisit when that lands.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds macOS x64 (Intel) cross-compilation support for ccusage by defining a new Nix derivation for x86_64-apple-darwin, updating the build action to conditionally select it based on architecture, and integrating x64 builds into CI and release workflows with E2E testing on Intel macOS runners. ChangesmacOS x64 Cross-Compilation Implementation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
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 unit tests (beta)
Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | dc599fb | Commit Preview URL Branch Preview URL |
Jun 11 2026, 09:54 PM |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — Cross-compiles the Intel macOS x86_64 ccusage binary on the existing arm64 macOS runner, removing the need for a dedicated Intel macOS runner while keeping E2E validation on real Intel hardware.
- New
nix/darwin-x64-package.nix— crane-based cross package using the native toolchain withx86_64-apple-darwintarget override,apple-sdk_15buildInput (no nixpkgslibiconv), and apostInstalldylib-portability check. - Unified
build-macos-nix-native-package/action.yaml— selects.#ccusage-darwin-x64or.#ccusageby arch; both arches now share one action. - Removed
build-macos-cargo-native-package/action.yaml— superseded by the Nix-based action. - CI matrix update —
build-mac-x64on the arm64 runner; publishespackages/ccusage-darwin-x64; addsmacos-15-intelE2E smoketest. - Release workflow — mac-x64 builds on the arm64 runner via the unified action; condition simplified to
matrix.platform == 'darwin'.
Big Pickle (free via Pullfrog for OSS) | 𝕏
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
There was a problem hiding this comment.
2 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="nix/darwin-x64-package.nix">
<violation number="1" location="nix/darwin-x64-package.nix:43">
P2: `buildInputs` is fully overwritten in the cross args, which makes the x64 package drift-prone and can drop future Darwin dependencies from the base package.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| ); | ||
| crossCommonArgs = config.packages.ccusage.passthru.commonArgs // { | ||
| cargoExtraArgs = "-p ccusage --bin ccusage --target ${target}"; | ||
| buildInputs = [ pkgs.apple-sdk_15 ]; |
There was a problem hiding this comment.
P2: buildInputs is fully overwritten in the cross args, which makes the x64 package drift-prone and can drop future Darwin dependencies from the base package.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At nix/darwin-x64-package.nix, line 43:
<comment>`buildInputs` is fully overwritten in the cross args, which makes the x64 package drift-prone and can drop future Darwin dependencies from the base package.</comment>
<file context>
@@ -0,0 +1,69 @@
+ );
+ crossCommonArgs = config.packages.ccusage.passthru.commonArgs // {
+ cargoExtraArgs = "-p ccusage --bin ccusage --target ${target}";
+ buildInputs = [ pkgs.apple-sdk_15 ];
+ };
+ crossDepsOnlyArgs = config.packages.ccusage.passthru.depsOnlyArgs // {
</file context>
Co-authored-by: Codesmith <[email protected]>
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runner startupExecution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one
Cached bunx execution performanceRuns the same large fixture through Fixtures: Claude
Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |

Summary
Build the x86_64 (Intel) macOS binary by cross-compiling on the existing
aarch64 macOS runner, removing the need for a dedicated Intel macOS runner.
Why it's clean (no pkgsCross stdenv)
macOS↔macOS cross doesn't need a full
pkgsCrosstoolchain: the native arm64toolchain targets
x86_64-apple-darwin, Apple clang is multi-arch (thecccrate auto-passes
-arch x86_64for bundled sqlite), and the Apple SDK shipsmulti-arch tbd stubs. Verified locally:
file→Mach-O 64-bit x86_64 executableotool -L→ only/usr/lib/libSystem.B.dylib(portable to Intel Macs)(I prototyped the
pkgsCross.x86_64-darwinapproach too — it spends minutesbootstrapping a cross clang/libcxx, so this lighter target-only approach wins.)
Change
ccusage-darwin-x64(native toolchain + thex86_64 target + Apple SDK; drops the aarch64-only nixpkgs libiconv).
(arm64 →
ccusage, x64 →ccusage-darwin-x64).build-mac-x64to the native matrix (same arm64 runner),publish it via pkg-pr-new, and add a
macos-15-intelpreview E2E so thecross-built binary is exercised on real Intel hardware.
cargo path; drop the now-unused
build-macos-cargo-native-package.Caveats
question like Windows).
x86_64-darwinafter 26.05; this path will need a revisitwhen that lands.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is enabled.Summary by cubic
Cross-compile the Intel (x86_64) macOS
ccusagebinary on the existing arm64 runner. This removes the dedicated Intel runner and unifies macOS builds under Nix.New Features
ccusage-darwin-x64Nix package that builds thex86_64-apple-darwintarget with the native toolchain and Apple SDK; enforces a system-dylib-only check; exposed inflake.nix.macos-15-intel) to run the cross-built binary.Refactors
build-macos-nix-native-packagefor both arches; selectsccusage(arm64) orccusage-darwin-x64(x64) by arch and validates the input; removed the Cargo-based action.build-mac-x64job onblacksmith-12vcpu-macos-26and publishpackages/ccusage-darwin-x64.Written for commit dc599fb. Summary will update on new commits.
Summary by CodeRabbit
New Features
Chores