Hi!

On Tue, 2018-06-05 at 18:32:21 +0200, Adam Borowski wrote:
> Package: dpkg-dev
> Version: 1.19.0.5
> Severity: wishlist
> Tags: patch

> Here's a patch to turn on colorized diagnostics via dpkg-buildflags if
> DEB_BUILD_OPTIONS includes "color".  This is the usual default, but both
> gcc and clang disable color if their output is redirected (as, unlike
> terminals, not all tools used to browse build logs understand ANSI color).
> Thus, let's re-enable it via -fdiagnostics-color=always.
> 
> The rationale has been recently discussed on debian-devel@lists.d.o; to
> a human who reads build logs highlighting problems allows finding the
> error in the middle of a lengthy log drastically faster: you look for that
> piece of red; this exploits a peculiarity of human vision which evolved
> to be extremely good at noticing a fleck of color appearing for even a tiny
> fraction of second.
> 
> To read such a log, you print it to a terminal, less -R, ansi2html or so on.

I hope you don't intend for this to be the default in the future, as I
expect it might wreak havoc. :)

Right now, given that it's not the default, I'm happy to add it.

> I'm not sure what to do with LDFLAGS: currently dpkg-buildflags gives
> options like -g -O2 only to ${LANG}FLAGS, these are supposed to be given
> when linking as gcc fails to do some optimizations otherwise (especially
> with LTO), but some packages pass LDFLAGS only.  Should we add
> -fdiagnostics-color=always there as well?  This would be redundant but
> harmless for properly written makefiles.

I think using a flag here is also a bit suboptimal, and it clutters the
compiler flags. But I don't see any other way to force colors for gcc
and clang. The presence of GCC_COLORS envvar enables at most auto mode,
and clang does not seem to support any envvar. :/

For dpkg itself, you'd just export DPKG_COLORS=always and that's it
though. :)

So, thanks for the patch! It's missing an update to the man page
though. :) About the option name, I'd probably use "colors", but that
does not really describe its nature, which is to force them, perhaps
"colors-forced" or "colors-always" but that's a bit long.

I'd probably also force DPKG_COLORS=always from dpkg-buildpackage if
the option is set.

Thanks,
Guillem

Reply via email to