-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ccache gives different warnings than raw g++ call #93
Comments
Can't reproduce the problem using ccache 3.2.5 and g++ 5.2.1 to compile your example code. It might be useful to have a look at ccache's log output:
|
Interesting, it's the -E step that adds the output, i.e. I guess that makes it a gcc bug? |
Not sure i understand the g++ devs correctly but i think they say it's not really a bug but a byproduct of doing the -E step https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71517 Is the -E step necessary for ccache to work? And would switching to using something like $ g++ -E -fdirectives-only -fPIC -Wsuggest-override -isystem /usr/include/x86_64-linux-gnu/qt5/ q.cpp > q.i Would be possible? (since that also seems to make the warnings go away) |
You don't want -fdirectives-only on the -c compilation, only on the preprocessing step obviously. |
If you don't give You can use run_second_cpp / $CCACHE_CPP2, to run the preprocessor (cpp) again. |
The second step should be of course without -fpreprocessed too, because what -E -fdirectives-only does is not preprocessing, it is just evaluating the various preprocessing conditions and including the headers. |
I understand why you suggest using
|
On Fri, Jul 08, 2016 at 08:46:26AM -0700, Joel Rosdahl wrote:
That can surely be configurable and/or runtime testable, so one could
The amount of diagnostics etc. that differs between non-integrated and
|
Possible: yes. Unproblematic: no. Requiring configuration to make ccache work with certain compilers would be quite painful from a ccache user point of view since ccache always has tried to work out of the box regardless of which compiler is being used. Also, there's (at least currently) no good way to have compiler-specific configuration since ccache doesn't really know which compiler is run. So to preserve the works-out-of-the-box and no-compiler-specific-configuration traits, I think that ccache would need runtime detection. Which leads to:
If you mean testing for compiler version (with something like "$compiler --version", or if that fails, "$compiler -V" for e.g. SUNStudio, or if that fails, "$compiler /HELP" for MSVC, or if that fails, what?) for each ccache invocation, then: Possible: yes. Easy to implement: probably. Easy to maintain: probably not. Will slow down ccache, especially for esoteric compilers: yes. (By the way, one might think that it should be possible to cache the compiler detection result based on mtime of the compiler, and that's of course possible but not very robust since the compiler could be a shell script that selects the actual compiler to run.) I have considered introducing runtime detection several times before but never got to try implementing it for the reasons mentioned above. If you mean testing specifically if -fdirectives-only works, then that has similar problems.
It may be a small enough price for you who probably doesn't even use ccache, but for me and likely other ccache users, getting cache misses just because some unused -D option changed value would matter. That said, I'm of course in no position to do much else than try to compensate for changed behavior of compilers. Since the main compilers used with ccache are GCC and clang, and, as you say, both likely will continue to work differently when compiling preprocessed input vs normal compilation, it makes sense to follow their new behavior. However, since clang doesn't have -fdirectives-only, it wouldn't help the clang case even if ccache started using it. Therefore, my suggestion is to flip the default of run_second_cpp from false to true. This will solve the problem for all compilers at the expense of some slowdown. For modern compilers the slowdown is measurable but quite tiny, so I don't think it's a problem. To me, this would be much more appealing than e.g. losing the "ignore unused -D flags" feature. @itensionanders and others: Opinions on simply letting run_second_cpp default to true? |
@jrosdahl : I think that we should consider enabling both of run_second_cpp and hash_dir The usual case is direct hit anyway, so enabling it wouldn't cost that much - unless compiling. The hash_dir similarly gives less surprises when compiling with debug objects, and now there I've found that |
This and other similar whitespace diagnostics probably also has problems using distcc, since that also transports preprocessed source code (using the ccache intermediate files, where available). |
Yes, agree. |
Output from g++ and ccache: http://paste.ubuntu.com/17091648/
The file i'm compiling is at http://paste.ubuntu.com/17091697/
$ ccache -V
ccache version 3.2.4
$ g++ --version
g++ (Ubuntu 5.3.1-14ubuntu2.1) 5.3.1 20160413
Using Ubuntu 16.04
Any idea why that happens?
The text was updated successfully, but these errors were encountered: