侧边栏壁纸
博主头像
Eoser's page! 博主等级

@学习@生活@自己

  • 累计撰写 121 篇文章
  • 累计创建 31 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Android12 不支持 ccache 编译缓存问题

eoser
2023-04-04 / 0 评论 / 0 点赞 / 2 阅读 / 0 字

问题原因

源码使用的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 (简体中文)

0

评论区