diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-20 04:37:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-20 04:37:38 +0000 |
commit | 5c3074f3cd4c33e30c55e851a3ecf21ebec0769e (patch) | |
tree | d0b5ca4e1acb7c34e4331e34d4574e1bee79cefe /docs/UsersManual.html | |
parent | cf17d9d9c0c0c931478807cc020c8ab1c2cc296a (diff) |
slurp some content from the PTH doc into the user's doc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69569 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/UsersManual.html')
-rw-r--r-- | docs/UsersManual.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/docs/UsersManual.html b/docs/UsersManual.html index 8f8951f87e..cfed51a202 100644 --- a/docs/UsersManual.html +++ b/docs/UsersManual.html @@ -180,6 +180,66 @@ other high level options like -c, -g, etc. <h3 id="precompiledheaders">Precompiled Headers</h3> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> +<p><a href="http://en.wikipedia.org/wiki/Precompiled_header">Precompiled +headers</a> are a general approach employed by many compilers to reduce +compilation time. The underlying motivation of the approach is that it is +common for the same (and often large) header files to be included by +multiple source files. Consequently, compile times can often be greatly improved +by caching some of the (redundant) work done by a compiler to process headers. +Precompiled header files, which represent one of many ways to implement +this optimization, are literally files that represent an on-disk cache that +contains the vital information necessary to reduce some of the work +needed to process a corresponding header file. While details of precompiled +headers vary between compilers, precompiled headers have been shown to be a +highly effective at speeding up program compilation on systems with very large +system headers (e.g., Mac OS/X).</p> + +<p>Clang supports an implementation of precompiled headers known as +<em>pre-tokenized headers</em> (PTH). Clang's pre-tokenized headers support most +of same interfaces as GCC's pre-compiled headers (as well as others) but are +completely different in their implementation. If you are interested in how +PTH is implemented, please see the <a href="PTHInternals.html">PTH Internals + document</a>.</p> + +<h4>Generating a PTH File</h4> + +<p>To generate a PTH file using Clang, one invokes Clang with +the <b><tt>-x <i><language></i>-header</tt></b> option. This mirrors the +interface in GCC for generating PCH files:</p> + +<pre> + $ gcc -x c-header test.h -o test.h.gch + $ clang -x c-header test.h -o test.h.pth +</pre> + +<h4>Using a PTH File</h4> + +<p>A PTH file can then be used as a prefix header when a +<b><tt>-include</tt></b> option is passed to <tt>clang</tt>:</p> + +<pre> + $ clang -include test.h test.c -o test +</pre> + +<p>The <tt>clang</tt> driver will first check if a PTH file for <tt>test.h</tt> +is available; if so, the contents of <tt>test.h</tt> (and the files it includes) +will be processed from the PTH file. Otherwise, Clang falls back to +directly processing the content of <tt>test.h</tt>. This mirrors the behavior of +GCC.</p> + +<p><b>NOTE:</b> Clang does <em>not</em> automatically used PTH files +for headers that are directly included within a source file. For example:</p> + +<pre> + $ clang -x c-header test.h -o test.h.pth + $ cat test.c + #include "test.h" + $ clang test.c -o test +</pre> + +<p>In this example, <tt>clang</tt> will not automatically use the PTH file for +<tt>test.h</tt> since <tt>test.h</tt> was included directly in the source file +and not specified on the command line using <tt>-include</tt>.</p> <!-- ======================================================================= --> |