Skip to content

Conversation

@marcocastignoli
Copy link
Member

@marcocastignoli marcocastignoli commented Jan 6, 2026

Depends on #16384

  • 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.

@marcocastignoli marcocastignoli mentioned this pull request Jan 13, 2026
12 tasks
@marcocastignoli marcocastignoli marked this pull request as ready for review January 26, 2026 15:32
@r0qs r0qs added the has dependencies The PR depends on other PRs that must be merged first label Jan 26, 2026
…tag` command

- Remove CCACHE_ENABLED and use CCACHE_DISABLE instead
export CCACHE_DIR="$HOME/.ccache"
export CCACHE_BASEDIR="$ROOTDIR"
export CCACHE_NOHASHDIR=1
CMAKE_OPTIONS="${CMAKE_OPTIONS:-} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
Copy link
Member

Choose a reason for hiding this comment

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

We already have ccache detection in place, I’m wondering whether it would be better to let CMake handle this automatically and remove -DCMAKE_C_COMPILER_LAUNCHER=ccache and -DCMAKE_CXX_COMPILER_LAUNCHER=ccache from here. See: https://github.com/argotorg/solidity/blob/develop/cmake/EthCcache.cmake).

Copy link
Member

Choose a reason for hiding this comment

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

We would probably need to add set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE}) on the cmake ccache config as well.

Copy link
Member

Choose a reason for hiding this comment

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

I kinda like that it's explicit. Never understood why we need this EthCcache.cmake in the first place.

Copy link
Member

@r0qs r0qs Jan 29, 2026

Choose a reason for hiding this comment

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

Haha sure. We can keep it as it is then, and don't change the cake cmake config.

Copy link
Member

Choose a reason for hiding this comment

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

Never change the cake config

Comment on lines +129 to +130
- ~/.ccache
run_with_ccache_unless_tag:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- ~/.ccache
run_with_ccache_unless_tag:
- ~/.ccache
run_with_ccache_unless_tag:

export CCACHE_DIR="$HOME/.ccache"
export CCACHE_BASEDIR="$ROOTDIR"
export CCACHE_NOHASHDIR=1
CMAKE_OPTIONS="${CMAKE_OPTIONS:-} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
Copy link
Member

@r0qs r0qs Jan 28, 2026

Choose a reason for hiding this comment

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

I think that for build.sh and build_ossfuzz.sh we can remove this and let cmake set it. For Windows, it seems that we may need to explicitly set using CMAKE_VS_GLOBALS

Comment on lines +32 to +33
CMAKE_VS_GLOBALS="CLToolPath=${WIN_PWD}/deps/ccache;UseMultiToolTask=true"
CMAKE_VS_GLOBALS_ARG=(-DCMAKE_VS_GLOBALS="$CMAKE_VS_GLOBALS")
Copy link
Member

@r0qs r0qs Jan 28, 2026

Choose a reason for hiding this comment

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

Can this be done by cmake? See: https://github.com/ccache/ccache/wiki/MS-Visual-Studio#usage-with-cmake

Maybe we can add that you our cmake ccache config.

Copy link
Member

@r0qs r0qs left a comment

Choose a reason for hiding this comment

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

Since #16385 (comment) is @clonker’s preference, and I don’t have a strong opinion either way, I’m okay with keeping some configurations out of CMake and explicitly defining them in the build scripts.

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

Labels

external contribution ⭐ has dependencies The PR depends on other PRs that must be merged first

Projects

Status: Sprint - Needs Review

Development

Successfully merging this pull request may close these issues.

4 participants