Hi Magnus,

I see nothing wrong with your plans ... but I haven't tried what you are suggesting so have no experiential
knowledge to share. The only other thing I suggest with the pi build is to monitor your ram and cache
mem usage while the compile and linking is going on. I didn't clue in on the cause of my builds failing until I actually observed
the pi running out of resources. I didn't get the error you are seeing, so even increasing swap mem may not
be the solution. If you haven't tried conky for desktop monitoring your system, you can use the file attached and
setup instructions here ( tinyurl.com/mf33uvn ) and elsewhere.
I found this solution and variants thereof on a few threads you may also try :
sudo apt purge binutils
sudo apt remove make
sudo apt autoremove
sudo apt install build-essential

Read More...