GCC support profile based optimization using the -fprofile-generate and -fprofile-use options. The first instructs gcc to include hooks for the profile data file generation, the latter uses them in the optimization step. The profile data file is stored in the same directory as the source file, with the suffix .gcda. When using ccache, the input file names of gcc are replaced by temporary (preprocessed) file names. As the file names differ between the first and the second compilation step, gcc is unable to identify the profile data file and can't use it. The patch solves this problem by searching for the flags '-fprofile-generate', '-fprofile-use' and '-fprofile-arcs'. If found, the caching is disabled and the original gcc call (with the original input files) is performed. Clemens Reproducible: Always Steps to Reproduce: 1. echo "int main(int a, char** b){}" > test.c 2. gcc -fprofile-generate -c test.c 3. gcc -fprofile-generate -o test test.o 4. ./test 5. gcc -fprofile-use -c test.c 6. gcc -o test test.o Actual Results: With unpatched ccache: 5) Gives warning about $CCACHE_DIR/tmp.hash.*.gcda file not found, execution counts assumed to be zero Expected Results: With ccache: 2) Generated test.gcno in current directory 4) Generated test.gcda in current directory 5) No error.
Created attachment 140402 [details, diff] Patch to prevent ccache from caching when -fprofile-* options are used. Patch used in attached ebuild to fix the bug.
Created attachment 140403 [details] Modified ebuild to apply the patch
incvs.