Open
Conversation
Rename the system ccache.conf path var from SYSTEM_CCACHE_CONF to CCACHE_CONFIGPATH2, the env var ccache itself reads for a secondary config, and make it absolute (rooted at github.workspace/openwrt/) so it matches the checkout layout rather than depending on working-directory: openwrt. Write both CCACHE_DIR and CCACHE_CONFIGPATH2 to $GITHUB_ENV from the configure step so every subsequent step inherits the same values. Previously each step had to redeclare CCACHE_DIR in its own env block and the "Show ccache stats" step was running without CCACHE_CONFIGPATH2 at all, so it never saw the system ccache.conf written during configuration. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
File ctime and mtime change when the ccache archive is tar'd and extracted for upload/restore, causing spurious hash mismatches. Tell ccache to ignore them. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
The external toolchain is rebuilt daily by the build bots, but the compiler itself usually does not change. Without an explicit compiler_check, ccache falls back to the compiler binary's mtime, so each daily rebuild produces a "new" compiler and every lookup misses. Derive a stable compiler_check string from the OpenWrt commit that last touched toolchain/gcc or toolchain/binutils. For external toolchains, read the build commit from "gcc --version" (r0-<SHA> pkgversion) and resolve the last change relative to it; otherwise fall back to HEAD. Full git history is needed for "git log", so switch checkout to fetch-depth: 0. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Before saving/uploading the ccache archive on push, run two
maintenance commands and drop the scratch directory from the tar:
* ccache --evict-older-than 1d drops entries that were not
accessed in the last day, so long-unused results do not sit
in the cache forever across runs.
* ccache --cleanup enforces max_size, which is otherwise only
applied opportunistically during inserts. Running it here
guarantees the archive we upload is trimmed to the configured
limit instead of whatever size the cache happened to reach.
* .ccache/tmp is excluded from the tar. It is ccache's scratch
directory for in-flight compilations and has no value once
the build step has finished; including it just inflates the
archive.
Both ccache invocations must run before the subsequent
"Cleanup dl/build_dir/staging_dir" step, because that step
removes staging_dir/host/bin/ccache.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Bump the kernel ccache max_size from 800M to 1G, and the packages ccache limit from the default 5G to 8G. Multiple package builds have been observed hitting the 5G default, and the kernel cache has been reaching the previous 800M limit. Since entries not accessed in the last day are now evicted before the archive is uploaded, a larger max_size no longer risks unbounded growth across runs. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Zero the ccache stats before the build so the stats printed afterwards reflect only the current run, not counters accumulated into the restored cache archive. Also fix the "Show ccache stats" step, which was missing CCACHE_CONFIGPATH2 and so didn't see the system ccache.conf written during configuration, and switch it to -vv for the per-reason breakdown that's useful when debugging cache misses. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
hauke
commented
Apr 18, 2026
| [ ${{ inputs.ccache_type }} = 'kernel' ] && echo max_size=800M >> $SYSTEM_CCACHE_CONF | ||
| echo compiler_type=gcc >> $CCACHE_CONFIGPATH2 | ||
| [ ${{ inputs.ccache_type }} = 'kernel' ] && echo max_size=1G >> $CCACHE_CONFIGPATH2 | ||
| [ ${{ inputs.ccache_type }} = 'packages' ] && echo max_size=8G >> $CCACHE_CONFIGPATH2 |
Member
Author
There was a problem hiding this comment.
In my test the mips malta full build generated 1.9GB and x86/64 2.4GB.
Failed checksIssues marked with an ❌ are failing checks. Commit 3a3b290
For more details, see the full job log. Something broken? Consider providing feedback. |
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.
This contains multiple fixes and improvements for the ccache handling in the Github actions. This is very hard to test in all the situations. I hope this fixes the ccache handling in the github actions now.
For small changes it should reduce the build time of a Linux kernel from 25 minutes to 2:30 minutes.
Here is an example run on main: https://github.com/hauke/openwrt/actions/runs/24610733561/job/71964583220
and here on a PR: https://github.com/hauke/openwrt/actions/runs/24612062608/job/71968121620
This also needs this OpenWrt change: openwrt/openwrt#22995