clang builds chromium

Hi,

as of clang r116145, clang successfully builds all of chromium
(browser & test binaries) in both Debug and Release configurations.
The resulting browser binary even seems to work. Thank you for fixing
our bug reports so quickly! :slight_smile:

We have a continuous clang builder on both linux and mac, to make sure
our code stays clang-compatible, linked from
http://code.google.com/p/chromium/wiki/Clang . If you're interested in
which compiler flags we use, you can look at the compile step output:
http://build.chromium.org/buildbot/waterfall.fyi/builders/Chromium%20Mac%20Debug%20Clang/builds/795/steps/compile/logs/stdio
(the flags are slightly different for mac and linux).

Here are some random initial comparisons with gcc:

Build time

I built chrome.xcodeproj (i.e. just the browser) and all.xcodeproj
with both clang and gcc in both Debug and Release configurations and
measured the compile times, three times each. Results:

Building chrome with clang in Debug [1]
real 40m28.591s
real 39m51.426s
real 39m44.070s

Building chrome with gcc in Debug
real 44m55.732s
real 45m18.087s
real 45m3.671s

Building all with clang in Debug
real 70m8.669s
real 69m37.114s
real 70m26.698s

Building all with gcc in Debug
real 78m1.581s
real 78m6.648s
real 77m34.363s

Building chrome with clang in Release
real 43m58.864s
real 43m28.477s
real 43m29.998s

Building chrome with gcc in Release
real 57m6.050s
real 56m44.654s
real 58m8.629s

Building all with clang in Release
real 79m13.448s
real 79m0.107s
real 79m19.669s

Building all with gcc in Release
real 147m53.350s
real 146m35.010s
real 150m11.451s

clang is 10%-87% faster when building. [2]

Executable size

clang
Chromium: 12.6 kB
Chromium Framework: 45.2 MB
Chromium Framework.framework.dSYM DWARF file: 69.4 MB

gcc
Chromium: 12.6 kB
Chromium Framework: 52.1 MB
Chromium Framework.framework.dSYM DWARF file: 75.5 MB

Clang's output is almost 10% smaller.

Executable speed

I measured JavaScript performance. Since that's mostly dependent on
code generated by V8, it's not the greatest test, but it was easy to
do.

clang v8 (3 runs)
5655
5562
5637

clang sunspider
Total: 270.0ms +/- 0.9%

gcc v8 (3 runs)
5532
5542
5480

gcc sunspider
Total: 271.2ms +/- 9.1%

As expected, this looks mostly the same.

I also ran a slightly modified version of
http://trac.webkit.org/export/69591/trunk/WebCore/benchmarks/parser/html-parser.html
(changed to force a full garbage collection after every run, to reduce
variance), which checks a bit more than just JavaScript performance:

clang:
avg 5077.75
stdev 173.6965385377613

gcc
avg 5163.65
stdev 122.2183599137216

This looks good, too.

I didn't run most of the test binaries yet. (The one I ran passed all tests.)

Nico

1: Some files in the gpu project take very very long to build with
clang and require a ton of memory. There's possibly a clang bug in
there, and the build time here might go down a few minutes once that's
fixed. I'll try to find a reduced test case.
2: This was with a Release+Asserts build of clang r116145, the gcc
that comes with XCode on 10.6 ( i686-apple-darwin10-gcc-4.2.1 (GCC)
4.2.1 (Apple Inc. build 5664) ), and on a MacBook Pro with 4 GB ram
and 2.5 GHz i5 processor.

Hi,

as of clang r116145, clang successfully builds all of chromium
(browser & test binaries) in both Debug and Release configurations.
The resulting browser binary even seems to work. Thank you for fixing
our bug reports so quickly! :slight_smile:

