what RPI are you using? compiling on my tinker board went pretty straight, but it has 2GB RAM
you might be running into same issue as that guy
https://bitcointalk.org/index.php?topic=304389.0try monitoring your ram while compiling on a second ssh session