From patchwork Tue Jun 12 22:46:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 928531 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-479601-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=angband.pl Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="smYStZ0P"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4154lG1YvBz9s2t for ; Wed, 13 Jun 2018 08:47:20 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=H3llcihRAYXBNaXUTARNTWQiRmd3b2R/28fQy7jNewm/soB4Zumuy t1I1L2gAv6HTgqji/wLeZ0hvZ4gsUWHzJoH7/FrwCUcd0DJXQNwE/iZTz6rXhYTw F2B2Y0ShqV81lYXWRB1+pu5ThhP/ajbfhJUQNqvjeXV/tst2Wxya4A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=GS+Ex3hmvNmdk+uWU/++UR4CFSM=; b=smYStZ0PS/fEfm57Bacd 00Pe7ewAeuswKyti/tZJKtdLUqFc1FM399prAc3U+EqNrUQSfKYIdp1VoqJbKms3 47t0INvz0fp6mlpO+yAGTtPawmY/qY0oWc12tJG9QJyoXh+xnpzDwG0Ng42aQmdl 48qQAexW30zE16M2XHWgBZ4= Received: (qmail 30975 invoked by alias); 12 Jun 2018 22:47:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 21870 invoked by uid 89); 12 Jun 2018 22:47:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:4.89, vision, highlights, clic X-HELO: tartarus.angband.pl Received: from tartarus.angband.pl (HELO tartarus.angband.pl) (89.206.35.136) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Jun 2018 22:47:03 +0000 Received: from kilobyte by tartarus.angband.pl with local (Exim 4.89) (envelope-from ) id 1fSs43-00040Y-P6 for gcc-patches@gcc.gnu.org; Wed, 13 Jun 2018 00:46:59 +0200 Date: Wed, 13 Jun 2018 00:46:59 +0200 From: Adam Borowski To: gcc-patches@gcc.gnu.org Subject: [PATCH] Let env var CLICOLOR_FORCE set -fdiagnostics-color=always. Message-ID: <20180612224659.spp22g33ym4pib5r@angband.pl> MIME-Version: 1.0 Content-Disposition: inline X-Junkbait: aaron@angband.pl, zzyx@angband.pl User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: kilobyte@angband.pl X-SA-Exim-Scanned: No (on tartarus.angband.pl); SAEximRunCond expanded to false X-IsSubscribed: yes 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. -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- From: Adam Borowski Date: Mon, 11 Jun 2018 01:01:46 +0200 Subject: [PATCH] Let env var CLICOLOR_FORCE set -fdiagnostics-color=always. --- gcc/diagnostic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index e22c17bc02c..d9e352932c6 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -190,12 +190,18 @@ diagnostic_color_init (diagnostic_context *context, int value /*= -1 */) /* value == -1 is the default value. */ if (value < 0) { + /* Explicit command-line args override env, but env prevails over + defaults, whatever they are. + The spec defines an existing but empty var to mean "yes". */ + const char* clic = getenv ("CLICOLOR_FORCE"); + if (clic && strcmp (clic, "0")) + value = DIAGNOSTICS_COLOR_YES; /* If DIAGNOSTICS_COLOR_DEFAULT is -1, default to -fdiagnostics-color=auto if GCC_COLORS is in the environment, otherwise default to -fdiagnostics-color=never, for other values default to that -fdiagnostics-color={never,auto,always}. */ - if (DIAGNOSTICS_COLOR_DEFAULT == -1) + else if (DIAGNOSTICS_COLOR_DEFAULT == -1) { if (!getenv ("GCC_COLORS")) return;