Skip to content

Wire ccache into the cibuildwheel macOS build - #235

Merged
bdraco merged 1 commit into
masterfrom
fix-ccache-macos-wiring
May 17, 2026
Merged

bdraco merged 1 commit into
masterfrom
fix-ccache-macos-wiring

Conversation

@bdraco

@bdraco bdraco commented May 17, 2026 •

Copy link
Copy Markdown
Member

What do these changes do?

Adds a Wire ccache into the cibuildwheel macOS build step in
.github/workflows/reusable-build-wheel.yml that sets
CIBW_ENVIRONMENT_MACOS to prepend $(brew --prefix ccache)/libexec
to PATH and propagate CCACHE_DIR, so setuptools' bare clang /
cc lookups hit Brew's ccache shims. Mirrors the existing Linux step.

The macOS half of #233 was a no-op: the ccache action installed and
configured ccache, but cibuildwheel ran plain clang from Xcode, so
the job logged Cache size (GB): 0.0 / 0.2 ( 0.00%) followed by
Not saving cache because no objects are cached. Linux already works
because CIBW_ENVIRONMENT_LINUX puts /usr/lib*/ccache on PATH
inside the manylinux container; macOS had no equivalent.

brew --prefix ccache resolves correctly on both Apple-silicon
(/opt/homebrew) and Intel (/usr/local) runners.

Are there changes in behavior for the user?

No. CI-only change. The published wheels are byte-identical; only the
macOS wheel-build job is affected (it should populate the ccache cache
on the first run and serve cache hits on subsequent runs).

Related issue number

Follow-up to #233.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist -- N/A (CI workflow change; the
    effect is observable only by re-running the wheel-build matrix)
  • Documentation reflects the changes -- N/A (no user-visible API)
  • Add a new news fragment into the CHANGES/ folder
Agent run details (optional, for reviewers)

Diagnosis from the #233 merge run
(job 76422386592):

ccache stats
  Cache size (GB): 0.0 / 0.2 ( 0.00%)
ccache version 4.13.5
...
Not saving cache because no objects are cached.

Linux on the same run did save a 274 KB cache.tzst with 7 cacheable
misses, so this is a macOS-only gap.

Local checks:

  • actionlint .github/workflows/reusable-build-wheel.yml: clean.
  • make doc-spelling: passes for this change. CHANGES/235.contrib.rst
    is a symlink to CHANGES/233.contrib.rst (per AGENTS.md), so no new
    fragment text or wordlist entries are introduced. Two pre-existing
    failures remain on master that are unrelated to this change
    (subdirectory in CHANGES/207.contrib.rst:1 and postfix in
    CHANGES.rst:168).
  • Pre-commit hooks (actionlint-docker, yamllint, codespell, etc.) pass.

The runtime effect cannot be exercised locally; verification is the
next macOS wheel-build job on this branch.

Drafted with Claude Code (Claude Opus 4.7); reviewed by @bdraco.

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label May 17, 2026
@bdraco
bdraco force-pushed the fix-ccache-macos-wiring branch from 70c691f to a297989 Compare May 17, 2026 23:07
@bdraco
bdraco marked this pull request as draft May 17, 2026 23:08
@bdraco
bdraco force-pushed the fix-ccache-macos-wiring branch from a297989 to d029edc Compare May 17, 2026 23:11
The previous wiring only set CIBW_ENVIRONMENT_LINUX, so on macOS the
ccache action installed and configured ccache but the build never
invoked it. The post-job log made this explicit:

    ccache stats
      Cache size (GB): 0.0 / 0.2 ( 0.00%)
    Not saving cache because no objects are cached.

cibuildwheel runs directly on the macOS host (no container), so child
processes only see the wrapper compilers when their parent directory is
on PATH. Brew's ccache ships compiler-named shims under
$(brew --prefix ccache)/libexec; prepending that to PATH via
CIBW_ENVIRONMENT_MACOS makes setuptools' bare clang / cc lookups
hit ccache. brew --prefix is used so the same snippet works on both
Apple-silicon (/opt/homebrew) and Intel (/usr/local) runners.
@bdraco
bdraco force-pushed the fix-ccache-macos-wiring branch from d029edc to 3482306 Compare May 17, 2026 23:14
@codspeed

