Skip to content

Conversation

@marcocastignoli
Copy link
Member

  • 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.
  • Adds/ensures ccache is installed on all relevant executors: macOS, Arch Linux, and the Ubuntu/emscripten buildpack-deps Docker images.
  • 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 develop-cache-test. We can later create another PR starting from this branch to see if the builds are indeed using the cache generated by develop-cache-test, before merging this PR let's remember to fix the occurrences of develop-cache-test in the code.

@github-actions
Copy link

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.

apt-get install -qqy --no-install-recommends \
build-essential \
cmake \
ccache \
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have a special workflow for updating buildpack images and this needs to be done in two steps (separate PRs). See buildpack-deps/README.md.

Comment on lines 209 to 212
run_build:
steps:
# TODO: remove the line below
# Before merging this PR we need to use an alternative develop branch to test the functionality, `develop-cache-test`
Copy link
Collaborator

Choose a reason for hiding this comment

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

We want to be able to run without ccache on tags, so we still need to keep a non-cached variant of this command around.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think is the best solution to handle this case? Something like this would work or do we need a more generic solution?

      - when:
          condition:
            and:
              - equal: ["", << pipeline.git.tag >>]
          steps:
            - run:
                name: Build (ccache)
                command: |
                  export CCACHE_DIR="$HOME/.ccache"
                  export CCACHE_BASEDIR="$(pwd)"
                  export CCACHE_NOHASHDIR=1
                  mkdir -p "$CCACHE_DIR"
                  export CMAKE_OPTIONS="${CMAKE_OPTIONS:-} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
                  ccache -z

                  scripts/ci/build.sh

                  ccache -s
      - when:
          condition:
            or:
              - not:
                  equal: ["", << pipeline.git.tag >>]
          steps:
            - run:
                name: Build (no ccache)
                command: scripts/ci/build.sh

Copy link
Collaborator

@cameel cameel Dec 22, 2025

Choose a reason for hiding this comment

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

Yeah, that should work.

I mean, I would have preferred something that directly passes this decision as a parameter from the top, but I that would be annoying, because you'd have to modify most jobs to have parameters. A global version like this does not have this problem.

export CCACHE_NOHASHDIR=1
mkdir -p "$CCACHE_DIR"
export CMAKE_OPTIONS="${CMAKE_OPTIONS:-} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
ccache -z || true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we expect not to have this on any of the platforms?
Is that platform Windows? :P

equal: ["develop-cache-test", << pipeline.git.branch >>]
steps:
- save_cache:
key: v1-ccache-{{ arch }}-develop-cache-test-{{ .Revision }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I expect that we might want to invalidate cache whenever we suspect something weird is going on. It would be convenient to be able to do that without having to merge a PR. In an extreme case we might even not be able to merge one due to required jobs failing because of cache. In addition to the hard-coded version we could also keep a variable in CircleCI config that we can bump to get the same effect:

Suggested change
key: v1-ccache-{{ arch }}-develop-cache-test-{{ .Revision }}
key: v1-{{ .Environment.CCACHE_KEY }}-ccache-{{ arch }}-develop-cache-test-{{ .Revision }}

Comment on lines 225 to 226
- v1-ccache-{{ arch }}-
- run:
Copy link
Collaborator

Choose a reason for hiding this comment

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

we usually add a warning here because not everyone may realize that changing the code between restore_cache and save_cache doe not invalidate the cache automatically.

Suggested change
- v1-ccache-{{ arch }}-
- run:
- v1-ccache-{{ arch }}-
# WARNING! If you edit anything between here and save_cache, remember to bump version or invalidate the cache manually.
- run:

- when:
condition:
not:
equal: ["develop-cache-test", << pipeline.git.branch >>]
Copy link
Collaborator

Choose a reason for hiding this comment

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

The breaking branch needs special treatment as well. It's not a feature branch but currently would be treated like one. It's like develop, but for the next breaking version.

- improve comments and warnings
- treat ccache as always existing
- add CCACHE_KEY to easily invalidate cache
- skip cache also on "breaking" branch
@github-actions
Copy link

ghcr.io/argotorg/solidity-buildpack-deps:ubuntu.clang.ossfuzz-13 [ghcr.io/argotorg/solidity-buildpack-deps@sha256:ed197b3d083aa05526ec40d6d3d1f2bc3e8856bd23c1a7037becb4d3a15b3529].

@github-actions
Copy link

ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.clang-8 [ghcr.io/argotorg/solidity-buildpack-deps@sha256:4c936d31b0eaebb770ea72e6fb8af002dfbdb920604858afa0c8cd055aa49664].

@github-actions
Copy link

ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404-7 [ghcr.io/argotorg/solidity-buildpack-deps@sha256:bf3c7dac5f613d220757d9e32ee6855648b98bdb460a984ade214f8fe6920d63].

@github-actions
Copy link

ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.arm-3 [ghcr.io/argotorg/solidity-buildpack-deps@sha256:c4f7da98bc922e8ff2e58d5cfc0216b698ca1ee3ed84f1a0561bbf3641905b4a].

@github-actions
Copy link

ghcr.io/argotorg/solidity-buildpack-deps:emscripten-22 [ghcr.io/argotorg/solidity-buildpack-deps@sha256:e7ca70baa048d4307124f22670f38db4205d57689661feb8e92ea50a31d8fdbe].

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants