On Sun, Sep 9, 2012 at 6:17 AM, Allan Odgaard
<text...@gmail.com> wrote:
On Sep 9, 2012, at 3:03 PM, Mathias Gaunard <mat...@gaunard.com> wrote:
> […] GCC and Clang […] will not output the dependencies from a PCH file […] (gcc bug 14933)
>
> What is therefore the recommended way to deal with this?
Setup your .o files to depend on the precompiled header (i.e. the version produced by clang/gcc), which in turn should depend on the headers it includes (which are output with -MD when you precompile it).
That's what we do in chromium as well.
Rule for the gch file:
build $
obj/third_party/WebKit/Source/WebCore/webcore_platform.WebCorePrefix.h-cc.gch: $
cxx ../../third_party/WebKit/Source/WebCore/WebCorePrefix.h
cflags_pch_cc = -x c++-header
Rule for a cpp file depending on it:
build $
obj/third_party/WebKit/Source/WebCore/platform/webcore_platform.LayoutTestSupport.o: $
cxx $
../../third_party/WebKit/Source/WebCore/platform/LayoutTestSupport.cpp $
| $
obj/third_party/WebKit/Source/WebCore/webcore_platform.WebCorePrefix.h-cc.gch $
|| $ obj/third_party/WebKit/Source/WebCore/WebCore.gyp/webcore_platform.gen/WebCore/WebCoreSystemInterface.h
(Since compile flags are different for precompiled headers in c, c++, objc, and objc++ modes, we build four different gch files. This example is for c++, hence the '-cc.gch'.)
If you use gyp, the GCC_PRECOMPILE_PREFIX_HEADER and GCC_PREFIX_HEADER xcode_settings get translated into the right thing transparently for the ninja generator.
Nico