Running out of memory building code inside of multipass enironments

Hi there,

I’m building a support library for bpftrace in a snap inside a multipass build environment and g++ is breaking because I’m running out of memory. This builds fine outside of the multipass environment because tens of GB of memory and swap. I did think of adding a workaround to make a temporary swap file for the build inside the multipass environment, but I suspect there must be an easier solution.

The out of memory failure is as follows:

/usr/lib/llvm-6.0/include/clang/AST/DeclOpenMP.h:97:1: warning: multi-line comment [-Wcomment]
 /// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
 ^
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.

Any ideas?

You can bump up the VM’s memory to 4GB with:

snapcraft clean
SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=4G snapcraft

You can optionally also try using LXD:
snapcraft --use-lxd

1 Like

Is this documented anywhere?