Repository navigation
Wire ccache into the cibuildwheel macOS build - #235
Merged
Merged
Conversation
bdraco
force-pushed
the
fix-ccache-macos-wiring
branch
from
May 17, 2026 23:07
70c691f to
a297989
Compare
bdraco
marked this pull request as draft
May 17, 2026 23:08
bdraco
force-pushed
the
fix-ccache-macos-wiring
branch
from
May 17, 2026 23:11
a297989 to
d029edc
Compare
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
force-pushed
the
fix-ccache-macos-wiring
branch
from
May 17, 2026 23:14
d029edc to
3482306
Compare
bdraco
marked this pull request as ready for review
May 17, 2026 23:35
This was referenced May 17, 2026
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Adds a
Wire ccache into the cibuildwheel macOS buildstep in.github/workflows/reusable-build-wheel.ymlthat setsCIBW_ENVIRONMENT_MACOSto prepend$(brew --prefix ccache)/libexecto
PATHand propagateCCACHE_DIR, so setuptools' bareclang/cclookups 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
clangfrom Xcode, sothe job logged
Cache size (GB): 0.0 / 0.2 ( 0.00%)followed byNot saving cache because no objects are cached.Linux already worksbecause
CIBW_ENVIRONMENT_LINUXputs/usr/lib*/ccacheonPATHinside the manylinux container; macOS had no equivalent.
brew --prefix ccacheresolves 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
effect is observable only by re-running the wheel-build matrix)
CHANGES/folderAgent run details (optional, for reviewers)
Diagnosis from the #233 merge run
(job 76422386592):
Linux on the same run did save a 274 KB
cache.tzstwith 7 cacheablemisses, 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.rstis a symlink to
CHANGES/233.contrib.rst(per AGENTS.md), so no newfragment text or wordlist entries are introduced. Two pre-existing
failures remain on master that are unrelated to this change
(
subdirectoryinCHANGES/207.contrib.rst:1andpostfixinCHANGES.rst:168).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.