We have a continuous clang builder on both linux and mac, to make sure
our code stays clang-compatible, linked from
http://code.google.com/p/chromium/wiki/Clang . If you're interested in
which compiler flags we use, you can look at the compile step output:
http://build.chromium.org/buildbot/waterfall.fyi/builders/Chromium%20Mac%20Debug%20Clang/builds/795/steps/compile/logs/stdio
(the flags are slightly different for mac and linux).

Here are some random initial comparisons with gcc:

Build time

I built chrome.xcodeproj (i.e. just the browser) and all.xcodeproj
with both clang and gcc in both Debug and Release configurations and
measured the compile times, three times each. Results:

Building chrome with clang in Debug [1]
real 40m28.591s
real 39m51.426s
real 39m44.070s

Building chrome with gcc in Debug
real 44m55.732s
real 45m18.087s
real 45m3.671s

Building all with clang in Debug
real 70m8.669s
real 69m37.114s
real 70m26.698s

Building all with gcc in Debug
real 78m1.581s
real 78m6.648s
real 77m34.363s

Building chrome with clang in Release
real 43m58.864s
real 43m28.477s
real 43m29.998s

Building chrome with gcc in Release
real 57m6.050s
real 56m44.654s
real 58m8.629s

Building all with clang in Release
real 79m13.448s
real 79m0.107s
real 79m19.669s

Building all with gcc in Release
real 147m53.350s
real 146m35.010s
real 150m11.451s

clang is 10%-87% faster when building. [2]

Executable size

clang
Chromium: 12.6 kB
Chromium Framework: 45.2 MB
Chromium Framework.framework.dSYM DWARF file: 69.4 MB

gcc
Chromium: 12.6 kB
Chromium Framework: 52.1 MB
Chromium Framework.framework.dSYM DWARF file: 75.5 MB

Clang's output is almost 10% smaller.

Executable speed

I measured JavaScript performance. Since that's mostly dependent on
code generated by V8, it's not the greatest test, but it was easy to
do.

clang v8 (3 runs)
5655
5562
5637

clang sunspider
Total: 270.0ms +/- 0.9%

gcc v8 (3 runs)
5532
5542
5480

gcc sunspider
Total: 271.2ms +/- 9.1%

As expected, this looks mostly the same.

I also ran a slightly modified version of
http://trac.webkit.org/export/69591/trunk/WebCore/benchmarks/parser/html-parser.html
(changed to force a full garbage collection after every run, to reduce
variance), which checks a bit more than just JavaScript performance:

clang:
avg 5077.75
stdev 173.6965385377613

gcc
avg 5163.65
stdev 122.2183599137216

This looks good, too.

I didn't run most of the test binaries yet. (The one I ran passed all tests.)

Nico

1: Some files in the gpu project take very very long to build with
clang and require a ton of memory. There's possibly a clang bug in
there, and the build time here might go down a few minutes once that's
fixed. I'll try to find a reduced test case.

Quick follow-up: This is just template instantiation being slow. It's
also a problem in gcc. There's nothing clang can do here.

Nico

BTW: Release+Asserts is going to do more internal checking IIRC than the
gcc on the system FWIW.

-eric

We know of some remaining inefficiencies in Clang's template instantiation, particularly w.r.t. source-location information in types, so there may be hope of Clang getting faster/smaller here.

  - Doug

I rebuilt clang with --disable-assertions and re-ran this test (but
only twice each):

Building chrome with clang-noasserts in Debug
real 32m59.061s
real 32m16.343s

Building all with clang-noasserts in Debug
real 57m36.865s
real 57m21.031s

Building chrome with clang-noasserts in Release
real 35m5.824s
real 34m56.622s

Building all with clang-noasserts in Release
real 63m56.959s
real 63m47.464s

That's with the same revision of clang and chromium, and on the same hardware.

clang Release is 25% faster than clang Release+Asserts and 130% faster than gcc.

(This improvement seemed too big to me, so I re-ran the test with gcc
another time as well to check if something on my system changed in the
meantime. But I got the same compile times with gcc that I got
originally.)

Nico