From patchwork Tue Aug 18 09:17:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1346723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=dd+O4JM7; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BW50r5YVFz9sRK for ; Tue, 18 Aug 2020 19:17:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35D55385040F; Tue, 18 Aug 2020 09:17:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35D55385040F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597742265; bh=T9ThVWV4XiI5nzo4SYQZSavSDl+k5xK+Ek5ucJqHdH0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dd+O4JM7jU0k4/+o0BOPqMDM3Gxw7+N5qUt7PkLyIbDMkI3Jjdz8oHBrzEc1TtxUn irCk1VOiHblfTcvTmcu1/UjuvQQQ4vWcY3H3GUMkBZJsUuFoBQbDL7nenuWn0fAFXD 5c83Tf8jzvfC0vmSLLUxwXozlxkxU/hZZqmtZy9A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id A02783857C74 for ; Tue, 18 Aug 2020 09:17:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A02783857C74 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07I92FSR150874; Tue, 18 Aug 2020 05:17:38 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3304pek77u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Aug 2020 05:17:38 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 07I92FVI150827; Tue, 18 Aug 2020 05:17:37 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 3304pek77d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Aug 2020 05:17:37 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 07I9F5Sj014724; Tue, 18 Aug 2020 09:17:35 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma05fra.de.ibm.com with ESMTP id 3304bug92e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Aug 2020 09:17:35 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 07I9HXFm28049798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Aug 2020 09:17:33 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6021F4203F; Tue, 18 Aug 2020 09:17:33 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5A614204D; Tue, 18 Aug 2020 09:17:30 +0000 (GMT) Received: from KewenLins-MacBook-Pro.local (unknown [9.200.44.150]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 18 Aug 2020 09:17:30 +0000 (GMT) Subject: [PATCH v2] options: Make --help= to emit values post-overrided To: Segher Boessenkool References: <9eb8a897-e4ee-a80a-4456-1e088ab8f301@linux.ibm.com> <20200806220449.GW6753@gate.crashing.org> <20200807144212.GZ6753@gate.crashing.org> <43e70605-d708-373c-c069-f8bbd3f9a8b0@linux.ibm.com> <28f055af-6793-2efc-edba-6b710238eab0@linux.ibm.com> <20200814220147.GP6753@gate.crashing.org> Message-ID: Date: Tue, 18 Aug 2020 17:17:29 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200814220147.GP6753@gate.crashing.org> Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-18_06:2020-08-18, 2020-08-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 impostorscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008180060 X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, MIME_CHARSET_FARAWAY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Cc: Bill Schmidt , GCC Patches , Joseph Myers Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi Segher, on 2020/8/15 上午6:01, Segher Boessenkool wrote: > Hi! > > On Fri, Aug 14, 2020 at 01:42:24PM +0800, Kewen.Lin wrote: >>> I think personally I'd prefer an option (3): call >>> target_option_override_hook directly in decode_options, >>> if help_option_arguments is nonempty. Like you say, >>> decode_options appears to be the only caller of print_help. >> >> Good idea! The related patch is attached, different from opts_alt{1,2} >> it could still call target_option_override_hook even if we won't call >> print_specific_help eventually for some special cases like lang_mask is >> CL_DRIVER or include_flags is empty. But I think it's fine. > >> --- a/gcc/opts-global.c >> +++ b/gcc/opts-global.c >> @@ -327,8 +327,14 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set, >> unsigned i; >> const char *arg; >> >> - FOR_EACH_VEC_ELT (help_option_arguments, i, arg) >> - print_help (opts, lang_mask, arg); >> + if (!help_option_arguments.is_empty ()) >> + { >> + /* Consider post-overrided values for --help=*. */ > > I'd say > /* Make sure --help=* see the overridden values. */ > This looks better, thanks for polishing! The updated one is attached. BR, Kewen ----- gcc/ChangeLog: * opts-global.c (decode_options): Call target_option_override_hook before it prints for --help=*. diff --git a/gcc/opts-global.c b/gcc/opts-global.c index b1a8429dc3c..69fe2b4f3b1 100644 --- a/gcc/opts-global.c +++ b/gcc/opts-global.c @@ -327,8 +327,14 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set, unsigned i; const char *arg; - FOR_EACH_VEC_ELT (help_option_arguments, i, arg) - print_help (opts, lang_mask, arg); + if (!help_option_arguments.is_empty ()) + { + /* Make sure --help=* see the overridden values. */ + target_option_override_hook (); + + FOR_EACH_VEC_ELT (help_option_arguments, i, arg) + print_help (opts, lang_mask, arg); + } } /* Hold command-line options associated with stack limitation. */