xref: /aosp_15_r20/build/make/core/ccache.mk (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1*9e94795aSAndroid Build Coastguard Worker#
2*9e94795aSAndroid Build Coastguard Worker# Copyright (C) 2015 The Android Open Source Project
3*9e94795aSAndroid Build Coastguard Worker#
4*9e94795aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
5*9e94795aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
6*9e94795aSAndroid Build Coastguard Worker# You may obtain a copy of the License at
7*9e94795aSAndroid Build Coastguard Worker#
8*9e94795aSAndroid Build Coastguard Worker#      http://www.apache.org/licenses/LICENSE-2.0
9*9e94795aSAndroid Build Coastguard Worker#
10*9e94795aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
11*9e94795aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
12*9e94795aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*9e94795aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
14*9e94795aSAndroid Build Coastguard Worker# limitations under the License.
15*9e94795aSAndroid Build Coastguard Worker#
16*9e94795aSAndroid Build Coastguard Worker
17*9e94795aSAndroid Build Coastguard Worker# We no longer provide a ccache prebuilt.
18*9e94795aSAndroid Build Coastguard Worker#
19*9e94795aSAndroid Build Coastguard Worker# Ours was old, and had a number of issues that triggered non-reproducible
20*9e94795aSAndroid Build Coastguard Worker# results and other failures. Newer ccache versions may fix some of those
21*9e94795aSAndroid Build Coastguard Worker# issues, but at the large scale of our build servers, we weren't seeing
22*9e94795aSAndroid Build Coastguard Worker# significant performance gains from using ccache -- you end up needing very
23*9e94795aSAndroid Build Coastguard Worker# good locality and/or very large caches if you're building many different
24*9e94795aSAndroid Build Coastguard Worker# configurations.
25*9e94795aSAndroid Build Coastguard Worker#
26*9e94795aSAndroid Build Coastguard Worker# Local no-change full rebuilds were showing better results, but why not just
27*9e94795aSAndroid Build Coastguard Worker# use incremental builds at that point?
28*9e94795aSAndroid Build Coastguard Worker#
29*9e94795aSAndroid Build Coastguard Worker# So if you still want to use ccache, continue setting USE_CCACHE, but also set
30*9e94795aSAndroid Build Coastguard Worker# the CCACHE_EXEC environment variable to the path to your ccache executable.
31*9e94795aSAndroid Build Coastguard Workerifneq ($(CCACHE_EXEC),)
32*9e94795aSAndroid Build Coastguard Workerifneq ($(filter-out false,$(USE_CCACHE)),)
33*9e94795aSAndroid Build Coastguard Worker  # The default check uses size and modification time, causing false misses
34*9e94795aSAndroid Build Coastguard Worker  # since the mtime depends when the repo was checked out
35*9e94795aSAndroid Build Coastguard Worker  CCACHE_COMPILERCHECK ?= content
36*9e94795aSAndroid Build Coastguard Worker
37*9e94795aSAndroid Build Coastguard Worker  # See man page, optimizations to get more cache hits
38*9e94795aSAndroid Build Coastguard Worker  # implies that __DATE__ and __TIME__ are not critical for functionality.
39*9e94795aSAndroid Build Coastguard Worker  # Ignore include file modification time since it will depend on when
40*9e94795aSAndroid Build Coastguard Worker  # the repo was checked out
41*9e94795aSAndroid Build Coastguard Worker  CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro
42*9e94795aSAndroid Build Coastguard Worker
43*9e94795aSAndroid Build Coastguard Worker  # Turn all preprocessor absolute paths into relative paths.
44*9e94795aSAndroid Build Coastguard Worker  # Fixes absolute paths in preprocessed source due to use of -g.
45*9e94795aSAndroid Build Coastguard Worker  # We don't really use system headers much so the rootdir is
46*9e94795aSAndroid Build Coastguard Worker  # fine; ensures these paths are relative for all Android trees
47*9e94795aSAndroid Build Coastguard Worker  # on a workstation.
48*9e94795aSAndroid Build Coastguard Worker  CCACHE_BASEDIR := /
49*9e94795aSAndroid Build Coastguard Worker
50*9e94795aSAndroid Build Coastguard Worker  # Workaround for ccache with clang.
51*9e94795aSAndroid Build Coastguard Worker  # See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
52*9e94795aSAndroid Build Coastguard Worker  CCACHE_CPP2 := true
53*9e94795aSAndroid Build Coastguard Worker
54*9e94795aSAndroid Build Coastguard Worker  ifndef CC_WRAPPER
55*9e94795aSAndroid Build Coastguard Worker    CC_WRAPPER := $(CCACHE_EXEC)
56*9e94795aSAndroid Build Coastguard Worker  endif
57*9e94795aSAndroid Build Coastguard Worker  ifndef CXX_WRAPPER
58*9e94795aSAndroid Build Coastguard Worker    CXX_WRAPPER := $(CCACHE_EXEC)
59*9e94795aSAndroid Build Coastguard Worker  endif
60*9e94795aSAndroid Build Coastguard Workerendif
61*9e94795aSAndroid Build Coastguard Workerendif
62