For compiling small programs it is absolutly sufficient to install gcc [~9MB] and g++ (if needed) [~14MB] only. No build-essential and all that stuff. If you have no other unoptified stuff installed you should have no problems installing those packages. I did that, I have enough space left and for small on device compiling I have all I need.