-
Notifications
You must be signed in to change notification settings - Fork 625
Open
Description
Precompiled headers are incorrectly identified as cache hit, even if macro definitions inside them changed. This causes wrong results. When preprocessing PCH, the output of -dD (which includes the macro definitions and their expansions) must be taken into account to determine equality.
This primarily affects GCC. For Clang, it appears that the macro definition is not included in the PCH, making the false positive erroneous but harmless (I'm not sure whether this is intended or is just due to my limited testing).
# sccache 0.12.0
touch empty.c
echo -e '#include "test.h"\n#include<stdio.h>\nint main(){printf("%d\\n",TEST);}' > test.c
echo -e '#ifndef TEST_H\n#define TEST_H\n#define TEST 1\n#endif' > test.h
sccache /usr/bin/gcc -fpch-preprocess -Winvalid-pch -x c-header -include test.h -o test.h.gch -c empty.c
sccache /usr/bin/gcc -fpch-preprocess -Winvalid-pch -include test.h -o test test.c
./test # prints 1
echo -e '#ifndef TEST_H\n#define TEST_H\n#define TEST 2\n#endif' > test.h
sccache /usr/bin/gcc -fpch-preprocess -Winvalid-pch -x c-header -include test.h -o test.h.gch -c empty.c
sccache /usr/bin/gcc -fpch-preprocess -Winvalid-pch -include test.h -o test test.c
./test # prints 1, should print 2Metadata
Metadata
Assignees
Labels
No labels