From patchwork Mon Apr 15 14:37:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 236621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 5A3CC2C00C4 for ; Tue, 16 Apr 2013 00:37:20 +1000 (EST) 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:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=oJ1PKfB6X03RPaP6d I1VPN8OrOqMmWhtq3QgzPRO930Wl13B7dSPNSxwVkXn3L75sXbI0CNygAo2rijQn AO5/HCT95z/CLj8H8635fVQXDkR1khZ0R74TshqugBs7ncSkcXRJJSrnrONVcWYZ p42R0hnesNdyJ8cBGV04JZtopA= 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:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=UKHgEujqTt5JgCVAi0/z7kn 7c1c=; b=Zg0uRResZ4stLJ1TF+pbhIG057UMh3qKEn9K0djHFpiFuf7F6QqUaL9 8p/Ry0nSu3rv5IoPM59JOsnxM9ftF5pV/0EXG7RdFXFsteXMgm22yhB2+JlrfJMD 5BLUTbwgbVziutHMzXjvcQdPL56TCk+Z3dV9jF189QB5gYFPE7d4= Received: (qmail 22247 invoked by alias); 15 Apr 2013 14:37: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 22238 invoked by uid 89); 15 Apr 2013 14:37:13 -0000 X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 15 Apr 2013 14:37:12 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3FEb9Zt022103 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Apr 2013 10:37:10 -0400 Received: from zalov.cz (vpn-57-214.rdu2.redhat.com [10.10.57.214]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3FEb6JZ006003 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 15 Apr 2013 10:37:08 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r3FEb4Aq015917; Mon, 15 Apr 2013 16:37:04 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r3FEb19Q015916; Mon, 15 Apr 2013 16:37:01 +0200 Date: Mon, 15 Apr 2013 16:37:00 +0200 From: Jakub Jelinek To: Gabriel Dos Reis Cc: Marc Glisse , Manuel =?iso-8859-1?B?TPNwZXotSWLh8WV6?= , "Joseph S. Myers" , Jason Merrill , Gcc Patch List Subject: Re: [PATCH] color diagnostics markers Message-ID: <20130415143700.GJ12880@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20130402091449.GE20616@tucnak.redhat.com> <20130408132301.GO20334@tucnak.redhat.com> <20130409132143.GV20334@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) On Mon, Apr 15, 2013 at 04:14:58AM -0500, Gabriel Dos Reis wrote: > > Defining a variable in my environment counts as a clear intention. > > If you invoke GCC on command line with explicit option requesting > colors, I don't think there is any doubt that. However, I dispute the > intent to be so universally clear for most GCC users who happen to have > GCC_COLORS set -- most users inherit whatever their sysadmin or > distros set for them. > > That said, I am fine with the idea to GCC_COLORS => detect. Here is a patch that implements it. If GCC_COLORS isn't in the environment, the default is still -fdiagnostics-color=never, otherwise it is -fdiagnostics-color=auto (but, as before, if GCC_COLORS is in the environment, but empty, colors aren't shown at all). Bootstrapped/regtested on x86_64-linux and i686-linux, additionally tested on a few testcases with make check when GCC_COLORS was in the environment, and additionally tested with RUNTESTFLAGS='--target_board=unix/-fdiagnostics-color=always dg.exp=pr56*.c' where only the last one showed some (expected) regressions, because that forces over colors even for the tests. Ok for trunk? 2013-04-15 Jakub Jelinek * Makefile.in (toplev.o): Depend on diagnostic-color.h. * diagnostic-color.c (should_colorize): Remove _WIN32 version. (colorize_init): Add argument to _WIN32 version. * toplev.c: Include diagnostic-color.h. (process_options): Default to -fdiagnostics-color=auto if GCC_COLORS env var is in the environment. * common.opt (fdiagnostics-color=): Add Var and Init. * doc/invoke.texi (-fdiagnostics-color=): Document that if GCC_COLORS env var is in the environment, the default is auto rather than never. * lib/prune.exp: Add -fdiagnostics-color=never to TEST_ALWAYS_FLAGS. * lib/c-compat.exp (compat-use-alt-compiler, compat_setup_dfp): Handle -fdiagnostics-color=never option similarly to -fno-diagnostics-show-caret option. Jakub --- gcc/Makefile.in.jj 2013-04-12 08:13:22.000000000 +0200 +++ gcc/Makefile.in 2013-04-12 08:13:22.000000000 +0200 @@ -2710,7 +2710,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM $(OPTS_H) params.def tree-mudflap.h $(TREE_PASS_H) $(GIMPLE_H) \ tree-ssa-alias.h $(PLUGIN_H) realmpfr.h tree-diagnostic.h \ $(TREE_PRETTY_PRINT_H) opts-diagnostic.h $(COMMON_TARGET_H) \ - tsan.h + tsan.h diagnostic-color.h hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H) --- gcc/diagnostic-color.c.jj 2013-04-12 08:13:22.000000000 +0200 +++ gcc/diagnostic-color.c 2013-04-15 13:00:41.978114658 +0200 @@ -264,14 +264,8 @@ parse_gcc_colors (void) } #if defined(_WIN32) -static bool -should_colorize (void) -{ - return false; -} - bool -colorize_init (void) +colorize_init (diagnostic_color_rule_t) { return false; } --- gcc/doc/invoke.texi.jj 2013-04-12 08:13:22.000000000 +0200 +++ gcc/doc/invoke.texi 2013-04-15 13:41:42.869556167 +0200 @@ -2963,9 +2963,10 @@ a message which is too long to fit on a @cindex highlight, color, colour @vindex GCC_COLORS @r{environment variable} Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always}, -or @samp{auto}. The default is @samp{never}, @samp{auto} means to use color -only when the standard error is a terminal. The forms -@option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are +or @samp{auto}. The default is @samp{never} if @env{GCC_COLORS} environment +variable isn't present in the environment, and @samp{auto} otherwise. +@samp{auto} means to use color only when the standard error is a terminal. +The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are aliases for @option{-fdiagnostics-color=always} and @option{-fdiagnostics-color=never}, respectively. --- gcc/testsuite/lib/prune.exp.jj 2013-01-11 09:02:39.000000000 +0100 +++ gcc/testsuite/lib/prune.exp 2013-04-15 13:36:49.275191326 +0200 @@ -19,7 +19,7 @@ if ![info exists TEST_ALWAYS_FLAGS] { set TEST_ALWAYS_FLAGS "" } -set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret $TEST_ALWAYS_FLAGS" +set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret -fdiagnostics-color=never $TEST_ALWAYS_FLAGS" proc prune_gcc_output { text } { #send_user "Before:$text\n" --- gcc/testsuite/lib/c-compat.exp.jj 2013-01-11 09:02:39.000000000 +0100 +++ gcc/testsuite/lib/c-compat.exp 2013-04-15 13:38:36.361596471 +0200 @@ -34,7 +34,7 @@ load_lib target-supports.exp # proc compat-use-alt-compiler { } { global GCC_UNDER_TEST ALT_CC_UNDER_TEST - global compat_same_alt compat_alt_caret + global compat_same_alt compat_alt_caret compat_alt_color global TEST_ALWAYS_FLAGS # We don't need to do this if the alternate compiler is actually @@ -44,6 +44,9 @@ proc compat-use-alt-compiler { } { if { $compat_alt_caret == 0 } then { regsub -- "-fno-diagnostics-show-caret" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS } + if { $compat_alt_color == 0 } then { + regsub -- "-fdiagnostics-color=never" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS + } } } @@ -70,9 +73,11 @@ proc compat_setup_dfp { } { global compat_same_alt global compat_have_dfp global compat_alt_caret + global compat_alt_color global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS set compat_alt_caret 0 + set compat_alt_color 0 set compat_save_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS verbose "compat_setup_dfp: $compat_use_alt $compat_same_alt" 2 @@ -88,6 +93,10 @@ proc compat_setup_dfp { } { int dummy; } "-fno-diagnostics-show-caret"] != 0 } { set compat_alt_caret 1 } + if { [check_no_compiler_messages_nocache compat_alt_has_color object { + int dummy; } "-fdiagnostics-color=never"] != 0 } { + set compat_alt_color 1 + } compat-use-tst-compiler } --- gcc/toplev.c.jj 2013-04-08 15:38:20.000000000 +0200 +++ gcc/toplev.c 2013-04-15 13:12:53.757005505 +0200 @@ -74,6 +74,7 @@ along with GCC; see the file COPYING3. #include "gimple.h" #include "tree-ssa-alias.h" #include "plugin.h" +#include "diagnostic-color.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -1209,6 +1210,13 @@ process_options (void) maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT; + /* Default to -fdiagnostics-color=auto if GCC_COLORS is in the environment, + otherwise default to -fdiagnostics-color=never. */ + if (!global_options_set.x_flag_diagnostics_show_color + && getenv ("GCC_COLORS")) + pp_show_color (global_dc->printer) + = colorize_init (DIAGNOSTICS_COLOR_AUTO); + /* Allow the front end to perform consistency checks and do further initialization based on the command line options. This hook also sets the original filename if appropriate (e.g. foo.i -> foo.c) --- gcc/common.opt.jj 2013-04-12 08:13:22.000000000 +0200 +++ gcc/common.opt 2013-04-15 13:07:59.112638039 +0200 @@ -1033,7 +1033,7 @@ Common Alias(fdiagnostics-color=,always, ; fdiagnostics-color= -Common Joined RejectNegative Enum(diagnostic_color_rule) +Common Joined RejectNegative Var(flag_diagnostics_show_color) Enum(diagnostic_color_rule) Init(DIAGNOSTICS_COLOR_NO) -fdiagnostics-color=[never|always|auto] Colorize diagnostics ; Required for these enum values.