[cfe-dev] Borland-style PCHs in clang
dawn at burble.org
dawn at burble.org
Tue Sep 28 18:35:17 PDT 2010
I'm trying to figure out the best way to support Borland style PCHs in
clang. Suppose we have headers x.h and y.h and file x.c
as follows:
#include "x.h"
#include "y.h"
#pragma hdrstop // everything above this line goes into the PCH
In bcc, we would use the command:
bcc -H -H=x.pch -c x.c
which would have the effect:
first compile:
x.pch is created from x.h and y.h
subsequent compiles:
x.pch is verified (compile options and defines checked,
included files and order checked, etc.), then
parsing begins after #pragma hdrstop
The easiest way to do this using clang would be to
create and invoke the makefile:
xtmp.h: x.h y.h
#header file created from all lines of x.c up to #pragma hdrstop
xtmp.c: x.c
#source file created from all lines after #pragma hdrstop
xtmp.pch: xtmp.h
clang -cc1 xtmp.h -emit-pch -o xtmp.pch
x.o: xy.pch
clang -cc1 -include-pch xy.pch xtmp.c
But that has problems:
1. name of files in debug info are wrong.
2. if file y.c includes x.h but not y.h, y.c can't share the PCH info built into xy.pch.
To fix #2, we could use the makefile:
xtmp.c: x.c
#source file created from all lines after #pragma hdrstop
x.pch: x.h
clang -cc1 x.h -emit-pch -o x.pch
xy.pch: x.pch x.h
clang -cc1 -include-pch x.pch -chained-pch y.h -emit-pch -o xy.pch
x.o: xy.pch
clang -cc1 -include-pch xy.pch xtmp.c
But this doesn't allow for PCH verification of the first part of x.c (up to the
#pragma hdrstop - the part that had been built into xtmp.h).
... and both of these have the problem of requiring us to do some makefile magic on the fly.
What's the best way to add this support to clang?
Thanks,
-Dawn
More information about the cfe-dev
mailing list