Skip to content

Allow ccache to reuse results across build directories #1522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,12 @@ def do_is_valid_combination(self) -> bool:
export distro_id='${distro_id}' # Required by find_cmake_latest.
. .evergreen/scripts/find-cmake-latest.sh
cmake_binary="$(find_cmake_latest)"

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
CCACHE_NOHASHDIR=1

# 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.
export CC='${CC}'
"$cmake_binary" -DENABLE_TRACING=ON -DENABLE_SASL=OFF -DENABLE_SNAPPY=OFF -DENABLE_ZSTD=OFF -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF .
Expand Down
5 changes: 5 additions & 0 deletions .evergreen/scripts/compile-openssl-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,10 @@ if [[ "${OSTYPE}" == darwin* ]]; then
}
fi

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
CCACHE_NOHASHDIR=1

"${CMAKE}" "${configure_flags[@]}" .
"${CMAKE}" --build . -- -j "$(nproc)"
5 changes: 5 additions & 0 deletions .evergreen/scripts/compile-scan-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ for dir in "${scan_build_directories[@]}"; do
done
: "${scan_build_binary:?"could not find a scan-build binary!"}"

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
CCACHE_NOHASHDIR=1

"${scan_build_binary}" --use-cc="${CC}" --use-c++="${CXX}" "${cmake_binary}" "${configure_flags[@]}" .

if [[ "${OSTYPE}" == darwin* ]]; then
Expand Down
5 changes: 5 additions & 0 deletions .evergreen/scripts/compile-std.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,10 @@ echo "Installing libmongocrypt... done."
echo "CFLAGS: ${CFLAGS}"
echo "configure_flags: ${configure_flags[*]}"

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
CCACHE_NOHASHDIR=1

"${cmake_binary}" "${configure_flags[@]}" .
"${cmake_binary}" --build .
5 changes: 5 additions & 0 deletions .evergreen/scripts/compile-test-azurekms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ echo "Installing libmongocrypt ... begin"
}
echo "Installing libmongocrypt ... end"

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
CCACHE_NOHASHDIR=1

echo "Compile test-azurekms ... begin"
# Disable unnecessary dependencies. test-azurekms is copied to a remote host for testing, which may not have all dependent libraries.
"${cmake_binary}" \
Expand Down
5 changes: 5 additions & 0 deletions .evergreen/scripts/compile-test-gcpkms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ echo "Installing libmongocrypt ... begin"
}
echo "Installing libmongocrypt ... end"

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
CCACHE_NOHASHDIR=1

echo "Compile test-gcpkms ... begin"
# Disable unnecessary dependencies. test-gcpkms is copied to a remote host for testing, which may not have all dependent libraries.
"${cmake_binary}" \
Expand Down
5 changes: 5 additions & 0 deletions .evergreen/scripts/compile-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ else
configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=OFF"
fi

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
CCACHE_NOHASHDIR=1

"${cmake_binary}" "${configure_flags[@]}" ${extra_configure_flags[@]+"${extra_configure_flags[@]}"} .
"${cmake_binary}" --build . -- -j "$(nproc)"
"${cmake_binary}" --build . --target install
5 changes: 4 additions & 1 deletion .evergreen/scripts/install-uninstall-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ else
BSON_ONLY_OPTION="-DENABLE_MONGOC=ON"
fi

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$SCRATCH_DIR"
CCACHE_NOHASHDIR=1

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

8 changes: 8 additions & 0 deletions .evergreen/scripts/link-sample-program-bson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ mkdir -p $INSTALL_DIR

cd $BUILD_DIR

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$SCRATCH_DIR"
CCACHE_NOHASHDIR=1

if [ "$LINK_STATIC" ]; then
# Our CMake system builds shared and static by default.
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF "$SCRATCH_DIR"
Expand Down Expand Up @@ -71,6 +76,9 @@ else

fi

# Revert ccache options, they no longer apply.
unset CCACHE_BASEDIR CCACHE_NOHASHDIR

ls -l $INSTALL_DIR/lib

set +o xtrace
Expand Down
8 changes: 8 additions & 0 deletions .evergreen/scripts/link-sample-program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ fi

ZSTD="AUTO"

# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$SCRATCH_DIR"
CCACHE_NOHASHDIR=1

$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"
$CMAKE --build . --parallel
$CMAKE --build . --parallel --target install

# Revert ccache options, they no longer apply.
unset CCACHE_BASEDIR CCACHE_NOHASHDIR

ls -l $INSTALL_DIR/lib

set +o xtrace
Expand Down