Code:
real 0m28.677s
user 1m25.066s
sys 0m0.000s
Full kernel build from make clean. Gotta love a ccache in RAM. Great for bisecting.
Here's my script to automate it. Only dependencies are ccache, pbzip2, bash4:
Code:
#!/usr/bin/env bash
# Copyright 2010, 2011 Dan Douglas
# License: WTFPL
declare -i csize=200 # max total cache size
cdir="/home/ormaaj/doc/mnt/ccache" # tmp directory
cachepath="/home/ormaaj/$(basename "$(pwd -P)").tar.bz2" # cache directory
ccachedir="/usr/lib/ccache/bin" # ccache toolchain symlinks path
colorsetup() {
set -- 'red' 'setaf 1' 'green' 'setaf 2' 'reset' 'sgr0'
while (($#)); do
colrs["$1"]="$(tput -S <<<"$2")"
shift 2
done
echo() { printf -- '%s\n' "${colrs['green']}${@}${colrs['reset']}" ''; } >&2
}
die() {
printf '%s\n' "${colrs['red']}${!#:-'Error occured.'}${colrs['reset']}" ''
if [[ $1 == -n ]]; then
echo 'Nonfatal, continuing...'
return
else
local -i frame
while caller $frame; do
((frame++))
done
fi
exit 1
} >&2
cleanup() {
echo 'Cleaning up tmpfs...'
umount "$cdir" || die -n "Failed unmounting tmpfs at: ${cdir}"
}
doCcache() {
if [[ ! -e $cdir ]]; then
echo "No existing temporary cache directory ${cdir}, creating..."
mkdir -p "$cdir"
fi
mount -t tmpfs -o "size=$((csize+50))m" tmpfs "$cdir" || die 'mount failed'
trap -- 'cleanup' EXIT
if [[ -e $cachepath ]]; then
tar --use-compress-prog=pbzip2 -xvf "$cachepath" -C "$cdir" || die 'Failed unpacking cache files'
else
echo "No previous cache found at: ${cachepath}, creating new." >&2
fi
export PATH="${ccachedir:-'/usr/lib/ccache/bin'}:${PATH}" CCACHE_SIZE="$csize" CCACHE_DIR="$cdir"
echo "$(ccache -s)"
doCompile
echo "$(ccache -s)"
pushd "$cdir"
tar --use-compress-prog=pbzip2 -cf "$cachepath" * || die -n 'Tar failed to pack up the ccache files!'
popd
cleanup
trap - EXIT
}
doCompile() {
make clean
if make -j8; then
make modules_install || die
make firmware_install || die
cp "./arch/$(uname -m)/boot/bzImage" "/boot/$(basename "$(pwd -P)")" || die 'Failed while copying kernel image.'
else
die 'make failed'
fi
}
main() {
local -A colrs
colorsetup
pushd /usr/src/linux
if [[ $1 == -n ]]; then
doCompile
else
doCcache
fi
# schedtool -D -e emerge -v @module-rebuild
popd
}
main "$@"
# vim: fenc=utf-8 ff=unix ts=4 sts=4 sw=4 ft=sh nowrap et :