-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Test sccache with temp copy #124074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Test sccache with temp copy #124074
Changes from all commits
c032b94
acc3583
2fc886e
709d5dd
f53e79d
e22b6fa
7e67bc9
a36ccd1
b8aea3b
3ba5ec6
b8c56ec
ce4729b
5bbdbad
86c6b1c
6164354
2ca0c95
4c64603
8f1fe94
0808ed2
f2410b7
7839ab6
51f2995
9f9e45c
c578b5a
a33f540
03b2030
b008128
7bde7e7
45fa3d4
c7b6d13
163962b
d8e6ef8
4e50efe
fb90899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -589,6 +589,33 @@ fi | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| initDistroRid "$os" "$arch" "$crossBuild" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Enable sccache for linux-x64 builds if the binary is present in the repo root. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "${USE_SCCACHE:-}" != "true" && "$os" == "linux" && "$arch" == "x64" && -f "$scriptroot/../sccache" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export PATH="$scriptroot/..:$PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export USE_SCCACHE=true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export SCCACHE_AZURE_BLOB_CONTAINER=runtime-cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export SCCACHE_AZURE_CONNECTION_STRING="BlobEndpoint=https://runsccache.blob.core.windows.net" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export SCCACHE_AZURE_NO_CREDENTIALS=true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sccache --stop-server || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Disable idle timeout so the server stays alive across long managed-build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # phases that separate native-compilation steps (e.g. clr then libs). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export SCCACHE_IDLE_TIMEOUT=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Write sccache logs to the AzDO artifact staging directory so they get published. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Fall back to the local artifacts/log directory if not running in CI. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -n "${BUILD_ARTIFACTSTAGINGDIRECTORY:-}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| __sccacheLogDir="$BUILD_ARTIFACTSTAGINGDIRECTORY/artifacts/log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| __sccacheLogDir="$scriptroot/../artifacts/log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$__sccacheLogDir" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SCCACHE_ERROR_LOG="$__sccacheLogDir/sccache_debug.log" SCCACHE_LOG=debug sccache --start-server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SCCACHE_ERROR_LOG="$__sccacheLogDir/sccache_debug.log" SCCACHE_LOG=debug sccache --start-server | |
| export SCCACHE_ERROR_LOG="$__sccacheLogDir/sccache_debug.log" | |
| export SCCACHE_LOG=debug | |
| sccache --start-server |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because eng/build.sh runs with set -e, a failure from sccache -s (e.g., server startup failure, unsupported backend, transient network issue) will abort the entire build even though this is just a diagnostic step. Consider making the stats call best-effort (or gating it behind an explicit opt-in) so cache issues don't fail the build.
| sccache -s | |
| sccache -s || echo "sccache stats are unavailable; continuing without cache stats" |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guard only checks -f "$scriptroot/../sccache", but with set -e the build will still fail later if that file isn't executable or can't be invoked. It should check that the binary is executable (and ideally invoke it via its full path) before enabling USE_SCCACHE/modifying PATH.
| # Enable sccache for linux-x64 builds if the binary is present in the repo root. | |
| if [[ "$os" == "linux" && "$arch" == "x64" && -f "$scriptroot/../sccache" ]]; then | |
| export PATH="$scriptroot/..:$PATH" | |
| export USE_SCCACHE=true | |
| export SCCACHE_AZURE_BLOB_CONTAINER=runtime-cache | |
| export SCCACHE_AZURE_CONNECTION_STRING="BlobEndpoint=https://runsccache.blob.core.windows.net" | |
| export SCCACHE_AZURE_NO_CREDENTIALS=true | |
| echo "sccache enabled for linux-x64 build" | |
| sccache -s | |
| # Enable sccache for linux-x64 builds if the binary is present and executable in the repo root. | |
| if [[ "$os" == "linux" && "$arch" == "x64" && -f "$scriptroot/../sccache" && -x "$scriptroot/../sccache" ]]; then | |
| export PATH="$scriptroot/..:$PATH" | |
| export USE_SCCACHE=true | |
| export SCCACHE_AZURE_BLOB_CONTAINER=runtime-cache | |
| export SCCACHE_AZURE_CONNECTION_STRING="BlobEndpoint=https://runsccache.blob.core.windows.net" | |
| export SCCACHE_AZURE_NO_CREDENTIALS=true | |
| echo "sccache enabled for linux-x64 build" | |
| "$scriptroot/../sccache" -s |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SCCACHE_LOG=debug is enabled unconditionally when sccache is detected, which can produce very large logs and artifacts on CI runs and slow down builds. Consider using a less verbose default (or honoring an existing SCCACHE_LOG value) and only enabling debug logging when explicitly requested.
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for enabling sccache uses -f "$scriptroot/../sccache", which doesn't guarantee the file is executable. If the file exists but isn't marked executable (or is the wrong binary), later calls to sccache/CMake launcher will fail. Consider using -x (and possibly validating sccache --version) before exporting USE_SCCACHE=true.
| # Enable sccache for linux-x64 builds if the binary is present in the repo root. | |
| if [[ "${USE_SCCACHE:-}" != "true" && "$os" == "linux" && "$arch" == "x64" && -f "$scriptroot/../sccache" ]]; then | |
| export PATH="$scriptroot/..:$PATH" | |
| export USE_SCCACHE=true | |
| export SCCACHE_AZURE_BLOB_CONTAINER=runtime-cache | |
| export SCCACHE_AZURE_CONNECTION_STRING="BlobEndpoint=https://runsccache.blob.core.windows.net" | |
| export SCCACHE_AZURE_NO_CREDENTIALS=true | |
| sccache --stop-server || true | |
| # Disable idle timeout so the server stays alive across long managed-build | |
| # phases that separate native-compilation steps (e.g. clr then libs). | |
| export SCCACHE_IDLE_TIMEOUT=0 | |
| # Write sccache logs to the AzDO artifact staging directory so they get published. | |
| # Fall back to the local artifacts/log directory if not running in CI. | |
| if [[ -n "${BUILD_ARTIFACTSTAGINGDIRECTORY:-}" ]]; then | |
| __sccacheLogDir="$BUILD_ARTIFACTSTAGINGDIRECTORY/artifacts/log" | |
| else | |
| __sccacheLogDir="$scriptroot/../artifacts/log" | |
| fi | |
| mkdir -p "$__sccacheLogDir" | |
| SCCACHE_ERROR_LOG="$__sccacheLogDir/sccache_debug.log" SCCACHE_LOG=debug sccache --start-server | |
| echo "sccache enabled for linux-x64 build" | |
| sccache -s | |
| # Enable sccache for linux-x64 builds if a working sccache binary is present in the repo root. | |
| if [[ "${USE_SCCACHE:-}" != "true" && "$os" == "linux" && "$arch" == "x64" && -x "$scriptroot/../sccache" ]]; then | |
| if "$scriptroot/../sccache" --version >/dev/null 2>&1; then | |
| export PATH="$scriptroot/..:$PATH" | |
| export USE_SCCACHE=true | |
| export SCCACHE_AZURE_BLOB_CONTAINER=runtime-cache | |
| export SCCACHE_AZURE_CONNECTION_STRING="BlobEndpoint=https://runsccache.blob.core.windows.net" | |
| export SCCACHE_AZURE_NO_CREDENTIALS=true | |
| sccache --stop-server || true | |
| # Disable idle timeout so the server stays alive across long managed-build | |
| # phases that separate native-compilation steps (e.g. clr then libs). | |
| export SCCACHE_IDLE_TIMEOUT=0 | |
| # Write sccache logs to the AzDO artifact staging directory so they get published. | |
| # Fall back to the local artifacts/log directory if not running in CI. | |
| if [[ -n "${BUILD_ARTIFACTSTAGINGDIRECTORY:-}" ]]; then | |
| __sccacheLogDir="$BUILD_ARTIFACTSTAGINGDIRECTORY/artifacts/log" | |
| else | |
| __sccacheLogDir="$scriptroot/../artifacts/log" | |
| fi | |
| mkdir -p "$__sccacheLogDir" | |
| SCCACHE_ERROR_LOG="$__sccacheLogDir/sccache_debug.log" SCCACHE_LOG=debug sccache --start-server | |
| echo "sccache enabled for linux-x64 build" | |
| sccache -s | |
| fi |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sccache integration only affects CoreCLR builds because only src/coreclr/build-runtime.sh checks the USE_SCCACHE environment variable. Other native components (Mono, native libs, host/corehost) do not currently respect this setting and will not use sccache even when enabled. Consider documenting this limitation in the comment, or adding USE_SCCACHE support to other native build scripts if caching is desired for those components as well.
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block auto-enables sccache for any linux-x64 build whenever a sccache file exists in the repo root, which changes default build behavior and introduces an external cache endpoint dependency for local developer builds as well as CI. It would be safer to make this explicitly opt-in (e.g., require USE_SCCACHE=true) or at least gate it to CI-only via a well-known environment variable (e.g., TF_BUILD/CI).
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final sccache -s runs whenever a ../sccache file exists, even if the earlier enablement block was skipped (e.g., USE_SCCACHE=true is already set). In that case PATH may not include the repo root and this can fail with sccache: command not found. Consider gating this on USE_SCCACHE==true and/or invoking "$scriptroot/../sccache" -s after ensuring it’s executable.
| if [[ "$os" == "linux" && "$arch" == "x64" && -f "$scriptroot/../sccache" ]]; then | |
| sccache -s | |
| if [[ "$os" == "linux" && "$arch" == "x64" && "${USE_SCCACHE:-}" == "true" ]]; then | |
| if command -v sccache >/dev/null 2>&1; then | |
| sccache -s || true | |
| elif [[ -x "$scriptroot/../sccache" ]]; then | |
| "$scriptroot/../sccache" -s || true | |
| fi |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same linux/x64 + sccache-present condition is duplicated here and above. Consider factoring it into a single helper/variable to avoid future drift (e.g., if the condition or path changes in one place but not the other).
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linux-x64 + sccache-present condition is duplicated for the post-build stats print. To avoid the two checks drifting over time, consider factoring the condition into a single boolean/variable and reusing it for both the setup and the final sccache -s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prepending the repo root to
PATHcan unintentionally shadow system tools if a same-named executable exists in the repo (now or in the future), making builds harder to reason about. A safer pattern is to invoke sccache via an explicit absolute path and/or add only a dedicated tools directory toPATH.