This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54780] New: G++ does not find precompiled headers in some cases
- From: "jpakkane at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 02 Oct 2012 13:23:25 +0000
- Subject: [Bug c++/54780] New: G++ does not find precompiled headers in some cases
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54780
Bug #: 54780
Summary: G++ does not find precompiled headers in some cases
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jpakkane@gmail.com
Created attachment 28326
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28326
Some dummy sources demonstrating the issue
Using GCC of Ubuntu Quantal, version gcc version 4.7.2 (Ubuntu/Linaro
4.7.2-2ubuntu1).
Under some circumstances g++ does not find precompiled headers that are in the
search path.
I have attached a simple test case that demonstrates the issue. Just run
compile.sh that comes with it and watch the output.
In the test case there is a common.h header that includes a bunch of STL
headers. It is in a subdirectory called hdir. The file is first precompiled and
placed in the subdirectory pchdir.
The script then compiles a bunch of files that include common.h but do very
little else. Both pchdir and hdir are passed in with -I. The precompiled header
is found and compilation is fast.
Next the script copies common.h to the main directory and compiles the sources
again using the exact same compiler switches. What happens is that g++ does not
find the precompiled header, probably because it first looks in the source dir
and finds common.h but not the corresponding pch and just stops looking. This
makes the compilation very slow.
Then the script copies the precompiled header to the main directory and
compiles the files again. Now g++ finds the pch and compilation is again fast.
Summing all this up: precompiled headers can not be used if the header is in
the source directory and the pch is in some other directory which is included
with -I. This is a problem when doing out-of-source builds.