automake
[Top][All Lists]
Advanced

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

Re: Status of precompiled headers support?


From: Lance Westerhoff
Subject: Re: Status of precompiled headers support?
Date: Mon, 29 Mar 2010 14:52:58 -0400

Hi Ralf-

That's the approach I ended up taking (hacking something of my own). A couple 
of items did come up though:

(1) We support multiple compilers (icc and gcc), so having a mechanism that 
reacts differently depending upon the compiler would be great. There is no 
"standard" pch approach that we can tell, and this would be a good opportunity 
for automake to come to the rescue.

(2) An extra added issue is since we are also using libtool, I had to hack in 
some of the extra arguments that I wasn't able to pick up from Automake 
(specifically -fPIC). That too is something that automake et al should take 
care of.

(3) As you said, gcc's pch support is lacking. I did notice the support for a 
single pch per cpp file, however it does not seem to require that the pch file 
is first. In fact, there are times when it will pick it up later in the 
compile. A key rule of thumb though is to think about your header file 
ordering. This is just good practice though. In this case, we make sure our 
largest and most inclusive pch files are loaded in first. For example, we use a 
lot of boost and we have a couple hierarchal class structures that are used 
repeatedly. We make sure as much of the hierarchy is loaded in using our pch 
file and that this hierarchy includes most of the boost headers we require.

(4) There is a bug in gcc where gcc will error out if the gch file is loaded 
and it attempts to load the same header file somewhere else in the compile 
(such as when g++ loads a *.h file that also loads the same header that 
corresponds to the gch file). This is a known gcc bug. The work around is to 
use a #ifndef prior to the #include. It is dirty, but it works just fine.

(5) Most importantly: for some reason I can not get the gch to make the first 
time around. I must have the dependency makefile code screwed up or something. 
The first time the project builds through, it does not build the gch file. 
Weird. Unfortunately, I don't know enough about make's quirks to get it to pick 
it up.

-Lance

On Mar 28, 2010, at 11:29 AM, Ralf Wildenhues wrote:

> Hello Lance,
> 
> * Lance Westerhoff wrote on Wed, Mar 24, 2010 at 05:39:13PM CET:
>> 
>> I searched the automake list archives (along with anywhere else I
>> could find), and it appears that nothing has really happened with
>> standardizing precompiled headers support in the tool chain as there
>> hasn't been any mention for years. I have found some vague references
>> to supporting them or suggested hacks, but nothing concrete. Is this
>> impression correct? If so, does anyone have any rules of thumb or
>> modern examples for hacking together one's own support?
> 
> Sadly, nothing has happened about the precompiled header support.
> 
> However, I don't see a good reason to invest a lot of work: GCC's PCH
> support is weak at best (you can include only one precompiled header,
> it must be the first included header, reusing it in presence of changed
> compile flags is often not possible), and semantics are very
> compiler-dependent.
> 
> That said, even without explicit Automake support you should be able to
> make use of precompiled headers by using self-written rules, no?
> 
> Cheers,
> Ralf





reply via email to

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