[PATCH] D10431: PR21174 - clang only searches current working directory for precompiled include file

Kim Gräsman via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 22:39:02 PDT 2015


On Tue, Aug 18, 2015 at 2:00 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>
>> > Should this logic for PCH/PTH scanning move out of the driver and into
>> > the frontend?
>
>> gcc also checks if the gch file is a directory and if so finds the first
>> file with matching language / defines etc. It also uses gch files for
>> #included files instead of just -included files
>> (https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html). I thought
>> clang intentionally did none of this so it doesn't have to stat all these
>> directories.
>
> Right, so the question is: what do we want our semantics to be here? Do we
> have sufficient motivation to change our existing design to something closer
> to GCC's? Or should we be encouraging people to use modules instead of PCH
> here, which has all of the desirable properties of the above, and doesn't
> have the "no preceding tokens" limitation?

We find Clang's GCC compat very useful overall, because we use GCC as
a cross-compiler and we can more or less drop in Clang for better
diagnostics and tooling.

So from a personal convenience standpoint, Nikola's patch would be
sufficient, because it would bring Clang just close enough to GCC to
solve our problem (we've now worked around it by disabling PCH in our
build system when we build for Clang.)

Encouraging modules would (I suppose?) create a split where Clang had
modules and other compilers had precompiled headers. For a Clang-only
shop, that's fine, but for a GCC/MSVC/Clang environment like ours,
that would be more work to find common ground. The remaining GCC PCH
behavior sounds mostly esoteric, so I, personally, don't see any point
in trying to mimic it, but others will probably disagree here.

All that said, I think we can solve this locally by just changing our
build system to -include an absolute path, so this isn't critical for
us at the moment. It would be convenient for us if this compat glitch
could be solved, but if you'd rather focus on modules, I can
understand that too :-)


More information about the cfe-commits mailing list