Skip to content

Share cache entries for the TTY and redirected stderr cases for clang #223

@jrosdahl

Description

@jrosdahl

Background

ccache currently can't share cache entries between these two cases:

  1. ccache clang -c source.c
  2. ccache clang -c source.c 2>/dev/null

We can fix it. See also the discussion in #222.

What to do

Here's a sketch of what could be done to fix the problem:

If the compiler is clang:

  • Don't include any explicit -f(no-)color-diagnostics options in the hash.
  • Strip any explicit -fno-color-diagnostics options from the compiler arguments and add a -fcolor-diagnostics option (if not already present) to force colors.
  • On a cache hit: Strip color codes from the stored stderr if -fno-color-diagnostics has been passed OR (stderr does not refer to a TTY AND -fcolor-diagnostics has not been passed).
  • Prove that it works by adding a test case that checks that color codes are stored in the cache and that color codes are not produced when stderr is redirected.
  • Remove the corresponding caveat from the documentation.

See also #224 which is somewhat similar but for GCC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions