Vladimir Prus | 16 Nov 19:00

Re: gcc precompiled headers

On Sunday 16 November 2008 20:25:35 Jeroen van der Wulp wrote:
> Hello everyone,
> 
> I'm still looking at precompiled headers and I found another small 
> issue. At some point it all seemed to work but today I found that the 
> names of precompiled headers should be of the form x.hpp.gch for a 
> header file x.hpp. With the Boost trunk version of Boost Build I am 
> getting x.gch which I thought to be okay for some time.
> 
> The comment in gcc.jam suggests that it was once working this way:
> 
> # Calls the base version specifying source's name as the name of the created
> # target. As result, the PCH will be named whatever.hpp.gch, and not
> # whatever.gch.
> rule generated-targets ( sources + : property-set : project name ? )
> 
> I prepared a small patch that solved the problem for me. Although it 
> solves the problem it feels like a hack. Maybe someone more knowledgable 
> can have a quick look.

This is recent breakage from the 'make source files with same name 
in different directories work' patch. I've checked in a fix:

	https://svn.boost.org/trac/boost/changeset/49800

> Another problem I'm having is that I'm importing precompiled headers in 
> library sources files as well as source files for executables. The 
> differences between the two in my case are the setting of the -fPIC 
> flag. The precompiled header cannot be used by both.

(Continue reading)

J. van der Wulp | 17 Nov 11:40
Favicon

Re: gcc precompiled headers

> This is recent breakage from the 'make source files with same name 
> in different directories work' patch. I've checked in a fix:
> 
> 	https://svn.boost.org/trac/boost/changeset/49800
> 

Thanks a lot. It was this very patch for which I imported the changes
from trunk. It allowed me to tidy some Jamfiles. During testing after
the changes I noticed that precompiled headers were no longer working.

> Are either libraries or executables static? Because when link=static, which
> is the default, -fPIC is added everywhere.
> 

I always try to test with either link=static or link=shared on the
command line. We have lots of tools and only a few libraries so shared
linking is usually preferred.

>> Can I also solve this problem by setting -fpic for all compilations in 
>> the project? For what platforms/gcc versions can this work and does this 
>> have any unwanted side-effects? 
> 
> -fPIC will work everywhere. It has some performance penalty, though I'm not
> sure anybody considers it significant nowdays.

Sounds as an acceptable offer using precompiled headers to speed up
compilation is more of a developer feature anyway.

Thanks again,

(Continue reading)


Gmane