[cfe-dev] Clang build of PostgreSQL

Eli Friedman eli.friedman at gmail.com
Thu Jun 23 13:32:38 PDT 2011


On Thu, Jun 23, 2011 at 1:21 PM, Peter Geoghegan <peter at 2ndquadrant.com> wrote:
> 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.

It's worth noting that the graph from the presentation you're pointing
to is at -O0.

> 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.

We generally find that the LLVM optimizers are faster than the gcc
ones... but if there's a specific file that's taking longer than you
expect to compile, please file a bug at http://llvm.org/bugs/ with
preprocessed source.

-Eli




More information about the cfe-dev mailing list