Skip to content

Commit

Permalink
Fix rust-lang#6805: add --enable-ccache configure option to prefix co…
Browse files Browse the repository at this point in the history
…mpiler invocations with ccache to attempt to reuse common results, e.g. for LLVM (re)builds.
  • Loading branch information
pnkfelix committed May 29, 2013
1 parent f254d11 commit 2b08337
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
43 changes: 39 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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%/}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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=
Expand Down
29 changes: 29 additions & 0 deletions mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) \
Expand Down

1 comment on commit 2b08337

@catamorphism
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ - great!

Please sign in to comment.