mozilla / sccache

Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.
Apache License 2.0
5.74k stars 542 forks source link

sccache breaks -Wimplicit-fallthrough #821

Open anholt opened 4 years ago

anholt commented 4 years ago

I've been looking at using sccache to improve Mesa build times, and I noticed that after getting sccache working locally, my build was spewing -Wimplcit-fallthrough errors. Sample code:

#include <stdio.h>

int main(int argc, char **argv)
{
    switch (argc) {
    case 0:
        printf("0\n");
        /* fallthrough */
    case 1:
        printf("1\n");
        break;
    }
    return 0;
}

Output:

% /usr/bin/gcc-10 -Wimplicit-fallthrough -c -o fallthrough-test fallthrough-test.c        
% sccache /usr/bin/gcc-10 -Wimplicit-fallthrough -c -o fallthrough-test fallthrough-test.c
fallthrough-test.c: In function 'main':
fallthrough-test.c:7:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
    7 | # 1 "fallthrough-test.c"
      |   ^~~~~~~~~~~~~
fallthrough-test.c:9:2: note: here
    9 | # 27 "/usr/include/stdio.h" 3 4
      |  ^~~~
mstange commented 3 years ago

Hmm, maybe preprocessing was removing the /* fallthrough */ comment? I'm not sure if the preprocessor touches regular comments, I thought it didn't. Could you retest with rewrite_includes_only = true in your config's [dist] section?

anholt commented 3 years ago

It does seem like that option would be required. However I'm failing to reproduce now (possibly due to a new compiler, possibly that I changed something else in sccache configuration since then before I dropped using it)