[cfe-users] How to have clang ignore gch directories?
Paul Smith via cfe-users
cfe-users at lists.llvm.org
Tue Apr 23 12:06:56 PDT 2019
How can I get clang to stop caring about gch directories for
precompiled headers that were created by GCC?
Currently my main build uses GCC and it generates .gch directories:
$ ls -1d foo_pch*
When I compile my code using GCC, it works fine:
$ g++ ... -Winvalid-pch --include=foo_pch.h ...
But then if I try to use tools based on clang with exactly the same
arguments, it throws an error (with or without -Winvalid-pch):
$ clang++ ... --include=foo_pch.h ...
error: no suitable precompiled header file found in directory
1 error generated.
Note I'm really not using clang++, I'm using a tool linked with libLLVM
which parses the code, but I get the same behavior there.
Using strace I can see clang first look for .pch then .pth (neither of
which exist, which is fine), and finally .gch. Apparently clang cannot
parse the GCC-generated precompiled header file. I don't care if clang
can't read those files, I just want it to include the .h file.
How can I tell clang to just ignore the GCC-specific precompiled
headers, or equivalently ignore precompiled headers altogether? I
can't delete the gch directories because I need them for my build. I've
read through the clang docs and can't find any likely-looking options.
It's really frustrating when clang tries to appropriate GCC-specific
options and configurations when it's not actually compatible with them.
It makes modern multi-compiler development so unnecessarily difficult.
FWIW, I'm working with Clang 7.0.1 on GNU/Linux Ubuntu 18.04.
More information about the cfe-users