[cfe-dev] Clang build of PostgreSQL

Peter Geoghegan peter at 2ndquadrant.com
Thu Jun 23 13:21:42 PDT 2011


Hi,

I apologise in advance if it is inappropriate to post a query like
this to a dev list, but I found no reasonable alternative.

I work on the PostgreSQL project, and was present at Chris Lattner's
talk on Clang/LLVM at FOSDEM earlier in the year. At that talk,
Postgres was specifically cited as an example of a medium sized C
program that had seen large improvements in compile times when built
with Clang. Here are his slides:

http://www.scribd.com/doc/48921683/LLVM-Clang-Advancing-Compiler-Technology

I would really like to be able to reproduce some of Chris's work here,
to demonstrate to the PostgreSQL community.

Here is an example of arguments given to Clang (and gcc) by PG's build system:

/home/peter/build/Release/bin/clang -O2 -Wall -Wmissing-prototypes
-Wpointer-arith -Wdeclaration-after-statement -Wendif-labels
-Wformat-security -fno-strict-aliasing -fwrapv -I../../../src/include
-D_GNU_SOURCE   -c -o pg_db_role_setting.o pg_db_role_setting.c

At present, when I build Postgres using gcc (specifically, Fedora's
build of gcc 4.6), I see a build time of 2 minutes 1 second. For
Clang, built today from SVN tip, I see a build time of 3m23s. Clang
has been built with --enable-optimized and --disable-assertions in an
attempt to be objective.

A small number of TUs, particularly gram.c, seem to be real
bottlenecks for Clang.

Any advice on improving build times with Clang would be appreciated.

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




More information about the cfe-dev mailing list