Brandon Shawhan
Brandon Shawhan

Reputation: 53

ccache fails with read only

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?

Upvotes: 5

Views: 16173

Answers (5)

  1. create a new mount point using

    sudo mkdir /mnt/ccache
    
  2. then bind ccache directory to that mount point using

    sudo mount --bind /home/<your_account_username>/.cache/ccache /mnt/ccache
    

    replace <your_account_username> with the appropriate value. After this, add the following

  3. nano ~/.bashrc file and adds:

    export USE_CCACHE=1
    export CCACHE_EXEC=/usr/bin/ccache
    export CCACHE_DIR=/mnt/ccache
    

    save and exit

  4. Terminal: ccache -M 50G

  5. add auto mount

    sudo nano /etc/fstab
    /home/<your_account_username>/.cache/ccache /mnt/ccache none defaults,bind,users,noauto 0 0
    

    save and exit

nano ~/.profile
mount /mnt/ccache

save and exit

You should not see these errors ever again.

Upvotes: 0

mkdir $HOME/.ccachetmp
export CCACHE_DIR=$HOME/.ccachetmp

You can additionally add

export CCACHE_DIR=$HOME/.ccachetmp

In ~/.bashrc

Upvotes: 0

vindarmagnus
vindarmagnus

Reputation: 318

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.

Upvotes: 0

guness
guness

Reputation: 6636

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

Upvotes: 0

Vadim Tihomirov
Vadim Tihomirov

Reputation: 166

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

Upvotes: 15

Related Questions