In case anyone stumbled upon this issue or something related to this.
Since I do not have a linux machine, I decided to spin up a cheap 1cpu, 512MB ram, $5 digital ocean droplet to setup my toolchain and compile some code for the onion. The above issue occurred on a fresh ubuntu 16 and ubuntu 17 droplet. A friend did some googling and pointed out that these type of issues could be memory related and he was spot on.
After setting up 2GB swap space using this guide: Adding Space on Ubuntu the compile has completed successfully on both Ubuntu 16 and 17.
Hope this helps someone experiencing this frustration.