[cfe-dev] PTH vs PCH usage

Douglas Gregor dgregor at apple.com
Sun Jan 1 10:37:07 PST 2012


On Dec 28, 2011, at 1:12 PM, Vladimir Voskresensky wrote:

> Hello,
> 
> What kind of caching (i.e. for Indexing) should be used if Clang is to 
> be used from IDE-like applications for completion/x-ref features?
> Does PCH is the right thing to use in such situations (at least I see it 
> mentioned in documentation for clang_createIndex)?

PCH provides the best build-time and indexing-time improvements. I strongly recommend using it if you can, although it often requires that the user intervene by creating a prefix header that you can precompile.

> What is the status of PTH? Is it live or deprecated?

It's live. Performance gains from PTH are fairly limited… IIRC they were in the 10-20% range, which is far below what we tend to see with PCH.

> Should it be used in interactive applications as cache mechanism as well?


This idea has come up, although I don't know if anyone has tried it. Presumably, one could use PTH on all of the header files and then PCH for the prefix header, since the mechanisms compose.

	- Doug



More information about the cfe-dev mailing list