Android Q默认不使用ccache编译,以及修改方法

build/core/ccache.mk中有一段注释

# We no longer provide a ccache prebuilt.
#
# Ours was old, and had a number of issues that triggered non-reproducible
# results and other failures. Newer ccache versions may fix some of those
# issues, but at the large scale of our build servers, we weren't seeing
# significant performance gains from using ccache -- you end up needing very
# good locality and/or very large caches if you're building many different
# configurations.
#
# Local no-change full rebuilds were showing better results, but why not just
# use incremental builds at that point?
#
# So if you still want to use ccache, continue setting USE_CCACHE, but also set
# the CCACHE_EXEC environment variable to the path to your ccache executable.

大概意思是aosp中预置的ccache已经太老了,会引起一些意想不到的错误,不建议使用,如果一定要使用的话,可以自己安装最新版本的ccache,然后把ccache的路径添加到环境变量中

export CCACHE_EXEC := /usr/bin/ccache

export USE_CCACHE=true

不过这种export 环境变量的方法我试了好像不起作用,不知道是什么原因,可以直接在 build/core/ccache.mk 文件中添加

CCACHE_EXEC := /usr/bin/ccache,修改之后的文件如下:

#
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# We no longer provide a ccache prebuilt.
#
# Ours was old, and had a number of issues that triggered non-reproducible
# results and other failures. Newer ccache versions may fix some of those
# issues, but at the large scale of our build servers, we weren't seeing
# significant performance gains from using ccache -- you end up needing very
# good locality and/or very large caches if you're building many different
# configurations.
#
# Local no-change full rebuilds were showing better results, but why not just
# use incremental builds at that point?
#
# So if you still want to use ccache, continue setting USE_CCACHE, but also set
# the CCACHE_EXEC environment variable to the path to your ccache executable.

# add begin
CCACHE_EXEC := /usr/bin/ccache
# add end

ifneq ($(CCACHE_EXEC),)
ifneq ($(filter-out false,$(USE_CCACHE)),)
  # The default check uses size and modification time, causing false misses
  # since the mtime depends when the repo was checked out
  CCACHE_COMPILERCHECK ?= content

  # See man page, optimizations to get more cache hits
  # implies that __DATE__ and __TIME__ are not critical for functionality.
  # Ignore include file modification time since it will depend on when
  # the repo was checked out
  CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro

  # Turn all preprocessor absolute paths into relative paths.
  # Fixes absolute paths in preprocessed source due to use of -g.
  # We don't really use system headers much so the rootdir is
  # fine; ensures these paths are relative for all Android trees
  # on a workstation.
  CCACHE_BASEDIR := /

  # Workaround for ccache with clang.
  # See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
  CCACHE_CPP2 := true

  ifndef CC_WRAPPER
    CC_WRAPPER := $(CCACHE_EXEC)
  endif
  ifndef CXX_WRAPPER
    CXX_WRAPPER := $(CCACHE_EXEC)
  endif
endif
endif

猜你喜欢

转载自blog.csdn.net/zhangqi6627/article/details/107762572
今日推荐