Fix #6805: add --enable-ccache configure option to prefix compiler invocations with ccache to attempt to reuse common results, e.g. for LLVM (re)builds.

This commit is contained in:
Felix S. Klock II 2013-05-29 23:18:09 +02:00
parent f254d119ea
commit 2b083373e4
2 changed files with 68 additions and 4 deletions

43
configure vendored
View File

@ -376,6 +376,7 @@ opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
opt manage-submodules 1 "let the build manage the git submodules"
opt mingw-cross 0 "cross-compile for win32 using mingw"
opt clang 0 "prefer clang to gcc for building the runtime"
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
valopt prefix "/usr/local" "set installation prefix"
@ -421,6 +422,7 @@ else
fi
probe CFG_CLANG clang++
probe CFG_CCACHE ccache
probe CFG_GCC gcc
probe CFG_LD ld
probe CFG_VALGRIND valgrind
@ -571,6 +573,16 @@ else
CFG_C_COMPILER="gcc"
fi
if [ ! -z "$CFG_ENABLE_CCACHE" ]
then
if [ -z "$CFG_CCACHE" ]
then
err "ccache requested but not found"
fi
CFG_C_COMPILER="ccache $CFG_C_COMPILER"
fi
# a little post-processing of various config values
CFG_PREFIX=${CFG_PREFIX%/}
@ -825,20 +837,35 @@ do
--enable-bindings=none --disable-threads \
--disable-pthreads"
if [ "$CFG_C_COMPILER" = "clang" ]
then
case "$CFG_C_COMPILER" in
("ccache clang")
LLVM_CXX_32="ccache clang++ -m32 -Qunused-arguments"
LLVM_CC_32="ccache clang -m32 -Qunused-arguments"
LLVM_CXX_64="ccache clang++ -Qunused-arguments"
LLVM_CC_64="ccache clang -Qunused-arguments"
;;
("clang")
LLVM_CXX_32="clang++ -m32"
LLVM_CC_32="clang -m32"
LLVM_CXX_64="clang++"
LLVM_CC_64="clang"
else
;;
("ccache gcc")
LLVM_CXX_32="ccache g++ -m32"
LLVM_CC_32="ccache gcc -m32"
LLVM_CXX_64="ccache g++"
LLVM_CC_64="ccache gcc"
;;
("gcc")
LLVM_CXX_32="g++ -m32"
LLVM_CC_32="gcc -m32"
LLVM_CXX_64="g++"
LLVM_CC_64="gcc"
fi
esac
LLVM_CFLAGS_32="-m32"
LLVM_CXXFLAGS_32="-m32"
@ -935,6 +962,14 @@ then
putvar CFG_PAXCTL
fi
# Avoid spurious warnings from clang by feeding it original source on
# ccache-miss rather than preprocessed input.
if [ ! -z "$CFG_ENABLE_CCACHE" ] && [ ! -z "$CFG_ENABLE_CLANG" ]
then
CFG_CCACHE_CPP2=1
putvar CFG_CCACHE_CPP2
fi
if [ ! -z $BAD_PANDOC ]
then
CFG_PANDOC=

View File

@ -105,10 +105,35 @@ ifeq ($(CFG_C_COMPILER),gcc)
ifeq ($(origin CPP),default)
CPP=gcc
endif
else
ifeq ($(CFG_C_COMPILER),ccache clang)
# The -Qunused-arguments sidesteps spurious warnings from clang
ifeq ($(origin CC),default)
CC=ccache clang -Qunused-arguments
endif
ifeq ($(origin CXX),default)
CXX=ccache clang++ -Qunused-arguments
endif
ifeq ($(origin CPP),default)
CPP=ccache clang -Qunused-arguments
endif
else
ifeq ($(CFG_C_COMPILER),ccache gcc)
ifeq ($(origin CC),default)
CC=ccache gcc
endif
ifeq ($(origin CXX),default)
CXX=ccache g++
endif
ifeq ($(origin CPP),default)
CPP=ccache gcc
endif
else
CFG_ERR := $(error please try on a system with gcc or clang)
endif
endif
endif
endif
# x86_64-unknown-linux-gnu configuration
@ -366,6 +391,10 @@ CFG_LDPATH_x86_64-unknown-freebsd :=
CFG_RUN_x86_64-unknown-freebsd=$(2)
CFG_RUN_TARG_x86_64-unknown-freebsd=$(call CFG_RUN_x86_64-unknown-freebsd,,$(2))
ifeq ($(CFG_CCACHE_CPP2),1)
CCACHE_CPP2=1
export CCACHE_CPP
endif
define CFG_MAKE_TOOLCHAIN
CFG_COMPILE_C_$(1) = $$(CC_$(1)) \