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

Reply via email to