如何让 Bazel、ccache 和沙箱协同工作(ccache 只读文件系统)

2024-01-01

我正在尝试使用通过 copr 安装的 Bazel 0.16.1 和通过 DNF 安装的 ccache 3.4.2 在 Fedora 28 上构建 C++ 应用程序。我使用默认的 cc_binary 和 cc_library 规则。当我运行 bazel build 命令时,ccache 出现错误:

ccache: error: Failed to create temporary file for /home/mwalker/.ccache/tmp/time.stdout: Read-only file system

当我构建时我可以看到--verbose_failures --sandbox_debug我们没有挂载 ccache tmp 目录 r/w。

那么,如何让 bazel 以读写方式挂载我的 ccache 目录,或者如何通过 bazel 告诉 ccache 我的工作区的正确缓存目录所在的位置?

When I run the same command on Ubuntu 18.04 it succeeds, so this leads me to believe that ccache is supported in some way.

看起来我的问题的一部分是 ccache 将其编译器驱动程序安装为 gcc。例如。which gcc -> /usr/lib64/ccache/gcc。在 Ubuntu 上,必须显式调用 ccache,而默认工具链不会调用它。


您可以将现有目录添加到沙箱中--sandbox_writable_path=<path> https://docs.bazel.build/versions/master/command-line-reference.html[1].


[1] https://docs.bazel.build/versions/master/command-line-reference.html https://docs.bazel.build/versions/master/command-line-reference.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何让 Bazel、ccache 和沙箱协同工作(ccache 只读文件系统) 的相关文章

随机推荐