Skip to content

Conversation

@marcocastignoli
Copy link
Member

@marcocastignoli marcocastignoli commented Jan 6, 2026

  • This PR enables ccache for the main CMake build in CircleCI and stores the cache between runs.
  • CircleCI now restores ~/.ccache on most branches from the latest cache produced on develop, so builds can reuse compiled objects.
  • Runs on develop start from an empty cache and then save a fresh ~/.ccache snapshot (one per revision) to keep the seed cache updated.
  • The build step also resets and prints ccache stats (ccache -z / ccache -s) so we can see cache hits in the logs.

For the purpose of testing instead of creating the cache from develop, the cache is created by this branch ci-ccache. We can later create another PR starting from this branch to see if the builds are indeed using the cache generated by ci-ccache, before merging this PR let's remember to fix the occurrences of ci-ccache in the code.

Results

In this PR, I edited a single file and the CI is successfully using ccache for all build job. These are the results of the speedup:

Job ccache disabled ccache enabled speedup
b_ubu_force_release 10:52 01:02 11×
b_ubu_static_arm 20:55 01:09 18×
b_ubu_min_req 17:25 01:39 11×
b_ubu_ossfuzz 22:05 02:13 10×
b_ubu_min_req_clang 12:15 01:29
b_ubu_clang 12:54 01:32
b_win 23:06 05:47
b_ubu 11:22 00:42 16×
b_ems 07:18 03:15
b_osx 09:25 01:14
b_ubu_static 11:16 00:42 16×
b_archlinux 18:49 01:29 13×

In total we save ~23 minutes (or around 2$) each run.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

export CCACHE_NOHASHDIR=1
export CCACHE_COMPILERTYPE=msvc
# Hard-coded MSVC cl.exe path
CCACHE_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"
Copy link
Member

Choose a reason for hiding this comment

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

won't that very easily break?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean the hard-coded path?

I cannot find a reliable way to find that path.

Copy link
Member

@clonker clonker Jan 7, 2026

Choose a reason for hiding this comment

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

vswhere.exe might be able to do that for you (or vcvarsall or something)

Copy link
Member Author

Choose a reason for hiding this comment

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

@marcocastignoli marcocastignoli moved this to Sprint - Needs Review in Sourcify Public Jan 8, 2026
@marcocastignoli marcocastignoli self-assigned this Jan 8, 2026
Copy link
Member

@clonker clonker left a comment

Choose a reason for hiding this comment

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

some preliminary comments. very nice work altogether! i was thinking whether we should perhaps have another environment variable that globally enables or disables ccache entirely. that way, if there are problems, we can quickly switch it off.


# On `ci-ccache` and `breaking` we intentionally do NOT restore any ccache, so every run starts from scratch.
# Tags always skip ccache. Other branches restore the most recent cache produced on `ci-ccache`.
- when:
Copy link
Member

@r0qs r0qs Jan 9, 2026

Choose a reason for hiding this comment

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

I'm wondering if this condition can be added to a command, maybe in ensure_ccache_key, and we could pass the list of branches to skip as parameters. In this way we can avoid some repetition in the config.

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea! I did the same also for saving save_ccache_if_develop

set -ex

ROOTDIR="$(dirname "$0")/../.."
ROOTDIR="$(realpath "$(dirname "$0")/../..")"
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change necessary?

Copy link
Member Author

@marcocastignoli marcocastignoli Jan 12, 2026

Choose a reason for hiding this comment

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

Because of CCACHE_BASEDIR,it needs to be an absolute path to keep ccache hash paths consistent across runs. it's probably not needed but it's cleaner imo

mv cmake-3.27.4-windows-x86_64 "$PSScriptRoot\..\deps\cmake"
Remove-Item cmake.zip

Invoke-WebRequest -URI "https://github.com/ccache/ccache/releases/download/v4.12.2/ccache-4.12.2-windows-x86_64.zip" -OutFile ccache.zip
Copy link
Member

@r0qs r0qs Jan 9, 2026

Choose a reason for hiding this comment

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

Not directly related to this PR, but would it be better to define the versions as variables? That would make them easier to update in the future and help avoid potential mistakes when changing paths after a version bump.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we want to tackle this in this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Sprint - Needs Review

Development

Successfully merging this pull request may close these issues.

4 participants