[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]MacOSX works!

From: James Michael DuPont
Subject: Re: [DotGNU]MacOSX works!
Date: Wed, 22 May 2002 00:00:27 -0700 (PDT)

I did some searching for you.
Hope it helps.

Pre-compiled headers for C++

The pre-compiled header mechanism has been extended so
that it can be used when compiling C++ code. Using the
-cpp-precomp switch allows C++ compilations to benefit
from pre-compiled headers for frameworks such as
Carbon. Note, however, that pre-compiled headers may
not contain C++ declarations.
Invoking the GNU preprocessor
By default, the precompilation preprocessor (also
known as cpp-precomp) is used to preprocess C and
Objective-C source code. However, in some cases, this
may not be desirable. (An example would be having
Pascal source code in a file whose name is the same as
some C header file, except for a .p extension - the
precompilation preprocessor would mistake such a file
as being a precompiled header file.) While the
-traditional-cpp switch can be used to indicate that
the GNU preprocessor should be used instead, at some
point in the future, this switch will revert back to
its original intent, which was to indicate that the
preprocessor should behave like traditional
preprocessors, rather than as the ISO C Standard
requires. In order to avoid problems in the future,
the -no-cpp-precomp switch should be used instead of
the -traditional-cpp switch.

# What are "precomps"?
I had problems building some Darwin kernel modules,
and it was always complaining about
TrustedPrecomps.txt and would always die. Fortunatly,
Stan Shebs of Apple helped me out, and here was his

"Precomps" are the version of precompiled headers
implemented originally by NeXT. They're built and
processed using a special preprocessor cpp-precomp
that is like a normal C/ObjC preprocessor, except that
it can read (and write) precompiled headers, which are
binary files with predigested tokens and dependency

The theory of its operation is that it a) processes
the precomp faster than the equivalent set of text
files, and b) it knows what variables, decls, etc are
actually used in the sources, and omits the decls of
anything not actually used. So cpp-precomp can take in
100,000 lines of header plus 500 lines of source file,
but put out maybe 2,000 lines of headers plus the 500
lines of source, which makes the main pass of the
compiler go by more quickly.

In practice, compilation of Cocoa programs tends to
speed up by a factor of four when using precomps,
which is why we like them. On the downside, the
dependency analysis requires full parsing and some
semantic analysis, and that's why it's only been done
for C and Objective-C; no C++.

Unfortunately, cpp-precomp is not included in Darwin.
Fortunately, the compiler has been tweaked to not
require it, although if you look closely at cc -v,
you'll see a -smart option being passed to cpp, which
is a cpp-precomp option that cpp has been modified to

Another cpp-precomp option is -precomp-trustfile,
which specifies a file containing names of precomps
that have already been validated (to make sure that
real .h files aren't newer than the precompiled
versions), thus making compiles going a little faster.
As with -smart, regular cpp has no use for this

# That's great, but how do I fix my precomps errors
under Darwin?
Darwin doesn't support precomps, but some of the
Makefiles distributed with 1.0.2 and earlier define
precomps to be used. You can fix this by a couple of

    * You can make a Makefile.postamble with the
following line:


      This will cause no precomp flags to be passed to
the compiler. This method was suggested by Ryan
* You can edit the original Makefile that is shipped
with the system, and fix it globally. You'll have to
and comment out any line containing "-precomp". 

James Michael DuPont

Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience

reply via email to

[Prev in Thread] Current Thread [Next in Thread]