Currently, bazel based ebuilds fail when FEATURES=ccache is enabled due to a sandbox violation. The issue can be roughly summarized as follows. Bazel clears the environment variable CCACHE_DIR. When CCACHE_DIR is unset, ccache defaults to using "${HOME}/.ccache" as the cache directory. For portage, "${HOME}/.ccache" expands to "/var/lib/portage/home/.ccache". Therefore, when ccache is enabled, it tries to cache files in "/var/lib/portage/home/.ccache" that results in the sandbox violation. Example of the ebuild that triggers this issue is `tensorflow`. So, the steps to reproduce are: 1. Install and configure ccache. 2. FEATURES=ccache emerge tensorflow Unfortunately, I am no longer using bazel nor tensorflow, so I cannot provide the exact logs, but I think this bug might be helpful to other users. This issue can be solved by modifying the `bazel.eclass` eclass and adding the following lines ``` build --action_env CCACHE_DIR build --host_action_env CCACHE_DIR ``` right below the line containing `build --action_env HOME` of `bazel_setup_bazelrc` function.
I have found a solution: set `cache_dir` in `/etc/ccache.conf`, like this: ``` cache_dir=/var/cache/ccache max_size=300G umask=002 compiler_check=%compiler% -v compress=false ``` I am not familiar with bazel too and I have tried to pass `CCACHE_DIR` and `-d $CCACHE_DIR` into bazel but all get failed, only this method works.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8876dc1db3205682d1ed8543b7fef1ce2b619874 commit 8876dc1db3205682d1ed8543b7fef1ce2b619874 Author: Jakov Smolić <jsmolic@gentoo.org> AuthorDate: 2024-02-24 12:55:07 +0000 Commit: Jakov Smolić <jsmolic@gentoo.org> CommitDate: 2024-02-24 12:55:07 +0000 Remove bazel.eclass Closes: https://bugs.gentoo.org/804690 Bug: https://bugs.gentoo.org/804690 Signed-off-by: Jakov Smolić <jsmolic@gentoo.org> eclass/bazel.eclass | 227 ---------------------------------------------------- 1 file changed, 227 deletions(-) Additionally, it has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8876dc1db3205682d1ed8543b7fef1ce2b619874 commit 8876dc1db3205682d1ed8543b7fef1ce2b619874 Author: Jakov Smolić <jsmolic@gentoo.org> AuthorDate: 2024-02-24 12:55:07 +0000 Commit: Jakov Smolić <jsmolic@gentoo.org> CommitDate: 2024-02-24 12:55:07 +0000 Remove bazel.eclass Closes: https://bugs.gentoo.org/804690 Bug: https://bugs.gentoo.org/804690 Signed-off-by: Jakov Smolić <jsmolic@gentoo.org> eclass/bazel.eclass | 227 ---------------------------------------------------- 1 file changed, 227 deletions(-)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=c68172926bdaff7eb20553509c4f00196e98b07a commit c68172926bdaff7eb20553509c4f00196e98b07a Author: Huang Rui <vowstar@gmail.com> AuthorDate: 2024-02-25 16:04:05 +0000 Commit: Huang Rui <vowstar@gmail.com> CommitDate: 2024-02-25 16:04:19 +0000 sci-electronics/verible: treeclean bazel eclass dropped from ::gentoo Bug: https://bugs.gentoo.org/804690 Signed-off-by: Huang Rui <vowstar@gmail.com> sci-electronics/verible/Manifest | 42 -------- sci-electronics/verible/metadata.xml | 31 ------ sci-electronics/verible/verible-0.0.3420.ebuild | 121 ------------------------ sci-electronics/verible/verible-0.0.3430.ebuild | 121 ------------------------ 4 files changed, 315 deletions(-)