From 2eb9c3257d2a6c2e6c80d7442f020acb3e4e88b1 Mon Sep 17 00:00:00 2001 From: Final AI Agent Date: Fri, 14 Aug 2026 00:01:53 +0000 Subject: [PATCH 1/6] Add sccache to CI builds --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 790d4c1836..d7636736e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: AEGISUB_BUILD_BRANCH: ${{ github.head_ref || github.ref_name }} # Same condition as windows-sign-executable AEGISUB_SIGN_WINDOWS: ${{ matrix.config.os == 'windows-latest' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci/windows-signing') }} + SCCACHE_GHA_ENABLED: "true" strategy: fail-fast: false @@ -29,6 +30,9 @@ jobs: - name: Windows MSVC Release os: windows-latest msvc: true + compilers: | + $env:CC = "sccache cl" + $env:CXX = "sccache cl" devenv: | Import-Module "$env:VS\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" Enter-VsDevShell -VsInstallPath $env:VS -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64" @@ -50,10 +54,12 @@ jobs: - name: Ubuntu Debug os: ubuntu-latest buildtype: debugoptimized + compilers: export CC="sccache gcc" CXX="sccache g++" args: -Db_pch=false - name: Ubuntu Release os: ubuntu-latest buildtype: release + compilers: export CC="sccache gcc" CXX="sccache g++" args: -Db_pch=false - name: macOS x86_64 Release os: macos-15 @@ -89,6 +95,7 @@ jobs: - name: macOS arm64 Debug os: macos-15 buildtype: debugoptimized + compilers: export CC="sccache clang" CXX="sccache clang++" args: >- -Dmacos_deployment_target=15.0 -Dbuild_osx_bundle=false @@ -99,6 +106,7 @@ jobs: os: macos-15 native_args: --native-file tools/macos-release.ini buildtype: release + compilers: export CC="sccache clang" CXX="sccache clang++" args: *macos_source_args steps: @@ -110,6 +118,9 @@ jobs: with: python-version: '3.x' + - name: Set up sccache + uses: mozilla-actions/sccache-action@v0.0.11 + - name: Setup Meson run: | python -m pip install --upgrade pip setuptools @@ -186,6 +197,7 @@ jobs: - name: Configure run: | ${{ matrix.config.devenv }} + ${{ matrix.config.compilers }} meson setup build ${{ matrix.config.native_args }} ${{ matrix.config.cross_args }} ${{ matrix.config.args }} -Dbuildtype=${{ matrix.config.buildtype }} ${{ github.ref_type == 'tag' && '-Dofficial_release=true' || '' }} - name: Build FFTW (MacOS) From 57b32c2557fbd86d000f63b500039469b313c598 Mon Sep 17 00:00:00 2001 From: Final AI Agent Date: Wed, 7 Oct 2026 16:30:32 -0700 Subject: [PATCH 2/6] Separate sccache caches by toolchain architecture /usr/bin/clang is the same xcrun shim on Intel and Apple Silicon runners, so sccache's compiler hash matched across them and arm64 builds were served x86_64 objects. Factor a per-toolchain key into the hash via SCCACHE_C_CUSTOM_CACHE_BUSTER. --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7636736e3..bc4ffeb946 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: # Same condition as windows-sign-executable AEGISUB_SIGN_WINDOWS: ${{ matrix.config.os == 'windows-latest' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/ci/windows-signing') }} SCCACHE_GHA_ENABLED: "true" + SCCACHE_C_CUSTOM_CACHE_BUSTER: ${{ matrix.config['sccache-key'] }} strategy: fail-fast: false @@ -29,6 +30,7 @@ jobs: config: - name: Windows MSVC Release os: windows-latest + sccache-key: windows-x86_64-msvc msvc: true compilers: | $env:CC = "sccache cl" @@ -53,16 +55,19 @@ jobs: -Dlibass:fontconfig=disabled - name: Ubuntu Debug os: ubuntu-latest + sccache-key: linux-x86_64-gcc buildtype: debugoptimized compilers: export CC="sccache gcc" CXX="sccache g++" args: -Db_pch=false - name: Ubuntu Release os: ubuntu-latest + sccache-key: linux-x86_64-gcc buildtype: release compilers: export CC="sccache gcc" CXX="sccache g++" args: -Db_pch=false - name: macOS x86_64 Release os: macos-15 + sccache-key: macos-x86_64-clang cross_args: --cross-file tools/macos-release.ini --cross-file tools/macos-x86_64.ini buildtype: release args: &macos_source_args >- @@ -94,6 +99,7 @@ jobs: --force-fallback-for=boost,wxWidgets,libass,zlib,freetype2,fribidi,harfbuzz,ffms2,libavformat,libavcodec,libswscale,libavutil,libswresample,dav1d,hunspell,uchardet,icu-uc,icu-i18n,libcurl - name: macOS arm64 Debug os: macos-15 + sccache-key: macos-arm64-clang buildtype: debugoptimized compilers: export CC="sccache clang" CXX="sccache clang++" args: >- @@ -104,6 +110,7 @@ jobs: -Dopenal=enabled - name: macOS arm64 Release os: macos-15 + sccache-key: macos-arm64-clang native_args: --native-file tools/macos-release.ini buildtype: release compilers: export CC="sccache clang" CXX="sccache clang++" From ecdc0ab82d1e11696b53483f55cdd39e77d6106c Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Wed, 7 Oct 2026 16:30:49 -0700 Subject: [PATCH 3/6] ci: let meson pick up sccache and cover the Intel cross build Meson wraps compilers it detects itself with sccache when it is on PATH, including MSVC, so the per-job CC/CXX exports are unnecessary. Compilers listed in machine files are not wrapped, so the x86_64 cross build never used sccache; route them through a compiler_cache constant that tools/sccache.ini overrides. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 10 +--------- tools/macos-x86_64.ini | 12 ++++++++---- tools/sccache.ini | 5 +++++ 3 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 tools/sccache.ini diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc4ffeb946..5117853a61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,9 +32,6 @@ jobs: os: windows-latest sccache-key: windows-x86_64-msvc msvc: true - compilers: | - $env:CC = "sccache cl" - $env:CXX = "sccache cl" devenv: | Import-Module "$env:VS\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" Enter-VsDevShell -VsInstallPath $env:VS -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64" @@ -57,18 +54,16 @@ jobs: os: ubuntu-latest sccache-key: linux-x86_64-gcc buildtype: debugoptimized - compilers: export CC="sccache gcc" CXX="sccache g++" args: -Db_pch=false - name: Ubuntu Release os: ubuntu-latest sccache-key: linux-x86_64-gcc buildtype: release - compilers: export CC="sccache gcc" CXX="sccache g++" args: -Db_pch=false - name: macOS x86_64 Release os: macos-15 sccache-key: macos-x86_64-clang - cross_args: --cross-file tools/macos-release.ini --cross-file tools/macos-x86_64.ini + cross_args: --cross-file tools/macos-release.ini --cross-file tools/macos-x86_64.ini --cross-file tools/sccache.ini buildtype: release args: &macos_source_args >- -Ddefault_library=static @@ -101,7 +96,6 @@ jobs: os: macos-15 sccache-key: macos-arm64-clang buildtype: debugoptimized - compilers: export CC="sccache clang" CXX="sccache clang++" args: >- -Dmacos_deployment_target=15.0 -Dbuild_osx_bundle=false @@ -113,7 +107,6 @@ jobs: sccache-key: macos-arm64-clang native_args: --native-file tools/macos-release.ini buildtype: release - compilers: export CC="sccache clang" CXX="sccache clang++" args: *macos_source_args steps: @@ -204,7 +197,6 @@ jobs: - name: Configure run: | ${{ matrix.config.devenv }} - ${{ matrix.config.compilers }} meson setup build ${{ matrix.config.native_args }} ${{ matrix.config.cross_args }} ${{ matrix.config.args }} -Dbuildtype=${{ matrix.config.buildtype }} ${{ github.ref_type == 'tag' && '-Dofficial_release=true' || '' }} - name: Build FFTW (MacOS) diff --git a/tools/macos-x86_64.ini b/tools/macos-x86_64.ini index e4233c7eee..84cd36c922 100644 --- a/tools/macos-x86_64.ini +++ b/tools/macos-x86_64.ini @@ -1,10 +1,14 @@ # Build Intel binaries with native Apple Silicon tools; run tests via Rosetta. # Combine with macos-release.ini for target dependency search paths. +[constants] +# Overridden by tools/sccache.ini when layered after this file +compiler_cache = [] + [binaries] -c = ['/usr/bin/clang', '-arch', 'x86_64'] -cpp = ['/usr/bin/clang++', '-arch', 'x86_64'] -objc = ['/usr/bin/clang', '-arch', 'x86_64'] -objcpp = ['/usr/bin/clang++', '-arch', 'x86_64'] +c = compiler_cache + ['/usr/bin/clang', '-arch', 'x86_64'] +cpp = compiler_cache + ['/usr/bin/clang++', '-arch', 'x86_64'] +objc = compiler_cache + ['/usr/bin/clang', '-arch', 'x86_64'] +objcpp = compiler_cache + ['/usr/bin/clang++', '-arch', 'x86_64'] ar = '/usr/bin/ar' strip = '/usr/bin/strip' pkg-config = 'pkg-config' diff --git a/tools/sccache.ini b/tools/sccache.ini new file mode 100644 index 0000000000..a2d2662820 --- /dev/null +++ b/tools/sccache.ini @@ -0,0 +1,5 @@ +# Layer after a cross file that defines compiler_cache (e.g. macos-x86_64.ini) +# to compile through sccache. Meson only adds sccache automatically for +# compilers it finds itself, not ones listed in machine files. +[constants] +compiler_cache = ['sccache'] From 7ecb5b0e68fd35f8d0b2482f97076508c81183fb Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Wed, 7 Oct 2026 18:16:27 -0700 Subject: [PATCH 4/6] ci: disable PCH on macOS builds using sccache Clang records header mtimes in the PCH, so a PCH served from the cache is rejected once agi_pre.h has a new mtime on a fresh checkout. -Xclang -fno-pch-timestamp would avoid that, but sccache does not hash the PCH contents for its consumers, so a changed precompiled header could then serve stale objects. Linux already builds without PCH; MSVC PCH compiles are not cached by sccache, so Windows is unaffected. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5117853a61..6dfb5564e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,7 +65,9 @@ jobs: sccache-key: macos-x86_64-clang cross_args: --cross-file tools/macos-release.ini --cross-file tools/macos-x86_64.ini --cross-file tools/sccache.ini buildtype: release + # sccache serves clang PCHs that fail mtime validation on a fresh checkout args: &macos_source_args >- + -Db_pch=false -Ddefault_library=static -Dbuild_osx_bundle=true -Dfftw3=disabled @@ -97,6 +99,7 @@ jobs: sccache-key: macos-arm64-clang buildtype: debugoptimized args: >- + -Db_pch=false -Dmacos_deployment_target=15.0 -Dbuild_osx_bundle=false -Dfftw3=enabled From a2605eb1766306c66088167ef72e021d9c6f5435 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Wed, 7 Oct 2026 18:54:28 -0700 Subject: [PATCH 5/6] ci: build releases and manual runs without sccache Tag builds produce the official release artifacts, and manual dispatches are how the signing branch runs, so compile those from scratch rather than from cached objects. Without the action, sccache is not on PATH: meson does not wrap the compilers and tools/sccache.ini falls back to the plain cross compilers. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dfb5564e9..57f2376da8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,7 +121,9 @@ jobs: with: python-version: '3.x' + # Release and manually dispatched (e.g. signing) builds compile from scratch - name: Set up sccache + if: github.ref_type != 'tag' && github.event_name != 'workflow_dispatch' uses: mozilla-actions/sccache-action@v0.0.11 - name: Setup Meson From a5219133cbb3fecf6f07b52ce03adc37eec24fc0 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Wed, 7 Oct 2026 18:58:12 -0700 Subject: [PATCH 6/6] ci: make sccache a toggle on manual runs Manual dispatches use sccache by default, with a checkbox to compile from scratch instead (e.g. for signing test runs). Tag builds still never use it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57f2376da8..3b40c4cad2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,11 @@ on: pull_request: branches: [ master ] workflow_dispatch: + inputs: + sccache: + description: Use the sccache compilation cache + type: boolean + default: true permissions: contents: read @@ -121,9 +126,9 @@ jobs: with: python-version: '3.x' - # Release and manually dispatched (e.g. signing) builds compile from scratch + # Release builds compile from scratch; manual runs can opt out too - name: Set up sccache - if: github.ref_type != 'tag' && github.event_name != 'workflow_dispatch' + if: github.ref_type != 'tag' && (github.event_name != 'workflow_dispatch' || inputs.sccache) uses: mozilla-actions/sccache-action@v0.0.11 - name: Setup Meson