Archived
Public Access
Cache the compiler with ccache to speed kernel builds
- Install ccache and wrap the native + arm64 cross compilers via /usr/lib/ccache symlinks on PATH; persist CCACHE_DIR / PATH across steps through $GITHUB_ENV / $GITHUB_PATH. - Restore and save ~/.ccache with actions/cache@v4, keyed by arch + kernel version with a unique per-run suffix to force a save; restore-keys warm-start from a prior build of the same arch (including across point releases). - Print `ccache -s` after the build. Deliberately do not cache out/ (freshly built packages) or the re-cloned kernel source. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,40 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get install -y gcc-aarch64-linux-gnu
|
||||
|
||||
- name: 配置 ccache
|
||||
if: env.BUILD_NEEDED == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get install -y ccache
|
||||
# Wrap the (cross-)compilers through /usr/lib/ccache symlinks; the build
|
||||
# picks them up because this dir is prepended to PATH below.
|
||||
sudo update-ccache-symlinks || true
|
||||
ccache_bin="$(command -v ccache)"
|
||||
sudo ln -sf "$ccache_bin" /usr/lib/ccache/gcc
|
||||
if [ "$ARCH" = "arm64" ]; then
|
||||
sudo ln -sf "$ccache_bin" /usr/lib/ccache/aarch64-linux-gnu-gcc
|
||||
fi
|
||||
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
|
||||
{
|
||||
echo "CCACHE_DIR=$HOME/.ccache"
|
||||
echo "CCACHE_MAXSIZE=2G"
|
||||
echo "CCACHE_COMPRESS=1"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: 恢复 ccache 缓存
|
||||
if: env.BUILD_NEEDED == 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
# Only the compiler cache is worth persisting: the kernel source is
|
||||
# re-cloned each run and out/ holds freshly built packages. A unique key
|
||||
# per run forces a save; restore-keys warm-start from the most recent
|
||||
# prior build of the same arch (then any build of the same arch).
|
||||
path: ~/.ccache
|
||||
key: ccache-${{ matrix.arch }}-${{ needs.preflight.outputs.kernel_version }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
ccache-${{ matrix.arch }}-${{ needs.preflight.outputs.kernel_version }}-
|
||||
ccache-${{ matrix.arch }}-
|
||||
|
||||
- name: 创建源码目录
|
||||
if: env.BUILD_NEEDED == 'true'
|
||||
run: mkdir -p ./kernel/linux
|
||||
@@ -190,6 +224,10 @@ jobs:
|
||||
make bindeb-pkg -j$(nproc) LOCALVERSION="$LOCALVERSION_SUFFIX" KDEB_COMPRESS=gzip skipdbg=true
|
||||
fi
|
||||
|
||||
- name: ccache 统计
|
||||
if: env.BUILD_NEEDED == 'true'
|
||||
run: ccache -s
|
||||
|
||||
- name: 检查 deb 包
|
||||
if: env.BUILD_NEEDED == 'true'
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user