-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -584,6 +584,21 @@ arguments+=("-clp:ForceNoAlign") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| initDistroRid "$os" "$arch" "$crossBuild" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 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 PATH="$scriptroot/..:$PATH" | |
| export PATH="$PATH:$scriptroot/.." |
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 condition only checks -f "$scriptroot/../sccache", but the code later executes sccache as a command name. If the file exists but isn’t executable (or isn’t found via PATH), this will fail. Prefer checking -x and executing "$scriptroot/../sccache" (or ensuring PATH is updated before any invocation).
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 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 sccache presence check uses -f but the script immediately executes sccache. If the file exists but isn’t executable (or is the wrong binary), the build will fail (this script runs with set -e). Prefer checking -x and/or validating that invoking sccache --version succeeds before enabling it.
| 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 | |
| mkdir -p "$scriptroot/../artifacts/log" | |
| export SCCACHE_ERROR_LOG="$scriptroot/../artifacts/log/sccache_debug.log" | |
| export SCCACHE_LOG=debug | |
| sccache --start-server | |
| echo "sccache enabled for linux-x64 build" | |
| sccache -s | |
| if [[ "$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 | |
| mkdir -p "$scriptroot/../artifacts/log" | |
| export SCCACHE_ERROR_LOG="$scriptroot/../artifacts/log/sccache_debug.log" | |
| export SCCACHE_LOG=debug | |
| "$scriptroot/../sccache" --start-server | |
| echo "sccache enabled for linux-x64 build" | |
| "$scriptroot/../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 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.
sccache --start-server and sccache -s will hard-fail the entire build if sccache can’t start or the remote backend isn’t reachable (because eng/build.sh runs with set -e). If sccache is intended to be a best-effort accelerator, wrap these invocations so failures don’t abort the build, and only emit stats when the server is actually running.
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).
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 enablement check uses
-f "$scriptroot/../sccache", but that doesn't guarantee the file is executable. If the file exists without execute permissions, the latersccache -s/compiler launcher will fail and stop the build. Prefer checking-x(and/or verifyingcommand -v sccacheafter updating PATH) before enabling.