[cfe-dev] PCH: separation from source header

Ilya Murav'jov muravev at yandex.ru
Thu Sep 23 05:02:04 PDT 2010


Argyrios Kyrtzidis пишет:
> 
> Automatically using PCH seems like an architectural change with little benefit.
> Most of your woes can be attributed to the fact that clang does not fallback to the source header when it can't use the PCH.
> I think we should change the cannot-use-PCH errors to warnings and fallback to the source header, and maybe add a command-line option to enable the current behavior (hard errors when PCH can't be used).
> Anyone have an objection about this ?
> 
>> - in some C++ sources I still need to set #defines at first lines (e.g.
>> BOOST_AUTO_TEST_MAIN for Boost.Test library); now it is impossible.
> 
> If clang fallbacks to the source header, you can define them at command-line (-D).
> 

The main benefit is that one can setup settings (#define's, #include's)
per source file, not per project (= at command-line).

>>
>> 2. I have got some benchmarks (compiler' speed in debug mode) gcc vs
>> clang for my sources (http://gitorious.org/bombono-dvd). I use Boost *a
>> little*, and it makes a compiler be somewhat slow. Here are compilation
>> times (-g -O0) for src/mgui/editor/select.cpp (39kb, not so big!):
>>
>> a) without PCH:
>> clang++ 2.9: 5.35 seconds
>> g++     4.2: 5.05 seconds
>>
>> b) with PCH:
>> clang++ 2.9: 3.47 seconds
>> g++     4.2: 2.88 seconds
> 
> Interesting, is this gcc 4.4 ? Can you file a bug and include the preprocessed header (move headers of select.cpp to the preprocessed header before including it as well).
> 

No, it is gcc 4.4; I found it the quickest among 4.0-4.5 versions. gcc
4.4 is 30% slower, gcc 4.5.1 is 15% slower on my code.
I try to file a bug if I have time.

Regards,
 Ilya




More information about the cfe-dev mailing list