[cfe-dev] Clang build of PostgreSQL

Peter Geoghegan peter at 2ndquadrant.com
Thu Jun 23 14:07:43 PDT 2011


On 23 June 2011 21:47, Sean McBride <sean at rogue-research.com> wrote:

> Those numbers are for gcc 4.2, and probably Apple's fork thereof.  One would assume the gcc folks have made improvements in 4.6, which you used.

I do appreciate that, and that a different optimisation level has been
used, but I found the gap in compile times surprising, to the extent
that I suspect that something is wrong.

Regardless of its performance, I do really like Clang from a usability
perspective, FWIW.

Observe the differences in compile times of the file
/src/backend/parser/gram.c . The warning message that you see is a
known bug with Gnu Bison that they refuse to fix:

[peter at peter postgresql]$ time /home/peter/build/Release/bin/clang -O2
-Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wformat-security
-fno-strict-aliasing -fwrapv -Wno-error -I. -I. -I
/home/peter/postgresql/src/include -D_GNU_SOURCE   -c -o gram.o
/home/peter/postgresql/src/backend/parser/gram.c
In file included from gram.y:12939:
scan.c:16246:23: warning: unused variable 'yyg' [-Wunused-variable]
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be ...
                      ^
1 warning generated.

real	1m5.660s
user	1m5.344s
sys	0m0.083s
[peter at peter postgresql]$ time gcc -O2 -Wall -Wmissing-prototypes
-Wpointer-arith -Wdeclaration-after-statement -Wendif-labels
-Wformat-security -fno-strict-aliasing -fwrapv -Wno-error -I. -I. -I
/home/peter/postgresql/src/include -D_GNU_SOURCE   -c -o gram.o
/home/peter/postgresql/src/backend/parser/gram.c
In file included from gram.y:12939:0:
scan.c: In function ‘yy_try_NUL_trans’:
scan.c:16246:23: warning: unused variable ‘yyg’ [-Wunused-variable]

real	0m2.800s
user	0m2.688s
sys	0m0.094s

That's obviously a difference way out of proportion to the total
difference in compile times.

-- 
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services




More information about the cfe-dev mailing list