codspeed Bot commented May 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing fix-ccache-macos-wiring (3482306) with master (eeedfdb)

Open in CodSpeed

@bdraco
bdraco marked this pull request as ready for review May 17, 2026 23:35
@bdraco
bdraco merged commit 4179ce4 into master May 17, 2026
43 checks passed
@bdraco
bdraco deleted the fix-ccache-macos-wiring branch May 17, 2026 23:35
bdraco added a commit that referenced this pull request May 18, 2026
The macOS wiring added in #235 and the existing Linux wiring both
restore the saved cache, but every warm run logged 0 hits and a
100-percent miss rate. Per ccache debug logs (CCACHE_DEBUG=1,
CCACHE_LOGFILE), the manifest hash differs every run because three
inputs are unstable:

1. The compile-time cwd. PEP 517 build isolation runs the compiler
   from a path like /tmp/.tmp-propcache-pep517-RANDOM/src/src and the
   default ccache config has hash_dir=true.
2. The argv. The source argument (-c /tmp/.tmp-propcache-pep517-RANDOM/
   .../_helpers_c.c) and the include flag for pip's build environment
   (-I/tmp/build-env-RANDOM/include) both embed mkdtemp output. The
   project's own -ffile-prefix-map=<random>=<stable> flag for
   reproducible debug info also carries the random LHS into argv.
3. Preprocessor output. # line directives reference the random tmp
   path; -ffile-prefix-map only rewrites debug info and __FILE__, not
   the cpp line markers.

