Skip to content

Commit f5aeb0e

Browse files
authored
Allow ccache to reuse results across build directories (#1522)
1 parent 283cdc2 commit f5aeb0e

File tree

10 files changed

+56
-1
lines changed

10 files changed

+56
-1
lines changed

.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,12 @@ def do_is_valid_combination(self) -> bool:
926926
export distro_id='${distro_id}' # Required by find_cmake_latest.
927927
. .evergreen/scripts/find-cmake-latest.sh
928928
cmake_binary="$(find_cmake_latest)"
929+
930+
# Allow reuse of ccache compilation results between different build directories.
931+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
932+
CCACHE_BASEDIR="$(pwd)"
933+
CCACHE_NOHASHDIR=1
934+
929935
# Compile test-awsauth. Disable unnecessary dependencies since test-awsauth is copied to a remote Ubuntu 20.04 ECS cluster for testing, which may not have all dependent libraries.
930936
export CC='${CC}'
931937
"$cmake_binary" -DENABLE_TRACING=ON -DENABLE_SASL=OFF -DENABLE_SNAPPY=OFF -DENABLE_ZSTD=OFF -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF .

.evergreen/scripts/compile-openssl-static.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,10 @@ if [[ "${OSTYPE}" == darwin* ]]; then
109109
}
110110
fi
111111

112+
# Allow reuse of ccache compilation results between different build directories.
113+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
114+
CCACHE_BASEDIR="$(pwd)"
115+
CCACHE_NOHASHDIR=1
116+
112117
"${CMAKE}" "${configure_flags[@]}" .
113118
"${CMAKE}" --build . -- -j "$(nproc)"

.evergreen/scripts/compile-scan-build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ for dir in "${scan_build_directories[@]}"; do
148148
done
149149
: "${scan_build_binary:?"could not find a scan-build binary!"}"
150150

151+
# Allow reuse of ccache compilation results between different build directories.
152+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
153+
CCACHE_BASEDIR="$(pwd)"
154+
CCACHE_NOHASHDIR=1
155+
151156
"${scan_build_binary}" --use-cc="${CC}" --use-c++="${CXX}" "${cmake_binary}" "${configure_flags[@]}" .
152157

153158
if [[ "${OSTYPE}" == darwin* ]]; then

.evergreen/scripts/compile-std.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,10 @@ echo "Installing libmongocrypt... done."
134134
echo "CFLAGS: ${CFLAGS}"
135135
echo "configure_flags: ${configure_flags[*]}"
136136

137+
# Allow reuse of ccache compilation results between different build directories.
138+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
139+
CCACHE_BASEDIR="$(pwd)"
140+
CCACHE_NOHASHDIR=1
141+
137142
"${cmake_binary}" "${configure_flags[@]}" .
138143
"${cmake_binary}" --build .

.evergreen/scripts/compile-test-azurekms.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ echo "Installing libmongocrypt ... begin"
1616
}
1717
echo "Installing libmongocrypt ... end"
1818

19+
# Allow reuse of ccache compilation results between different build directories.
20+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
21+
CCACHE_BASEDIR="$(pwd)"
22+
CCACHE_NOHASHDIR=1
23+
1924
echo "Compile test-azurekms ... begin"
2025
# Disable unnecessary dependencies. test-azurekms is copied to a remote host for testing, which may not have all dependent libraries.
2126
"${cmake_binary}" \

.evergreen/scripts/compile-test-gcpkms.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ echo "Installing libmongocrypt ... begin"
1616
}
1717
echo "Installing libmongocrypt ... end"
1818

19+
# Allow reuse of ccache compilation results between different build directories.
20+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
21+
CCACHE_BASEDIR="$(pwd)"
22+
CCACHE_NOHASHDIR=1
23+
1924
echo "Compile test-gcpkms ... begin"
2025
# Disable unnecessary dependencies. test-gcpkms is copied to a remote host for testing, which may not have all dependent libraries.
2126
"${cmake_binary}" \

.evergreen/scripts/compile-unix.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ else
202202
configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=OFF"
203203
fi
204204

205+
# Allow reuse of ccache compilation results between different build directories.
206+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
207+
CCACHE_BASEDIR="$(pwd)"
208+
CCACHE_NOHASHDIR=1
209+
205210
"${cmake_binary}" "${configure_flags[@]}" ${extra_configure_flags[@]+"${extra_configure_flags[@]}"} .
206211
"${cmake_binary}" --build . -- -j "$(nproc)"
207212
"${cmake_binary}" --build . --target install

.evergreen/scripts/install-uninstall-check.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ else
4747
BSON_ONLY_OPTION="-DENABLE_MONGOC=ON"
4848
fi
4949

50+
# Allow reuse of ccache compilation results between different build directories.
51+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
52+
CCACHE_BASEDIR="$SCRATCH_DIR"
53+
CCACHE_NOHASHDIR=1
5054

5155
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION "$SCRATCH_DIR"
5256
$CMAKE --build .
@@ -201,4 +205,3 @@ if test -d $INSTALL_DIR/share/mongo-c-driver; then
201205
else
202206
echo "$INSTALL_DIR/share/mongo-c-driver check ok"
203207
fi
204-

.evergreen/scripts/link-sample-program-bson.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ mkdir -p $INSTALL_DIR
4444

4545
cd $BUILD_DIR
4646

47+
# Allow reuse of ccache compilation results between different build directories.
48+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
49+
CCACHE_BASEDIR="$SCRATCH_DIR"
50+
CCACHE_NOHASHDIR=1
51+
4752
if [ "$LINK_STATIC" ]; then
4853
# Our CMake system builds shared and static by default.
4954
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF "$SCRATCH_DIR"
@@ -71,6 +76,9 @@ else
7176

7277
fi
7378

79+
# Revert ccache options, they no longer apply.
80+
unset CCACHE_BASEDIR CCACHE_NOHASHDIR
81+
7482
ls -l $INSTALL_DIR/lib
7583

7684
set +o xtrace

.evergreen/scripts/link-sample-program.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,18 @@ fi
7272

7373
ZSTD="AUTO"
7474

75+
# Allow reuse of ccache compilation results between different build directories.
76+
export CCACHE_BASEDIR CCACHE_NOHASHDIR
77+
CCACHE_BASEDIR="$SCRATCH_DIR"
78+
CCACHE_NOHASHDIR=1
79+
7580
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $SSL_CMAKE_OPTION $SNAPPY_CMAKE_OPTION $STATIC_CMAKE_OPTION -DENABLE_ZSTD=$ZSTD "$SCRATCH_DIR"
7681
$CMAKE --build . --parallel
7782
$CMAKE --build . --parallel --target install
7883

84+
# Revert ccache options, they no longer apply.
85+
unset CCACHE_BASEDIR CCACHE_NOHASHDIR
86+
7987
ls -l $INSTALL_DIR/lib
8088

8189
set +o xtrace

0 commit comments

Comments
 (0)