Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 804690 - bazel.eclass: dev-build/bazel builds fail when CCACHE enabled
Summary: bazel.eclass: dev-build/bazel builds fail when CCACHE enabled
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jason Zaman
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 922374
  Show dependency tree
 
Reported: 2021-07-27 23:53 UTC by Susan Wilson
Modified: 2024-02-24 12:57 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Susan Wilson 2021-07-27 23:53:19 UTC
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.
Comment 1 Haonan Chen 2022-03-30 09:23:22 UTC
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.
Comment 2 Larry the Git Cow gentoo-dev 2024-02-24 12:57:21 UTC
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(-)