Per the ccache manual (https://ccache.dev/manual/latest.html), the
documented levers are CCACHE_BASEDIR (rewrites absolute paths under
the base directory to be relative to cwd, which on a build inside
that same tmp dir collapses the random parts), CCACHE_NOHASHDIR
(stops hashing the cwd), CCACHE_IGNOREOPTIONS (drops matching argv
entries from the hash, supports a trailing * glob), and
CCACHE_SLOPPINESS for header-mtime churn.

Apply the recipe in both the Linux and macOS wiring steps. Linux
bases at /tmp; macOS bases at $TMPDIR (/var/folders/<...>/T per
user, stable per runner). IGNOREOPTIONS drops -I/tmp/build-env-*
(no headers we actually depend on live there) and
-ffile-prefix-map=* (purely a debug-info cosmetic, does not affect
generated code).

ccache 3.7.7 (manylinux container) and 4.13.5 (macOS host) both
support these knobs (ignore_options landed in 3.3, 2016).
bdraco added a commit that referenced this pull request May 18, 2026
The macOS wiring added in #235 and the existing Linux wiring both
restore the saved cache, but every warm run logged 0 hits and a
100-percent miss rate. Per ccache debug logs (CCACHE_DEBUG=1,
CCACHE_LOGFILE), the manifest hash differs every run because three
inputs are unstable:

1. The compile-time cwd. PEP 517 build isolation runs the compiler
   from a path like /tmp/.tmp-propcache-pep517-RANDOM/src/src and the
   default ccache config has hash_dir=true.
2. The argv. The source argument (-c /tmp/.tmp-propcache-pep517-RANDOM/
   .../_helpers_c.c) and the include flag for pip's build environment
   (-I/tmp/build-env-RANDOM/include) both embed mkdtemp output. The
   project's own -ffile-prefix-map=<random>=<stable> flag for
   reproducible debug info also carries the random LHS into argv.
3. Preprocessor output. # line directives reference the random tmp
   path; -ffile-prefix-map only rewrites debug info and __FILE__, not
   the cpp line markers.

Per the ccache manual (https://ccache.dev/manual/latest.html), the
documented levers are CCACHE_BASEDIR (rewrites absolute paths under
the base directory to be relative to cwd, which on a build inside
that same tmp dir collapses the random parts), CCACHE_NOHASHDIR
(stops hashing the cwd), CCACHE_IGNOREOPTIONS (drops matching argv
entries from the hash, supports a trailing * glob), and
CCACHE_SLOPPINESS for header-mtime churn.

Apply the recipe in both the Linux and macOS wiring steps. Linux
bases at /tmp; macOS bases at $TMPDIR (/var/folders/<...>/T per
user, stable per runner). IGNOREOPTIONS drops -I/tmp/build-env-*
(no headers we actually depend on live there) and
-ffile-prefix-map=* (purely a debug-info cosmetic, does not affect
generated code).

ccache 3.7.7 (manylinux container) and 4.13.5 (macOS host) both
support these knobs (ignore_options landed in 3.3, 2016).
bdraco added a commit that referenced this pull request May 18, 2026
The macOS wiring added in #235 and the existing Linux wiring both
restore the saved cache, but every warm run logged 0 hits and a
100-percent miss rate. Per ccache debug logs (CCACHE_DEBUG=1,
CCACHE_LOGFILE), the manifest hash differs every run because three
inputs are unstable:

1. The compile-time cwd. PEP 517 build isolation runs the compiler
   from a path like /tmp/.tmp-propcache-pep517-RANDOM/src/src and the
   default ccache config has hash_dir=true.
2. The argv. The source argument (-c /tmp/.tmp-propcache-pep517-RANDOM/
   .../_helpers_c.c) and the include flag for pip's build environment
   (-I/tmp/build-env-RANDOM/include) both embed mkdtemp output. The
   project's own -ffile-prefix-map=<random>=<stable> flag for
   reproducible debug info also carries the random LHS into argv.
3. Preprocessor output. # line directives reference the random tmp
   path; -ffile-prefix-map only rewrites debug info and __FILE__, not
   the cpp line markers.

Per the ccache manual (https://ccache.dev/manual/latest.html), the
documented levers are CCACHE_BASEDIR (rewrites absolute paths under
the base directory to be relative to cwd, which on a build inside
that same tmp dir collapses the random parts), CCACHE_NOHASHDIR
(stops hashing the cwd), CCACHE_IGNOREOPTIONS (drops matching argv
entries from the hash, supports a trailing * glob), and
CCACHE_SLOPPINESS for header-mtime churn.

Apply the recipe in both the Linux and macOS wiring steps. Linux
bases at /tmp; macOS bases at $TMPDIR (/var/folders/<...>/T per
user, stable per runner). IGNOREOPTIONS drops -I/tmp/build-env-*
(no headers we actually depend on live there) and
-ffile-prefix-map=* (purely a debug-info cosmetic, does not affect
generated code).

ccache 3.7.7 (manylinux container) and 4.13.5 (macOS host) both
support these knobs (ignore_options landed in 3.3, 2016).
bdraco added a commit that referenced this pull request May 18, 2026
The macOS wiring added in #235 and the existing Linux wiring both
restore the saved cache, but every warm run logged 0 hits and a
100-percent miss rate. Per ccache debug logs (CCACHE_DEBUG=1,
CCACHE_LOGFILE), the manifest hash differs every run because three
inputs are unstable:

1. The compile-time cwd. PEP 517 build isolation runs the compiler
   from a path like /tmp/.tmp-propcache-pep517-RANDOM/src/src and the
   default ccache config has hash_dir=true.
2. The argv. The source argument (-c /tmp/.tmp-propcache-pep517-RANDOM/
   .../_helpers_c.c) and the include flag for pip's build environment
   (-I/tmp/build-env-RANDOM/include) both embed mkdtemp output. The
   project's own -ffile-prefix-map=<random>=<stable> flag for
   reproducible debug info also carries the random LHS into argv.
3. Preprocessor output. # line directives reference the random tmp
   path; -ffile-prefix-map only rewrites debug info and __FILE__, not
   the cpp line markers.

Per the ccache manual (https://ccache.dev/manual/latest.html), the
documented levers are CCACHE_BASEDIR (rewrites absolute paths under
the base directory to be relative to cwd, which on a build inside
that same tmp dir collapses the random parts), CCACHE_NOHASHDIR
(stops hashing the cwd), CCACHE_IGNOREOPTIONS (drops matching argv
entries from the hash, supports a trailing * glob), and
CCACHE_SLOPPINESS for header-mtime churn.

Apply the recipe in both the Linux and macOS wiring steps. Linux
bases at /tmp; macOS bases at $TMPDIR (/var/folders/<...>/T per
user, stable per runner). IGNOREOPTIONS drops -I/tmp/build-env-*
(no headers we actually depend on live there) and
-ffile-prefix-map=* (purely a debug-info cosmetic, does not affect
generated code).

ccache 3.7.7 (manylinux container) and 4.13.5 (macOS host) both
support these knobs (ignore_options landed in 3.3, 2016).
bdraco added a commit that referenced this pull request May 18, 2026
The macOS wiring added in #235 and the existing Linux wiring both
restore the saved cache, but every warm run logged 0 hits and a
100-percent miss rate. Per ccache debug logs (CCACHE_DEBUG=1,
CCACHE_LOGFILE), the manifest hash differs every run because three
inputs are unstable:

1. The compile-time cwd. PEP 517 build isolation runs the compiler
   from a path like /tmp/.tmp-propcache-pep517-RANDOM/src/src and the
   default ccache config has hash_dir=true.
2. The argv. The source argument (-c /tmp/.tmp-propcache-pep517-RANDOM/
   .../_helpers_c.c) and the include flag for pip's build environment
   (-I/tmp/build-env-RANDOM/include) both embed mkdtemp output. The
   project's own -ffile-prefix-map=<random>=<stable> flag for
   reproducible debug info also carries the random LHS into argv.
3. Preprocessor output. # line directives reference the random tmp
   path; -ffile-prefix-map only rewrites debug info and __FILE__, not
   the cpp line markers.

Per the ccache manual (https://ccache.dev/manual/latest.html), the
documented levers are CCACHE_BASEDIR (rewrites absolute paths under
the base directory to be relative to cwd, which on a build inside
that same tmp dir collapses the random parts), CCACHE_NOHASHDIR
(stops hashing the cwd), CCACHE_IGNOREOPTIONS (drops matching argv
entries from the hash, supports a trailing * glob), and
CCACHE_SLOPPINESS for header-mtime churn.

Apply the recipe in both the Linux and macOS wiring steps. Linux
bases at /tmp; macOS bases at $TMPDIR (/var/folders/<...>/T per
user, stable per runner). IGNOREOPTIONS drops -I/tmp/build-env-*
(no headers we actually depend on live there) and
-ffile-prefix-map=* (purely a debug-info cosmetic, does not affect
generated code).

ccache 3.7.7 (manylinux container) and 4.13.5 (macOS host) both
support these knobs (ignore_options landed in 3.3, 2016).
bdraco added a commit that referenced this pull request May 18, 2026
The macOS wiring added in #235 and the existing Linux wiring both
restore the saved cache, but every warm run logged 0 hits and a
100-percent miss rate. Per ccache debug logs (CCACHE_DEBUG=1,
CCACHE_LOGFILE), the manifest hash differs every run because three
inputs are unstable:

1. The compile-time cwd. PEP 517 build isolation runs the compiler
   from a path like /tmp/.tmp-propcache-pep517-RANDOM/src/src and the
   default ccache config has hash_dir=true.
2. The argv. The source argument (-c /tmp/.tmp-propcache-pep517-RANDOM/
   .../_helpers_c.c) and the include flag for pip's build environment
   (-I/tmp/build-env-RANDOM/include) both embed mkdtemp output. The
   project's own -ffile-prefix-map=<random>=<stable> flag for
   reproducible debug info also carries the random LHS into argv.
3. Preprocessor output. # line directives reference the random tmp
   path; -ffile-prefix-map only rewrites debug info and __FILE__, not
   the cpp line markers.

Per the ccache manual (https://ccache.dev/manual/latest.html), the
documented levers are CCACHE_BASEDIR (rewrites absolute paths under
the base directory to be relative to cwd, which on a build inside
that same tmp dir collapses the random parts), CCACHE_NOHASHDIR
(stops hashing the cwd), CCACHE_IGNOREOPTIONS (drops matching argv
entries from the hash, supports a trailing * glob), and
CCACHE_SLOPPINESS for header-mtime churn.

Apply the recipe in both the Linux and macOS wiring steps. Linux
bases at /tmp; macOS bases at $TMPDIR (/var/folders/<...>/T per
user, stable per runner). IGNOREOPTIONS drops -I/tmp/build-env-*
(no headers we actually depend on live there) and
-ffile-prefix-map=* (purely a debug-info cosmetic, does not affect
generated code).

ccache 3.7.7 (manylinux container) and 4.13.5 (macOS host) both
support these knobs (ignore_options landed in 3.3, 2016).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant