Skip to content

Commit 6ddd561

Browse files
committed
ci: use ccache in run_build command
1 parent 563f588 commit 6ddd561

File tree

1 file changed

+85
-10
lines changed

1 file changed

+85
-10
lines changed

.circleci/config.yml

Lines changed: 85 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,52 @@ commands:
186186
# --------------------------------------------------------------------------
187187
# Build Commands
188188

189+
setup_ccache:
190+
parameters:
191+
os:
192+
type: string
193+
default: "undefined"
194+
steps:
195+
- run:
196+
name: Create CMake files checksum
197+
command: |
198+
find . -name "CMakeLists.txt" -exec cat {} \; > /tmp/all-cmake-files.txt
199+
- restore_cache:
200+
keys:
201+
- ccache-v1-<<parameters.os>>-{{ arch }}-{{ .Branch }}-{{ checksum "/tmp/all-cmake-files.txt" }}
202+
- ccache-v1-<<parameters.os>>-{{ arch }}-{{ .Branch }}-
203+
- ccache-v1-<<parameters.os>>-{{ arch }}-
204+
- run:
205+
name: Install and configure ccache
206+
command: |
207+
# Install ccache if not present (cmake will use it, via EthCcache)
208+
if ! command -v ccache &> /dev/null; then
209+
if command -v brew &> /dev/null; then
210+
brew install ccache
211+
elif command -v apt &> /dev/null; then
212+
sudo apt update
213+
sudo apt install -y ccache
214+
elif command -v pacman &> /dev/null; then
215+
# ArchLinux
216+
sudo pacman --noconfirm -S ccache
217+
else
218+
echo "Warning: Unknown package manager, ccache may not be available"
219+
fi
220+
fi
221+
222+
# Configure ccache settings (only if ccache is available)
223+
if command -v ccache &> /dev/null; then
224+
ccache --set-config max_size=2G
225+
ccache --set-config cache_dir=$HOME/.ccache
226+
ccache --zero-stats
227+
228+
# Show initial stats
229+
echo "ccache initial stats:"
230+
ccache --show-stats
231+
else
232+
echo "ccache not available, skipping configuration"
233+
fi
234+
189235
setup_prerelease_commit_hash:
190236
steps:
191237
- run:
@@ -199,10 +245,25 @@ commands:
199245
echo -n "$CIRCLE_SHA1" > commit_hash.txt
200246
201247
run_build:
248+
parameters:
249+
os:
250+
type: string
251+
default: "undefined"
202252
steps:
253+
- setup_ccache:
254+
os: <<parameters.os>>
203255
- run:
204256
name: Build
205257
command: scripts/ci/build.sh
258+
- run:
259+
name: Show ccache stats
260+
command: |
261+
echo "ccache final stats:"
262+
ccache --show-stats
263+
- save_cache:
264+
key: ccache-v1-<<parameters.os>>-{{ arch }}-{{ .Branch }}-{{ checksum "/tmp/all-cmake-files.txt" }}
265+
paths:
266+
- ~/.ccache
206267

207268
run_build_ossfuzz:
208269
steps:
@@ -341,9 +402,14 @@ commands:
341402
- matrix_notify_failure_unless_pr
342403

343404
build:
405+
parameters:
406+
os:
407+
type: string
408+
default: "undefined"
344409
steps:
345410
- checkout
346-
- run_build
411+
- run_build:
412+
os: << parameters.os >>
347413
- store_artifacts_solc
348414
- store_artifacts_yul_phaser
349415
- persist_executables_to_workspace
@@ -1034,7 +1100,8 @@ jobs:
10341100
# Enough other jobs depend on it that it's worth it though.
10351101
<<: *base_ubuntu2404_xlarge
10361102
steps:
1037-
- build
1103+
- build:
1104+
os: ubu
10381105

10391106
# x64 ASAN build, for testing for memory related bugs
10401107
b_ubu_asan: &b_ubu_asan
@@ -1051,15 +1118,17 @@ jobs:
10511118
# Set the number of jobs to two instead of the default three, so that we do not run out of memory
10521119
MAKEFLAGS: -j 2
10531120
steps:
1054-
- build
1121+
- build:
1122+
os: ubu_asan
10551123

10561124
b_ubu_clang: &b_ubu_clang
10571125
<<: *base_ubuntu2404_clang_large
10581126
environment:
10591127
<<: *base_ubuntu2404_clang_large_env
10601128
MAKEFLAGS: -j 10
10611129
steps:
1062-
- build
1130+
- build:
1131+
os: ubu_clang
10631132

10641133
b_ubu_san_clang:
10651134
# This runs a bit faster on large and xlarge but on nightly efficiency matters more.
@@ -1072,7 +1141,8 @@ jobs:
10721141
# NOTE: Disabled pedantic builds to avoid false positives, see b_ubu_asan for a more detailed explanation.
10731142
CMAKE_OPTIONS: -DPEDANTIC=OFF << parameters.cmake_options >>
10741143
steps:
1075-
- build
1144+
- build:
1145+
os: ubu_san_clang
10761146

10771147
b_ubu_force_release: &b_ubu_force_release
10781148
<<: *b_ubu
@@ -1091,7 +1161,8 @@ jobs:
10911161
CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Release -DSOLC_LINK_STATIC=ON
10921162
steps:
10931163
- checkout
1094-
- run_build
1164+
- run_build:
1165+
os: ubu
10951166
- run:
10961167
name: strip binary
10971168
command: strip build/solc/solc
@@ -1109,7 +1180,8 @@ jobs:
11091180
<<: *base_ubuntu2204_large
11101181
steps:
11111182
- checkout
1112-
- run_build
1183+
- run_build:
1184+
os: ubu_2204
11131185
- matrix_notify_failure_unless_pr
11141186

11151187
b_ubu_2204_clang:
@@ -1119,7 +1191,8 @@ jobs:
11191191
MAKEFLAGS: -j 10
11201192
steps:
11211193
- checkout
1122-
- run_build
1194+
- run_build:
1195+
os: ubu_2204_clang
11231196
- matrix_notify_failure_unless_pr
11241197

11251198
b_ubu_ossfuzz: &b_ubu_ossfuzz
@@ -1157,7 +1230,8 @@ jobs:
11571230
command: |
11581231
pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake git openssh tar
11591232
- checkout
1160-
- run_build
1233+
- run_build:
1234+
os: archlinux
11611235
- store_artifacts_solc
11621236
- persist_executables_to_workspace
11631237
- matrix_notify_failure_unless_pr
@@ -1172,7 +1246,8 @@ jobs:
11721246
steps:
11731247
- checkout
11741248
- install_dependencies_osx
1175-
- run_build
1249+
- run_build:
1250+
os: mac
11761251
- store_artifacts_solc
11771252
- store_artifacts_yul_phaser
11781253
- persist_executables_to_workspace_osx

0 commit comments

Comments
 (0)