mirror of
https://github.com/ceph/ceph
synced 2025-02-24 11:37:37 +00:00
run-make-check.sh: ccache goodness for everyone
Since run-make-check.sh already ensures that ccache is installed,
it makes sense to let everyone benefit from the ccache
tweaks introduced by 4cb5a59053
Note 1: The previous solution using "date" would cause build tools to reset
their timestamps after 24 hours, on subsequent runs of run-make-check.sh.
In order to maximize ccache effectiveness, this commit sets SOURCE_DATE_EPOCH
to a fixed value: the number of seconds elapsed since the Unix epoch as at
January 1, 2000 (chosen to commemorate Y2K armageddon).
Note 2: this commit introduces "set -e". This was actually in effect
before, via "source install-deps.sh". Better to make it explicit.
Fixes: http://tracker.ceph.com/issues/24777
Signed-off-by: Nathan Cutler <ncutler@suse.com>
This commit is contained in:
parent
c8691cd9a3
commit
2315928acd
@ -12,9 +12,26 @@
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
|
||||
#
|
||||
# Return MAX(1, (number of processors / 2)) by default or NPROC
|
||||
#
|
||||
set -e
|
||||
|
||||
trap clean_up_after_myself EXIT
|
||||
|
||||
ORIGINAL_CCACHE_CONF="$HOME/.ccache/ccache.conf"
|
||||
SAVED_CCACHE_CONF="$HOME/.run-make-check-saved-ccache-conf"
|
||||
|
||||
function save_ccache_conf() {
|
||||
test -f $ORIGINAL_CCACHE_CONF && cp $ORIGINAL_CCACHE_CONF $SAVED_CCACHE_CONF || true
|
||||
}
|
||||
|
||||
function restore_ccache_conf() {
|
||||
test -f $SAVED_CCACHE_CONF && mv $SAVED_CCACHE_CONF $ORIGINAL_CCACHE_CONF || true
|
||||
}
|
||||
|
||||
function clean_up_after_myself() {
|
||||
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
|
||||
restore_ccache_conf
|
||||
}
|
||||
|
||||
function get_processors() {
|
||||
if test -n "$NPROC" ; then
|
||||
echo $NPROC
|
||||
@ -60,6 +77,11 @@ function run() {
|
||||
echo "This probably means distribution $ID is not supported by run-make-check.sh" >&2
|
||||
fi
|
||||
|
||||
if ! type ccache > /dev/null 2>&1 ; then
|
||||
echo "ERROR: ccache could not be installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -f ./install-deps.sh ; then
|
||||
$DRY_RUN source ./install-deps.sh || return 1
|
||||
fi
|
||||
@ -76,28 +98,34 @@ function run() {
|
||||
|
||||
CMAKE_BUILD_OPTS="-DWITH_FIO=ON -DWITH_GTEST_PARALLEL=ON"
|
||||
|
||||
# Are we in the CI ?
|
||||
cat <<EOM
|
||||
Note that the binaries produced by this script do not contain correct time
|
||||
and git version information, which may make them unsuitable for debugging
|
||||
and production use.
|
||||
EOM
|
||||
save_ccache_conf
|
||||
# remove the entropy generated by the date/time embedded in the build
|
||||
CMAKE_BUILD_OPTS="$CMAKE_BUILD_OPTS -D ENABLE_GIT_VERSION=OFF"
|
||||
export SOURCE_DATE_EPOCH="946684800"
|
||||
ccache -o sloppiness=time_macros
|
||||
ccache -o run_second_cpp=true
|
||||
if [ -n "$JENKINS_HOME" ]; then
|
||||
echo "Jenkins got detected, let's tune the build"
|
||||
# The following settings are made for improving ccache efficiency
|
||||
# by removing the entropy generated by the date/time embedded in the build
|
||||
CMAKE_BUILD_OPTS="$CMAKE_BUILD_OPTS -D ENABLE_GIT_VERSION=OFF"
|
||||
export SOURCE_DATE_EPOCH=$(date +%D |date -f- +%s)
|
||||
ccache -o sloppiness=time_macros
|
||||
ccache -o run_second_cpp=true
|
||||
|
||||
# Build host has plenty of space available, let's use it to keep
|
||||
# various versions of the built objects. This could increase the cache hit
|
||||
# if the same or similar PRs are running several times
|
||||
ccache -o max_size=100G
|
||||
ccache -z # Reset the ccache statistics
|
||||
# Build host has plenty of space available, let's use it to keep
|
||||
# various versions of the built objects. This could increase the cache hit
|
||||
# if the same or similar PRs are running several times
|
||||
ccache -o max_size=100G
|
||||
else
|
||||
echo "Current ccache max_size setting:"
|
||||
ccache -p | grep max_size
|
||||
fi
|
||||
ccache -z # Reset the ccache statistics
|
||||
|
||||
$DRY_RUN ./do_cmake.sh $CMAKE_BUILD_OPTS $CMAKE_PYTHON_OPTS $@ || return 1
|
||||
$DRY_RUN cd build
|
||||
$DRY_RUN make $BUILD_MAKEOPTS tests || return 1
|
||||
if [ -n "$JENKINS_HOME" ]; then
|
||||
ccache -s # print the ccache statistics to evaluate the efficiency
|
||||
fi
|
||||
|
||||
ccache -s # print the ccache statistics to evaluate the efficiency
|
||||
|
||||
# prevent OSD EMFILE death on tests, make sure large than 1024
|
||||
$DRY_RUN ulimit -n $(ulimit -Hn)
|
||||
if [ $(ulimit -n) -lt 1024 ];then
|
||||
@ -124,14 +152,7 @@ function main() {
|
||||
echo "Please fix 'hostname --fqdn', otherwise 'make check' will fail"
|
||||
return 1
|
||||
fi
|
||||
if run "$@" ; then
|
||||
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
|
||||
echo "cmake check: successful run on $(git rev-parse HEAD)"
|
||||
return 0
|
||||
else
|
||||
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
|
||||
return 1
|
||||
fi
|
||||
run "$@" && echo "make check: successful run on $(git rev-parse HEAD)"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user