]> git.ipfire.org Git - thirdparty/ccache.git/commit
Retain given color diagnostics options when forcing colored output
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 2 Nov 2020 21:09:56 +0000 (22:09 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 3 Nov 2020 19:00:40 +0000 (20:00 +0100)
commit50e8d22943621db33ef30b7333b3be4f923cfad8
tree4fae4675a14b934126ba9d6494dc2988bdfc55e0
parenta1ffc3940b6905376aa87cfb4469b515e5e9b8e6
Retain given color diagnostics options when forcing colored output

ccache currently filters out both -fdiagnostics-color and
-fcolor-diagnostics options when adding -fdiagnostics-color (GCC) or
-fcolor-diagnostics (Clang) to force colored output. The idea in #224
was that only -fdiagnostics-color options should be filtered out when
the compiler is GCC, but -fcolor-diagnostics is also removed, something
which was missed in the code review. This has the unintended side effect
that “ccache gcc -fcolor-diagnostics -c example.c” works since ccache in
effect removes -fcolor-diagnostics in the actual call to the compiler.

The bug can fixed by removing only the compiler-specific options when
forcing colored output, but a more robust method would be to retain all
color diagnostics options as is but exclude them from the input hash.
This commit makes that change and also simplifies the logic for color
diagnostics option handling.

Fixes #711.
src/argprocessing.cpp
src/ccache.cpp
test/suites/base.bash
test/suites/color_diagnostics.bash