Make snapcraft work with ccache

Bug #1626766 reported by Olivier Paroz
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

Despite having a properly configured ccache using $PATH, parts don't seem to be using it when compiling code.
It should be automatically picked up and used.

A simple test is to build a snap using a simple C++ example. Compiling by hand uses ccache, compiling uses snapcraft doesn't.

```
$ whereis g++
g++: /usr/bin/g++ /usr/lib/ccache/g++ /usr/share/man/man1/g++.1.gz
$ which g++
/usr/lib/ccache/g++

```

Olivier Paroz (oparoz)
description: updated
Revision history for this message
林博仁(Buo-ren Lin) (brlin) wrote :

As a workaround you may use the ccache remote part:
https://forum.snapcraft.io/t/speed-up-snap-building/7979

Revision history for this message
Mike Miller (mtmiller) wrote :

I have run into this, installing ccache in the host and building a snap with --destructive. I think this is because snapcraft prepends directories to PATH, so 'gcc' is found under /snap/.../usr/bin, not under /usr/lib/ccache.

A workaround that works for me is setting the environment variables CC="ccache gcc" and CXX="ccache g++" in the build environment.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.