Slow gcc compiler on FreeBSD

I noticed that my gcc compiler does not work as fast as it should.
To compile a simple hello world program should only take a few seconds, but it seems to 'hang' for a while and it can be as much as 10 seconds.
What can be causing this very slow compile time?
 
Compiling the following takes less than a second on my low profile machine (Atom Dual Core 1.6 GHz) FreeBSD 8.3-RELEASE:

Code:
#include <stdio.h>

int main(int argc, char *const argv[])
{
   printf("Hello, World!\n");
   return 0;
}

#gcc hello.c -o hello

Without knowing anything else, I suspect that your hard disk got a problem.
 
You can not measure compiler performance with trivial programs that take only a few seconds to compile. There are way too many variables involved, caching being the most important. Compile something like editors/vim on two different systems to get a more realistic benchmark. Repeat the compilation few times and use the average time.
 
kpa said:
... to get a more realistic benchmark ...

Perhaps I misunderstood the OP, however, IMHO this thread is not about benchmarking GCC, but whether it may take 10 s for compiling a "Hello, World!". My answer was no. In the past I used GCC over years in many versions on much slower machines than the ones used nowadays, and it never took 10 s for a simple "Hello, World".

So again, there is something horribly wrong with his machine, perhaps a defect HD.

To give this answer it is not necessary to measure whether compiling "Hello, World!" takes 0.8932 or 0.7487 seconds on a given machine.
 
The only time I have seen a compiler take that long to build a simple program was in a virtual machine. If I had to guess I'd assume the poster is running in a VM that is choked for resources. Or trying to run GCC on a machine that is already using 100% CPU for something else.
 
See also http://forums.freebsd.org/showthread.php?t=35423. Something is not right on that computer. It may not be anything to do with the compiler. The first thing to check is /etc/make.conf for the usual "optimizations". Also worth looking at BIOS settings to see if the CPU has been throttled or caches disabled. Could also be a failing hard drive, so using sysutils/smartmontools to check the drive is worthwhile:
# smartctl -a ada0 | less -S
 
Back
Top