On 06/12/2018 04:46 PM, Adam Borowski wrote: > Hi! > Here's a patch for Bugzilla 80271, to add support for env CLICOLOR_FORCE. > > Automated build environments -- and even some which you run by hand -- > redirect the output somewhere to save a log, even if they tee it to the > terminal anyway. This kills all colored highlights for diagnostics. > Those highlights are really nice for a human -- unlike the old days when > a single-threaded build always had the failure at the end, modern setups > tend to spew pages of stuff after the real reason your build failed. As > human vision evolved to be extremely good at noticing a fleck of color, > it's easy to spot that bit of red even when scrolling very fast. > > Besides terminals, you can read colored logs via "less -R", ansi2html, etc. > > For such piped setups, gcc has -fdiagnostics-color=always. Alas, while this > flag is easy to set by someone writing a given piece of software, there's > no reasonable way to set it globally in the build environment. > > Thus, in #80271 Jan Niklas Hasse requested, and I concur, to be able to > set the same via an env var. This flag doesn't affect code produced by gcc > in any way, thus it's reasonable to set it via env. There's already > GCC_COLORS letting you customize colors used, you just can't tell it to > ignore stderr not being a terminal. > > > Please forgive my lack of knowledge wrt proper ways of submitting patches to > gcc (ie, when biting please point to piece of TFM I failed to R). In > particular, I'm not sure how to run the testsuite: it produces a lot of > fails even without my patch, and I don't know what is your way to spot new > failures. The testsuite could be interesting as gcc in a lot of places sets > and unsets CLICOLOR_FORCE despite not supporting it itself (yet a number of > other tools do). Weirdly, in every case you unset it in the very next line > after enabling it. > > I've submitted an equivalent of this patch to llvm/clang as well. We _strongly_ discourage the use of environment variables to control the compiler. Really the way to go here is to use the -fdiagnostics-color=always and deal with the difficulties of flag injection.
Jeff