PTH for C++

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

PTH for C++

Reid Kleckner-2
Hey folks,

I wanted to ask about the existing PTH support in clang, and how well
it works for C++.

I couldn't find any user facing documentation, but my understanding is
that you use it by picking some representative C++ file that includes
most of the headers you want to pre-tokenize and invoke clang like so:
clang -cc1 -emit-pth most_headers.h -o most_headers.h.pth

Then you do the rest of your compiles with -token-cache most_headers.h.pth:
clang -cc1 -token-cache most_headers.h.pth foo.cc -o foo.o

Is this correct?  If so, how would I go about modifying a standard
Makefile setup to use PTH?  I don't see how this functionality is
exposed through the driver.

Have other people had success with PTH?  I remember ddunbar mentioned
in passing on IRC that PTH doesn't work well for C++, but I'm looking
for more detail.  If no one has numbers for how it performs, I was
going to self-host clang using PTH to make some.

Thanks,
Reid
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: PTH for C++

Nico Weber
Hi,

> I wanted to ask about the existing PTH support in clang, and how well
> it works for C++.

I believe PTH is dead and PCH is what's used these days. See
http://clang.llvm.org/docs/UsersManual.html#precompiledheaders .

PCH support for C++ isn't there yet, but Argyrios is working on it.

Nico
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: PTH for C++

Ted Kremenek
In reply to this post by Reid Kleckner-2
PTH should work fine for C++, since it only works on C++.

The usage of PTH/PCH follows the same mechanism for precompiled headers as gcc:

$ clang -x c++-header t.h -o t.h.pth

$ clang -include t.h t.cpp

Clang will automatically use 't.h.pth' if it is present instead of t.h.

On Jun 28, 2010, at 2:52 PM, Reid Kleckner wrote:

> Hey folks,
>
> I wanted to ask about the existing PTH support in clang, and how well
> it works for C++.
>
> I couldn't find any user facing documentation, but my understanding is
> that you use it by picking some representative C++ file that includes
> most of the headers you want to pre-tokenize and invoke clang like so:
> clang -cc1 -emit-pth most_headers.h -o most_headers.h.pth
>
> Then you do the rest of your compiles with -token-cache most_headers.h.pth:
> clang -cc1 -token-cache most_headers.h.pth foo.cc -o foo.o
>
> Is this correct?  If so, how would I go about modifying a standard
> Makefile setup to use PTH?  I don't see how this functionality is
> exposed through the driver.
>
> Have other people had success with PTH?  I remember ddunbar mentioned
> in passing on IRC that PTH doesn't work well for C++, but I'm looking
> for more detail.  If no one has numbers for how it performs, I was
> going to self-host clang using PTH to make some.
>
> Thanks,
> Reid
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: PTH for C++

Ted Kremenek
In reply to this post by Nico Weber
Quick clarification: PTH is not dead at all, and is currently being actively used by clang to support precompiled headers for C++/Objective-C++.

As Nico points out, Argyrios is working on PCH support for C++, but even when that is in place PTH isn't necessarily going away.  It is extremely useful for doing performance analysis work on the frontend, as it allows one to analyze the timings of parsing/semantic analysis by removing most of the time used for lexing.

On Jun 28, 2010, at 2:57 PM, Nico Weber wrote:

> Hi,
>
>> I wanted to ask about the existing PTH support in clang, and how well
>> it works for C++.
>
> I believe PTH is dead and PCH is what's used these days. See
> http://clang.llvm.org/docs/UsersManual.html#precompiledheaders .
>
> PCH support for C++ isn't there yet, but Argyrios is working on it.
>
> Nico
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev