Enable sccache for linux-x64 coreclr PR builds#127882
Open
agocke wants to merge 4 commits intodotnet:mainfrom
Open
Enable sccache for linux-x64 coreclr PR builds#127882agocke wants to merge 4 commits intodotnet:mainfrom
agocke wants to merge 4 commits intodotnet:mainfrom
Conversation
Wire up sccache as a compiler cache for linux-x64 coreclr native builds in PR pipelines using the Azure Pipeline Cache task. - Add PackageDownload for sccache 0.15.0 in runtime-prereqs.proj (Linux CI only) - Add setup-sccache.yml pre-build template: configures Pipeline Cache, sets USE_SCCACHE/SCCACHE_DIR env vars, prepends sccache to PATH - Add sccache-stats.yml post-build template for cache hit observability - Wire both templates into CoreCLR_Libraries and Libraries_CheckedCoreCLR jobs in runtime.yml - chmod +x the sccache binary in build-runtime.sh (NuGet strips permissions) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR wires up sccache for Linux x64 CoreCLR native builds in PR pipelines, using Azure Pipelines Cache to persist the local sccache directory between runs and emitting stats after the build for observability.
Changes:
- Downloads
sccacheviaPackageDownloadduring existing CoreCLR prereqs restore (Linux CI only). - Adds CoreCLR pipeline templates to restore/save the sccache cache directory and to print
sccache --show-stats. - Enables
sccacheas the CMake compiler launcher whenUSE_SCCACHE=true, including achmod +xworkaround for NuGet-stripped execute bits.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/runtime-prereqs.proj | Adds CI/Linux PackageDownload for the sccache NuGet package. |
| src/coreclr/build-runtime.sh | Enables sccache as a CMake compiler launcher and ensures the binary is executable. |
| eng/pipelines/runtime.yml | Hooks new pre-/post-build sccache templates into CoreCLR build jobs. |
| eng/pipelines/coreclr/templates/setup-sccache.yml | Restores/saves sccache directory via Cache@2 and configures PATH + env vars. |
| eng/pipelines/coreclr/templates/sccache-stats.yml | Prints sccache statistics after builds. |
Comment on lines
+27
to
+30
| - script: | | ||
| sccacheDir="$(Build.SourcesDirectory)/.packages/sccache/0.15.0/tools" | ||
| mkdir -p "$sccacheDir" | ||
| echo "##vso[task.prependpath]$sccacheDir" |
- Set SCCACHE_IDLE_TIMEOUT=0 to prevent server timeout before stats step - Fix chmod +x to use known NuGet package paths instead of command -v (command -v won't find non-executable files) - Exclude linux_musl legs via osSubgroup check (sccache package is glibc-only) - Use rolling cache key (Build.BuildNumber) so cache updates each run - Make stats step resilient with || true - Centralize sccache version as a template parameter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ns dot) Cache@2 interprets key segments containing '.' as file paths. Build.BuildNumber (e.g. 20260506.103) triggers FileNotFoundException. Build.BuildId is a plain integer that is treated as a string literal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 6, 2026
Open
Different jobs (CoreCLR_Libraries vs Libraries_CheckedCoreCLR) and configurations (Release vs Checked vs Debug) produce different object files. Without distinguishing them in the cache key, builds stomp over each other in the shared sccache directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 6, 2026
Member
Author
|
@steveisok This looks ready. By re-running the pipeline I simulated a hot cache and it looks to cut down our clr+libs build by ~half, as expected. We'll see how much it helps in practice with coreclr changes. |
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.
Note
This PR was created with assistance from GitHub Copilot.
Wire up sccache as a compiler cache for linux-x64 coreclr native builds in PR pipelines using the Azure Pipeline Cache task. This can likely be expanded to more runs/platforms in the future, but this is a good place to start.
Changes
src/coreclr/runtime-prereqs.proj: AddPackageDownloadforsccache0.15.0 (Linux CI only), piggybacking on the existing restoreeng/pipelines/coreclr/templates/setup-sccache.yml: Pre-build template that configures the Pipeline Cache for sccache storage, setsUSE_SCCACHE/SCCACHE_DIRenv vars, and prepends sccache toPATHeng/pipelines/coreclr/templates/sccache-stats.yml: Post-build template that printssccache --show-statseng/pipelines/runtime.yml: Wires both templates into theCoreCLR_LibrariesandLibraries_CheckedCoreCLRjobssrc/coreclr/build-runtime.sh:chmod +xthe sccache binary before use (NuGet strips execute permissions)How it works
PATH,SCCACHE_DIR,USE_SCCACHE)build.shrestoresruntime-prereqs.proj(downloads sccache binary) → native build uses sccache as cmake compiler launcherTemplates use compile-time
${{ if }}conditions so they are no-ops for non-linux-x64 platforms in multi-platform matrix jobs.