[ccache] ccache and -ftest-coverage

Davlet Panech davlet_panech at yahoo.ca
Wed Mar 3 18:58:39 GMT 2004


 --- Kimberley Burchett <kim at grassybrook.com> wrote:
> As of version 2.3, ccache does not handle the gcc flag -ftest-coverage
> correctly.  This flag causes gcc to output two extra files in addition
> to the object file.  ccache doesn't cache the extra files, so it is
> impossible to use ccache when compiling for code coverage testing.
> 
> There are three solutions to this that I can see:
> 
> 1) Disable caching when -ftest-coverage is specified.  I've patched my
> local version of ccache to do this, but it's possible to do better.
> 
> 2) Handle -ftest-coverage as a special case.
> 
> 3) Make ccache notice when extra files are created with the same prefix
> as the output object file, and cache those as well.  I think this is
> probably the correct long-term solution, unless people know of
> situations where it would cause problems.  I'd make the feature check
> for an environment variable listing the extra file extensions that
> ccache should look for.  Something like:
>     CCACHE_EXTRAFILES="%s.bb %s.bbg"
> 

gcc 2.9 always uses the basename of the source file to generate the names of these extra files,
while gcc 3 uses the full name of the object file. One way to fix it would be to introduce a few
"%" codes to refer to different file names.

There is a somewhat similar problem with the "-MD" flag. It outputs an extra file, but the name
and contents of that file is different between gcc2.9 and gcc3. The solution would be to pass
additional flags to the preprocessor when gcc3 is used. Something like:
  %o   -- output file ("dir/file.o")
  %bo  -- basename of output file ("file")
  %po  -- prefix of output file ("dir/file")
  %c   -- source file ("dir/file.c")
  %bc  -- basename of source file ("file")
  %pc  -- prefix of source file ("dir/file")

and

when using gcc3:
  CCACHE_EXTRAFILES="%po.bb %po.bbg"
  CCACHE_EXTRAFLAGS="-MQ %o -MF %po.d"

when using gcc2.9:
  CCACHE_EXTRAFILES="%bc.bb %bc.bbg"
  CCACHE_EXTRAFLAGS=""    # (empty)



I suggested a different solution on this list a little while ago (see message "-MD switch broken
in gcc3 w/ccache", Feb 20), but received no replies. The idea was to run a few "compiler feature
tests" (similar to the way autoconf/configure does it) to determine what needs to be done when
certain flags are present on the command line. We would then cache the results of the tests and
reuse them on subsequent invocations. This way we would treat each "irregular" flag as a special
case, thus being able to "do the right thing" depending on what is passed to us without any
intervention from the user.

The advantage is that everything will "just work" for the supported flags/compilers; but
implementing this would be quit a bit of work. I would be willing to work on it, though, but I'd
like to hear from the maintainers first.

Thoughts?
D.


______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca


More information about the ccache mailing list