[Bug pch/57242] precompiled headers ignored unless the .gch and TU's are compiled with certain combinations of -g flag

2013-11-10 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57242

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |INVALID

--- Comment #7 from Andrew Pinski pinskia at gcc dot gnu.org ---
Not a bug, ccache getting in the way.


[Bug pch/57242] precompiled headers ignored unless the .gch and TU's are compiled with certain combinations of -g flag

2013-05-13 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57242

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2013-05-13
 Ever confirmed|0   |1

--- Comment #5 from Richard Biener rguenth at gcc dot gnu.org ---
(In reply to etherice from comment #4)
 (In reply to Andrew Pinski from comment #1)
  This is by design as -g changes the information produced by the front-end
  and maybe even predefines too.
 
 I created a simpler test to demonstrate the bug. Two files:
 
 --
 pch.hpp
 --
 #ifndef __PCH_HPP__
 #define __PCH_HPP__
   #pragma message [ not using pre-compiled headers ]
   #include iostream
 #endif
 
 --
 test.cpp
 --
 #include pch.hpp
 int main() {
   std::cout  hello world  std::endl;
   return 0;
 }
 
 --
 
 If you run commands [1] and [2] below, you will notice that pch is ignored.
 
 [1]  g++ -I. pch.hpp  -o pch.hpp.gch
 [2]  g++ -I. -c test.cpp  -o test.o
 [3]  g++ -I. -c test.cpp  -o test.o -include pch.hpp

How?  I see

rguenther@murzim:/tmp g++-4.7 -I. pch.hpp  -o pch.hpp.gch
pch.hpp:3:19: note: #pragma message: [ not using pre-compiled headers ]
rguenther@murzim:/tmp g++-4.7 -I. -c test.cpp  -o test.o  
rguenther@murzim:/tmp g++-4.7 -I. -c test.cpp  -o test.o -include pch.hpp

rguenther@murzim:/tmp g++-4.8 -I. pch.hpp  -o pch.hpp.gch
pch.hpp:3:19: note: #pragma message: [ not using pre-compiled headers ]
   #pragma message [ not using pre-compiled headers ]
   ^
rguenther@murzim:/tmp g++-4.8 -I. -c test.cpp  -o test.o 
rguenther@murzim:/tmp g++-4.8 -I. -c test.cpp  -o test.o -include pch.hpp

the issue is probably that there are pre-installed precompiled headers
for libstdc++ which use certain flags.  Maybe in your case this confuses
things?  (disclaimer: I always install gcc built with --disable-libstdcxx-pch)
Try removing them.

[Bug pch/57242] precompiled headers ignored unless the .gch and TU's are compiled with certain combinations of -g flag

2013-05-13 Thread scottbaldwin at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57242

--- Comment #6 from etherice scottbaldwin at gmail dot com ---
(In reply to Richard Biener from comment #5)
 (In reply to etherice from comment #4)
  (In reply to Andrew Pinski from comment #1)
   This is by design as -g changes the information produced by the front-end
   and maybe even predefines too.
  
  I created a simpler test to demonstrate the bug. Two files:
  
  --
  pch.hpp
  --
  #ifndef __PCH_HPP__
  #define __PCH_HPP__
#pragma message [ not using pre-compiled headers ]
#include iostream
  #endif
  
  --
  test.cpp
  --
  #include pch.hpp
  int main() {
  std::cout  hello world  std::endl;
  return 0;
  }
  
  --
  
  If you run commands [1] and [2] below, you will notice that pch is ignored.
  
  [1]  g++ -I. pch.hpp  -o pch.hpp.gch
  [2]  g++ -I. -c test.cpp  -o test.o
  [3]  g++ -I. -c test.cpp  -o test.o -include pch.hpp
 
 How?  I see
 
 rguenther@murzim:/tmp g++-4.7 -I. pch.hpp  -o pch.hpp.gch
 pch.hpp:3:19: note: #pragma message: [ not using pre-compiled headers ]
 rguenther@murzim:/tmp g++-4.7 -I. -c test.cpp  -o test.o  
 rguenther@murzim:/tmp g++-4.7 -I. -c test.cpp  -o test.o -include pch.hpp
 
 rguenther@murzim:/tmp g++-4.8 -I. pch.hpp  -o pch.hpp.gch
 pch.hpp:3:19: note: #pragma message: [ not using pre-compiled headers ]
#pragma message [ not using pre-compiled headers ]
^
 rguenther@murzim:/tmp g++-4.8 -I. -c test.cpp  -o test.o 
 rguenther@murzim:/tmp g++-4.8 -I. -c test.cpp  -o test.o -include pch.hpp
 
 the issue is probably that there are pre-installed precompiled headers
 for libstdc++ which use certain flags.  Maybe in your case this confuses
 things?  (disclaimer: I always install gcc built with
 --disable-libstdcxx-pch)
 Try removing them.

I did a clean rebuild of 4.8 with --disable-libstdcxx-pch and results were the
same, pch ignored, but... after triple-checking some things I realized ccache
was still being used.

Once ccache was disabled, the issue went away and gcc-pch worked as expected.
So this appears to be a bug with ccache, not gcc.

Fortunately, the workaround is simple (using '-g3' or the '-include' option).

[Bug pch/57242] precompiled headers ignored unless the .gch and TU's are compiled with certain combinations of -g flag

2013-05-10 Thread scottbaldwin at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57242

--- Comment #4 from etherice scottbaldwin at gmail dot com ---
(In reply to Andrew Pinski from comment #1)
 This is by design as -g changes the information produced by the front-end
 and maybe even predefines too.

I created a simpler test to demonstrate the bug. Two files:

--
pch.hpp
--
#ifndef __PCH_HPP__
#define __PCH_HPP__
  #pragma message [ not using pre-compiled headers ]
  #include iostream
#endif

--
test.cpp
--
#include pch.hpp
int main() {
std::cout  hello world  std::endl;
return 0;
}

--

If you run commands [1] and [2] below, you will notice that pch is ignored.

[1]  g++ -I. pch.hpp  -o pch.hpp.gch
[2]  g++ -I. -c test.cpp  -o test.o
[3]  g++ -I. -c test.cpp  -o test.o -include pch.hpp

However, if you add -g3 to commands [1] and [2], then pch will be used in
command [2]. More specifically, you must use a combination of the -g flags I
described in the report for pch to be utilized.

One more note: Using the -include option (even though it's unnecessary in this
case) makes the -g3 flags no longer needed. To confirm this, execute commands
[1] and [3] and observe that pch is no longer ignored, even without the -g3
flags.