4

im building android 10 on an ubuntu machine. the source is custom and not googles' specifically. the source is hard-coded for a prebuilt clang to use ccache. i have installed ccache and added to bashrc these variables:

_CCACHE_EXEC=/usr/bin/ccache

_CCACHE_EXEC -M 50G

export USE_CCACHE=1

chmod and chown the ~/.ccache has the same results during the build, the actual error is:

ccache: error: Failed to create directory /home/brandonabandon/.ccache/tmp: Read -only file system.

i cannot contact the owner of the source. i have attempted disabling ccache which leads to errors further on due to recent hard-coded ccache commits. i could build fine before. ive been stumped for a week. any ideas?

Brandon Shawhan
  • 43
  • 1
  • 1
  • 5

3 Answers3

11

It looks that you have your ccache on the same partition as your source code. soong sandboxing mechanism does not like it:( you have two options:

  1. start to use another partition/drive for ccache
  2. mount your current ccache to another partition (/mnt for example)

Here is a list of steps for the second option:

sudo mkdir /mnt/ccache
sudo mount --bind /home/<your_current_path>/ccache /mnt/ccache

and needed env:

export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
export CCACHE_DIR=/mnt/ccache
ccache -M 100G -F 0
Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Vadim Tihomirov
  • 126
  • 1
  • 2
  • the path was to ~/.ccache not (ccache). sourcing bash with the proper path along with your answer sorted it. thanks mate. – Brandon Shawhan May 27 '20 at 14:32
  • Thank you! That worked. My path was similar to that of Vladim. – lallolu Dec 29 '21 at 13:57
  • 1
    In addition: If you want to make it persistent across reboots add the following to your `/etc/fstab`: `/home//ccache /mnt/ccache none defaults,bind,users,noauto 0 0` and to automount on login add this into your `~/.profile`: `mount /mnt/ccache`. – dtrunk Jan 12 '22 at 13:22
0

Improving the accepted answer here as I hit this the second time: PS: I am running as root

mkdir /mnt/ccache
mount --bind ~/.ccache /mnt/ccache

and env variables are the same as above:

export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
export CCACHE_DIR=/mnt/ccache
ccache -M 100G -F 0

In addition, I suggest putting those in .profile file using following command:

echo -e "\nexport USE_CCACHE=1\nexport CCACHE_EXEC=/usr/bin/ccache\nexport CCACHE_DIR=/mnt/ccache\nccache -M 100G -F 0" >> ~/.profile
guness
  • 6,336
  • 7
  • 59
  • 88
0

Not what the OP was looking for, but: If someone ends up here looking for a similar ccache error msg issue with arch/manjaro using

sudo pamac build <thing>

Then instead do

pamac build <thing>

and then type in password when prompted.

vindarmagnus
  • 326
  • 3
  • 10