diff mbox series

[v2] options: Make --help= to emit values post-overrided

Message ID c68ff25a-1620-3f7e-0722-26f561fc88d0@linux.ibm.com
State New
Headers show
Series [v2] options: Make --help= to emit values post-overrided | expand

Commit Message

Kewen.Lin Aug. 18, 2020, 9:17 a.m. UTC
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=*.

Comments

Richard Sandiford Aug. 18, 2020, 10:22 a.m. UTC | #1
"Kewen.Lin" <linkw@linux.ibm.com> writes:
> 	* opts-global.c (decode_options): Call target_option_override_hook
> 	before it prints for --help=*.

OK, thanks.

Richard

> 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.  */
diff mbox series

Patch

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.  */