GCC ≥9 has changed behavior for -ftest-coverage and --coverage in
combination with -fprofile-dir=dir:
- Without -fprofile-dir=dir the file is placed next to the object file
but with a “.gcno” extension.
- With -fprofile-dir=dir the file is also place next to the object file
(i.e. not in the specified profile directory) but the same style of
name as used for “.gcda” files (full pathname with slashes replaced
with hash characters).
Fix this by:
- Checking if the expected (GCC <9) .gcno file is present. If not, fall
back to running the compiler and increment the “unsupported option”
counter.
- Making sure to perform the above check before copying the object file
to the cache so that a later ccache invocation won’t believe that
there is a result in the cache.
- Improving the copy_file routine to not create the destination file
until it knows that there is a source file to copy from.