[PATCH/RFC] options: Make --help= to emit values post-overrided

Kewen.Lin linkw@linux.ibm.com
Thu Aug 6 12:37:23 GMT 2020


When I was working to update patch as Richard's review comments
here https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551474.html,
I noticed that the options "-Q --help=params" don't show the final values
after target option overriding, instead it emits the default values in
params.opt (without any explicit param settings).

I guess it's more meaningful to get it to emit values post-overrided,
to avoid possible confusion for users.  Does it make sense?
Or are there any concerns?

btw, not sure whether it's a good idea to move target_option_override_hook
call into print_specific_help and use one function local static
variable to control it's called once for all kinds of help dumping
(possible combination), then can remove the calls in function 



	* opts-global.c (decode_options): Adjust call to print_help.
	* opts.c (print_help): Add one function point argument
	target_option_override_hook and call it before print_specific_help.
	* opts.h (print_help): Add one more argument to function declare.

-------------- next part --------------
diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index b1a8429dc3c..ec960c87c9a 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -328,7 +328,7 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
   const char *arg;
   FOR_EACH_VEC_ELT (help_option_arguments, i, arg)
-    print_help (opts, lang_mask, arg);
+    print_help (opts, lang_mask, arg, target_option_override_hook);
 /* Hold command-line options associated with stack limitation.  */
diff --git a/gcc/opts.c b/gcc/opts.c
index 499eb900643..df184f909e6 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2017,7 +2017,8 @@ check_alignment_argument (location_t loc, const char *flag, const char *name)
 print_help (struct gcc_options *opts, unsigned int lang_mask,
-	    const char *help_option_argument)
+	    const char *help_option_argument,
+	    void (*target_option_override_hook) (void))
   const char *a = help_option_argument;
   unsigned int include_flags = 0;
@@ -2145,9 +2146,11 @@ print_help (struct gcc_options *opts, unsigned int lang_mask,
   if (!(include_flags & CL_PARAMS))
     exclude_flags |= CL_PARAMS;
-  if (include_flags)
+  if (include_flags) {
+    target_option_override_hook ();
     print_specific_help (include_flags, exclude_flags, 0, opts,
+  }
 /* Handle target- and language-independent options.  Return zero to
diff --git a/gcc/opts.h b/gcc/opts.h
index 8f594b46e33..9a837305af1 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -419,8 +419,9 @@ extern bool target_handle_option (struct gcc_options *opts,
 extern void finish_options (struct gcc_options *opts,
 			    struct gcc_options *opts_set,
 			    location_t loc);
-extern void print_help (struct gcc_options *opts, unsigned int lang_mask, const
-			char *help_option_argument);
+extern void print_help (struct gcc_options *opts, unsigned int lang_mask,
+			const char *help_option_argument,
+			void (*target_option_override_hook) (void));
 extern void default_options_optimization (struct gcc_options *opts,
 					  struct gcc_options *opts_set,
 					  struct cl_decoded_option *decoded_options,

More information about the Gcc-patches mailing list