Cannot anymore build PCL lib with snapcraft 3.8 [Fixed]

Hello there,

Since we did recently update on snapcraft 3.8, one of our snap part, the PCL library does not compile.

The C++ compiler fails with :

C++: internal compiler error: Killed (program cc1plus)

We thought about a performance (RAM) problem, so we ugraded machine, the env var for RAM, disabling parallel compiling, and try lxd without success. (but maybe we did it wrong)

The actual behavior is part of the library gets compiled, then it kind of becomes very slow, then compiler fails. Restarting the process will build a bit more objects of the library then fail again.

Our configuration is ubuntu 16.04 / snap 2.42 / snapcraft 3.8 / multipass 0.8.1

Any ideas ? snapcraft --debug did not give any output except "Failed to run ‘cmake --build . – -j2’ : exited with code 2.
Verify that the part is using the correct aprameters and try again

Hello some more information here after some more tests :

It was indeed an “amount of RAM allocated to the VM problem”.

So the first conclusion is : PCL library cannot be built with the current default RAM settings (i.e. 2G) allocated to the VM


For future users reading this post and being on Ubuntu, here are the steps to build your snapcraft.yaml with more RAM :

(we were using “sudo snapcraft” command, but you shouldn’t ! If you are doing this here are the steps)

export SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY=8G
sudo -E snapcraft

Explanation : Ubuntu by default not having a real root account but a sudo user system, providing an env variable is a bit more tricky, using the -E option will take care of this.
If it works snapcraft should display a message saying that the user changed the amount of RAM allocated to the VM.

WARNING :

Here is a solution and workaround for doing sudo snapcraft, but you should not use snapcraft with sudo in the first place.

Keep calm & snapcraft