Package: dpkg-dev Version: 1.19.0.5 Severity: wishlist Tags: patch Hi! 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'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. Compilers other than gcc/clang have their equivalents (such as CLICOLOR_FORCE=1 for cmake) but AFAIK none of those are handled by dpkg-dev, thus I'll need to submit relevant patches to other packages. This one goes first. Meow! -- System Information: Debian Release: buster/sid APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'unstable'), (500, 'testing'), (150, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.17.0+ (SMP w/6 CPU cores) Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) Versions of packages dpkg-dev depends on: ii binutils 2.30-21 ii bzip2 1.0.6-8.1 ii libdpkg-perl 1.19.0.5 ii make 4.2.1-1 ii patch 2.7.6-2 ii perl 5.26.2-5 ii tar 1.30+dfsg-2 ii xz-utils 5.2.2-1.3 Versions of packages dpkg-dev recommends: ii build-essential 12.5 ii clang-4.0 [c-compiler] 1:4.0.1-10+b1 ii fakeroot 1.22-2 ii gcc [c-compiler] 4:7.3.0-3 ii gcc-7 [c-compiler] 7.3.0-21 ii gnupg 2.2.7-1 ii gpgv 2.2.7-1 ii libalgorithm-merge-perl 0.08-3 ii tcc [c-compiler] 0.9.27-8 Versions of packages dpkg-dev suggests: ii debian-keyring 2018.06.04 -- no debconf information
>From 4475e3e219f4629058925ed04a06d13022a48797 Mon Sep 17 00:00:00 2001 From: Adam Borowski <kilob...@angband.pl> Date: Tue, 5 Jun 2018 17:17:12 +0200 Subject: [PATCH] dpkg-buildflags: enable gcc/clang color diagnostics if opts include "color" This requires build logs to be written to a terminal or read using a tool that understands ANSI color, such as "less -R", thus this needs to be opt-in for now. Build logs can be prepared for web via ansi2html, or stripped back to plain text via ansi2txt. --- scripts/Dpkg/BuildFlags.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm index 0533b12b5..39e0b7a96 100644 --- a/scripts/Dpkg/BuildFlags.pm +++ b/scripts/Dpkg/BuildFlags.pm @@ -75,6 +75,7 @@ sub load_vendor_defaults { my $build_opts = Dpkg::BuildOptions->new(); $self->{build_options} = $build_opts; my $default_flags = $build_opts->has('noopt') ? '-g -O0' : '-g -O2'; + $default_flags .= ' -fdiagnostics-color=always' if $build_opts->has('color'); $self->{flags} = { CPPFLAGS => '', CFLAGS => $default_flags, -- 2.17.1