Background
ccache currently can't share cache entries between these two cases:
ccache clang -c source.c
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.
Background
ccache currently can't share cache entries between these two cases:
ccache clang -c source.cccache clang -c source.c 2>/dev/nullWe 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:
-f(no-)color-diagnosticsoptions in the hash.-fno-color-diagnosticsoptions from the compiler arguments and add a-fcolor-diagnosticsoption (if not already present) to force colors.-fno-color-diagnosticshas been passed OR (stderr does not refer to a TTY AND-fcolor-diagnosticshas not been passed).See also #224 which is somewhat similar but for GCC.