Cooking LLVM in FreeBSD 8

Geoff Fritz gfritz at
Tue Mar 17 09:15:50 PDT 2009

On Tue, Mar 17, 2009 at 03:27:37PM +0100, Wojciech Puchar wrote:
> >
> > It does look promising, though.  I hope it'll eventually surpass gcc in
> actually - it's matter of measurement. for example - gcc generated code is 
> very fast, but often in expense of code size. Even -Os compiled programs 
> are quite large.
> Large code=less efficient caching=SLOWER overall performance with mixed 
> load and lots of task switching which is normal under unix.
> Even if this new compiler generates slightly slower but SMALLER code, it 
> could produce overall-faster system

I'm a big supporter of small, efficient binaries.  In fact, I'll often put
"-Os" in my /etc/make.conf CFLAGS setting.  This only rarely improves raw
speed over more agressive optimization flags, however.  I use it primarily
for programs that are huge to begin with (Firefox, for example) or programs
that have many instances running (my shell, my terminal program, etc.) for
the sake of conserving memory.

I tested clang (ccc), the stock 7.1 gcc (4.2.1), and gcc 4.3.4, using -Os
and -O0, -O2, and -O3.  For raw speed, gcc43 with -O3 took the lead.  In
every case, even the stock gcc beat ccc.  To be honest, I didn't pay too
much attention to the binary size, though I'm pretty sure both gcc variants
beat ccc in that benchmark.

Like I said before, I wasn't overly scientific in my methodology.  I
compiled the "zip" port for my tests (very fast compile).  I ran the same
task in a loop 5 times, and took the mean of the timings from "time".  I
did pre-load the file into filesystem cache by reading it with "dd" before
the calls to zip (which wrote to /dev/null).

In every case, ccc was last in performance when compared with the same
CFLAGS.  However, I didn't have time to see if, for example, "-O3" for ccc
resulted in a faster binary than "-O0" for gcc.

I wish lang/tcc would run under amd64.  Talk about small binaries!

Somebody with a compulsion for benchmarking could put this to the test.
After seeing Roland's benchmarking zeal in the "best archiver" thread,
maybe he should join the fun.  ;-)

-- Geoff

More information about the freebsd-questions mailing list