问题原因
源码使用的ccach版本太旧,经常产生各种问题,官方停用了ccach,需要使用建议用户安装新版本的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.
解决方案
- 1.安装ccache
sudo apt-get install ccache
- 2.添加ccach环境变量以及配置
修改文件 ~/.bashrc
export USE_CCACHE=1 #使用ccache export CCACHE_EXEC=/usr/bin/ccache #使用配置程序路径,不清楚可用 whereis ccache 查询 export CCACHE_DIR=~/.ccache #缓存路径,建议放在固态硬盘 export CCACHE_COMPRESS=1 #压缩,会损失部分性能 ${CCACHE_EXEC} -M 100G #设置缓存空间大小
- 3.修改build下的文件
修改 build/core/ccache.mk 文件
...... CCACHE_EXEC := /usr/bin/ccache #保证在下面句之前即可 ifneq ($(CCACHE_EXEC),) ......
更多关于ccache
ccache是一个编译缓存工具,除了android源码编译可用通过ccache提高编译速度外,其他项目也能使用想了解更多用法可通过下面地址查看了解。 文档:ccache (简体中文)
评论区