it isnt linear.
the larger the program, the more resources it takes, because the compiler will attempt to optimize across wide boundaries and that takes a great deal of resources for a big code base.
that said,
compiling a small program with g++ is not very demanding.
it can be done on little more than a simple wristwatch. It may take hours there, instead of nanoseconds on a real computer, but it can DO it. There are bored people out there who spend their free time putting unix onto oddball devices. You can google this. Any of these devices that are running the OS can compile a small program with g++.