Speed-up Snap Building

Here are some tips and tricks to speed-up the snap building process. Feel free to share yours as well.

Compiler Cache(CCache)

FIXME: The remote part feature is no longer supported by Snapcraft and should be replaced by ccache build-snaps

You can set up compiler cache to cache the build intermediate object code so that future build can reuse it. To accomplish this you may incorporate the ccache remote part.

  ccache: # empty, if it doesn't work you have an outdated snapcraft distribution

    - ccache


  • This will slightly slow down clean build.

Disable Unused Build Options

You may disable the building of some software components to cut off some build time via custom configflags. The following of some possible options:

  • A subset of libraries in a library part that is not depended by your snapped application
  • Documentation that isn’t currently easily accessible from the end users:
    • Manpages
    • Infodoc
    • Manuals in HTML format
    • Developer-oriented documentations (like Doxygen, Javadoc, …etc)
  • Static or dynamic linking libraries of a library part that is not used by the depending part
  • Optional features of a part that are not depended by your snapped application or parts
  • Tests that is only beneficial to the upstream

Is it possible to use something like this for other languages? For example; Rust?

I have no idea…:wink:

From now on the ccache remote part will ship a latest development snapshot of ccache and use it in the subsequent parts building.