Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions .github/workflows/build-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,24 @@ jobs:
run: |
$baseline = (Get-Content vcpkg.json | ConvertFrom-Json)."builtin-baseline"

$msvc = $env:VCToolsVersion
if (-not $msvc) { $msvc = "unknown" }

# Reduce churn: keep major.minor (e.g. 14.44)
$msvcMajorMinor = ($msvc -split '\.')[0..1] -join '.'

$triplet = "x86-windows"
if ("${{ inputs.preset }}" -like "x64*") { $triplet = "x64-windows" }

"baseline=$baseline" >> $env:GITHUB_OUTPUT
"msvc=$msvcMajorMinor" >> $env:GITHUB_OUTPUT
"triplet=$triplet" >> $env:GITHUB_OUTPUT

Write-Host "vcpkg cache key parts: baseline=$baseline, msvc=$msvcMajorMinor, triplet=$triplet"
Write-Host "vcpkg cache key parts: baseline=$baseline, triplet=$triplet"

- name: Restore vcpkg binary cache
if: startsWith(inputs.preset, 'win32')
id: vcpkg_cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}\vcpkg-bincache
key: vcpkg-bincache-v2-${{ runner.os }}-msvc${{ steps.vcpkg_key.outputs.msvc }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}
key: vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}-${{ hashFiles('triplets/*.cmake') }}
restore-keys: |
vcpkg-bincache-v2-${{ runner.os }}-msvc${{ steps.vcpkg_key.outputs.msvc }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-
vcpkg-bincache-v2-${{ runner.os }}-
vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-
vcpkg-bincache-v3-${{ runner.os }}-

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
Expand All @@ -157,6 +150,8 @@ jobs:

"VCPKG_DEFAULT_BINARY_CACHE=$cacheDir" >> $env:GITHUB_ENV
"VCPKG_BINARY_SOURCES=$env:VCPKG_BINARY_SOURCES" >> $env:GITHUB_ENV
"VCPKG_OVERLAY_TRIPLETS=${{ github.workspace }}\triplets" >> $env:GITHUB_ENV
"VCPKG_INSTALL_OPTIONS=--x-abi-tools-use-exact-versions" >> $env:GITHUB_ENV

- name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
shell: pwsh
Expand Down Expand Up @@ -186,7 +181,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}\vcpkg-bincache
key: vcpkg-bincache-v2-${{ runner.os }}-msvc${{ steps.vcpkg_key.outputs.msvc }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}
key: vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}-${{ hashFiles('triplets/*.cmake') }}

- name: Collect ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact
shell: pwsh
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:Embedded>",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/triplets"
}
},
{
Expand Down
9 changes: 9 additions & 0 deletions triplets/x86-windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Include the default x86-windows triplet
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

# Exclude compiler version from ABI hash so that weekly GitHub runner image
# updates don't invalidate the binary cache. Minor MSVC version bumps do not
# cause ABI incompatibilities for this project.
set(VCPKG_DISABLE_COMPILER_TRACKING ON)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this possibly cause other issues in the future? If the binary cache is invalidated once a week, then why does it not keep the new binary cache after 1 build? Does that not need looking into?

Do we perhaps need a CI trigger to manually force purge and refresh the cache in case it is accidentially broken?

Do we know why exactly the cache is broken right now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two separate layers of caching.

  1. GitHub Actions cache — stores/restores a directory of files based on a key we define in the workflow. It just zips up the folder and gives it back when the key matches. It knows nothing about vcpkg.
  2. vcpkg binary cache — inside that directory, each package is a .zip file named by vcpkg's own ABI hash (which includes the exact compiler version like 14.44.35207). When vcpkg runs, it computes its hash and looks for a matching .zip in the directory.

So the problem was GitHub Actions says: "key v2-msvc14.44-... matches, here's your directory" and says cach-hit was true. Then vcpkg opens that directory, computes its hash with the full compiler version 14.44.35207, finds no matching .zip files (they were built with 14.43.xxxxx) and re-builds ffmpeg which takes forever (17 min). Because cache-hit was true as far as github is concerned, it doesn't save the new build. This fix removes the compiler version from vcpkg's hash, so both layers should stay in sync.

RE future issues, MSVC maintains ABI compatibility within the same major version (14.x), and the cache still invalidates when the vcpkg baseline or triplet config changes. We'd be very unlikely to have no other changes before the next major MSVC version - and yes we can always just bump the version in build-toolchain.yml to force purge and refresh the cache.

Loading