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).

Reply via email to