patch: new option --target-help

Chandra Chavva cchavva@cygnus.com
Mon Jul 10 09:47:00 GMT 2000


Hi,

The new option --target-help displays only target specific option of each 
tool. This patch is already approved but not checked in. Now i am going 
to checkin this patch. 

Thanks
Chandra

        * gcc.c: New variable target_help_flag.
        (display_help): Add new option and its description.
        (process_command): Use it.
        * toplev.c (display_target_options): New function.
        (display_help): Use it.
        * cppinit.c (new_pending_directive): Mention --target-help.
	(handle_option): Accept --target-help.

        * as.c (Options): Mention --target-help.
        (parse_args): Accept --target-help.

        * lexsup.c (ld_options): Mention --target-help.
        (parse_args): Accept --target-help.

Index: toplev.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/toplev.c,v
retrieving revision 1.414
diff -p -r1.414 toplev.c
*** toplev.c	2000/06/29 17:46:42	1.414
--- toplev.c	2000/07/10 16:32:40
*************** static void output_lang_identify PARAMS 
*** 167,172 ****
--- 167,173 ----
  #endif
  static void compile_file PARAMS ((const char *));
  static void display_help PARAMS ((void));
+ static void display_target_options PARAMS ((void));
  static void mark_file_stack PARAMS ((void *));
  
  static void decode_d_option PARAMS ((const char *));
*************** display_help ()
*** 3988,3996 ****
  	    printf ("  %-21.21s %s\n", option, description);
  	}
      }
  
!   if (undoc)
!     printf ("\nThere are undocumented %s specific options as well.\n", lang);
  
    if (NUM_ELEM (target_switches) > 1
  #ifdef TARGET_OPTIONS
--- 3997,4012 ----
  	    printf ("  %-21.21s %s\n", option, description);
  	}
      }
+ 
+   display_target_options ();
+ 
+ }
  
! void
! display_target_options ()
! {
!   int undoc;
!   unsigned long  i;
  
    if (NUM_ELEM (target_switches) > 1
  #ifdef TARGET_OPTIONS
*************** display_help ()
*** 4016,4025 ****
  	      undoc = 1;
  	      
  	      if (extra_warnings)
! 		printf ("  -m%-21.21s [undocumented]\n", option);
  	    }
  	  else if (* description != 0)
! 	    doc += printf ("  -m%-21.21s %s\n", option, description);
  	}
        
  #ifdef TARGET_OPTIONS      
--- 4032,4041 ----
  	      undoc = 1;
  	      
  	      if (extra_warnings)
! 		printf ("  -m%-23.23s [undocumented]\n", option);
  	    }
  	  else if (* description != 0)
! 	    doc += printf ("  -m%-23.23s %s\n", option, description);
  	}
        
  #ifdef TARGET_OPTIONS      
*************** display_help ()
*** 4035,4044 ****
  	      undoc = 1;
  	      
  	      if (extra_warnings)
! 		printf ("  -m%-21.21s [undocumented]\n", option);
  	    }
  	  else if (* description != 0)
! 	    doc += printf ("  -m%-21.21s %s\n", option, description);
  	}
  #endif
        if (undoc)
--- 4051,4060 ----
  	      undoc = 1;
  	      
  	      if (extra_warnings)
! 		printf ("  -m%-23.23s [undocumented]\n", option);
  	    }
  	  else if (* description != 0)
! 	    doc += printf ("  -m%-23.23s %s\n", option, description);
  	}
  #endif
        if (undoc)
*************** independent_decode_option (argc, argv, s
*** 4397,4402 ****
--- 4413,4424 ----
    if (!strcmp (arg, "-help"))
      {
        display_help ();
+       exit (0);
+     }
+ 
+   if (!strcmp (arg, "-target-help"))
+     {
+       display_target_options ();
        exit (0);
      }
  
Index: gcc.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/gcc.c,v
retrieving revision 1.272
diff -p -r1.272 gcc.c
*** gcc.c	2000/06/18 02:42:45	1.272
--- gcc.c	2000/07/10 16:32:40
*************** static int print_help_list;
*** 134,139 ****
--- 134,143 ----
  
  static int verbose_flag;
  
+ /* Flag indicating to print target specific command line options. */
+ 
+ static int target_help_flag;
+ 
  /* Flag indicating whether we should report subprocess execution times
     (if this is supported by the system - see pexecute.c).  */
  
*************** static struct compiler default_compilers
*** 660,665 ****
--- 664,670 ----
  		  %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
  		  %{aux-info*} %{Qn:-fno-ident}\
  		  %{--help:--help}\
+ 		  %{--target-help:--target-help} \
                    %{start-sanitize-cygnus CYGNUS LOCAL law/v850}\
  		  %{attr-info*} %{offset-info*}\
                    %{end-sanitize-cygnus END CYGNUS LOCAL}\
*************** static struct compiler default_compilers
*** 691,696 ****
--- 696,702 ----
  		   %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
  		   %{aux-info*} %{Qn:-fno-ident}\
  		   %{--help:--help} \
+ 		   %{--target-help:--target-help} \
                     %{start-sanitize-cygnus CYGNUS LOCAL law/v850}\
  		   %{attr-info*} %{offset-info*}\
                     %{end-sanitize-cygnus END CYGNUS LOCAL}\
*************** display_help ()
*** 2905,2910 ****
--- 2911,2917 ----
    printf ("  -c                       Compile and assemble, but do not link\n");
    printf ("  -o <file>                Place the output into <file>\n");
    printf ("  -x <language>            Specify the language of the following input files\n");
+   printf ("  --target-help            Display target specific command line options\n");
    printf ("                            Permissable languages include: c c++ assembler none\n");
    printf ("                            'none' means revert to the default behaviour of\n");
    printf ("                            guessing the language based on the file's extension\n");
*************** process_command (argc, argv)
*** 3189,3194 ****
--- 3196,3213 ----
  	  add_assembler_option ("--help", 6);
  	  add_linker_option ("--help", 6);
  	}
+       else if (!strcmp (argv[i], "-ftarget-help"))
+         {
+           /* translate_options () has turned --target-help into -ftarget-help. */
+           target_help_flag = 1;
+           /* We will be passing a dummy file on to the sub-processes.  */
+           n_infiles++;
+           n_switches++;
+ 
+           add_preprocessor_option ("--target-help", 13);
+           add_assembler_option ("--target-help", 13);
+           add_linker_option ("--target-help", 13);
+         }
        else if (! strcmp (argv[i], "-pass-exit-codes"))
  	{
  	  pass_exit_codes = 1;
*************** process_command (argc, argv)
*** 3578,3583 ****
--- 3597,3618 ----
  	;
        else if (! strcmp (argv[i], "-print-multi-directory"))
  	;
+       else if (! strcmp (argv[i], "-ftarget-help"))
+         {
+           /* Create a dummy input file, so that we can pass --target-help
+              on to the various sub-processes.  */
+           infiles[n_infiles].language = "c";
+           infiles[n_infiles++].name   = "target-dummy";
+ 
+           /* Preserve the -target-help switch so that it can be caught by the
+              cc1 spec string.  */
+           switches[n_switches].part1     = "--target-help";
+           switches[n_switches].args      = 0;
+           switches[n_switches].live_cond = 0;
+           switches[n_switches].validated = 0;
+ 
+           n_switches++;
+         }
        else if (strcmp (argv[i], "-fhelp") == 0)
  	{
  	  if (verbose_flag)
*************** main (argc, argv)
*** 5566,5571 ****
--- 5601,5615 ----
        else
  	printf ("%s\n", multilib_dir);
        return (0);
+     }
+ 
+   if (target_help_flag)
+     {
+       /* Print if any target specific options.*/
+ 
+       /* We do not exit here. Instead we have created a fake input file
+        called 'target-dummy' which needs to be compiled, and we pass this
+        on to the various sub-processes, along with the --target-help switch. */
      }
  
    if (print_help_list)
Index: as.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/as.c,v
retrieving revision 1.134
diff -p -r1.134 as.c
*** as.c	2000/05/29 16:47:31	1.134
--- as.c	2000/07/10 16:33:02
*************** Options:\n\
*** 272,277 ****
--- 272,279 ----
    fprintf (stream, _("\
    --help                  show this message and exit\n"));
    fprintf (stream, _("\
+   --target-help           show target specific options\n"));
+   fprintf (stream, _("\
    -I DIR                  add DIR to search list for .include directives\n"));
    fprintf (stream, _("\
    -J                      don't warn about signed overflow\n"));
*************** parse_args (pargc, pargv)
*** 428,434 ****
  #define OPTION_WARN (OPTION_STD_BASE + 18)
      {"warn", no_argument, NULL, OPTION_WARN},
  #define OPTION_WARN_FATAL (OPTION_STD_BASE + 19)
!     {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
    };
  
    /* Construct the option lists from the standard list and the
--- 430,438 ----
  #define OPTION_WARN (OPTION_STD_BASE + 18)
      {"warn", no_argument, NULL, OPTION_WARN},
  #define OPTION_WARN_FATAL (OPTION_STD_BASE + 19)
!     {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
! #define OPTION_TARGET_HELP (OPTION_STD_BASE + 20)
!     {"target-help", no_argument, NULL, OPTION_TARGET_HELP}
    };
  
    /* Construct the option lists from the standard list and the
*************** parse_args (pargc, pargv)
*** 497,502 ****
--- 501,510 ----
  	  new_argv[new_argc++] = optarg;
  	  new_argv[new_argc] = NULL;
  	  break;
+ 
+ 	case OPTION_TARGET_HELP:
+           md_show_usage (stdout);
+           exit (EXIT_SUCCESS);
  
  	case OPTION_HELP:
  	  show_usage (stdout);
Index: lexsup.c
===================================================================
RCS file: /cvs/cvsfiles/devo/ld/lexsup.c,v
retrieving revision 1.113
diff -p -r1.113 lexsup.c
*** lexsup.c	2000/05/29 16:49:23	1.113
--- lexsup.c	2000/07/10 16:33:13
*************** int parsing_defsym = 0;
*** 95,101 ****
  #define OPTION_SORT_COMMON		(OPTION_SONAME + 1)
  #define OPTION_STATS			(OPTION_SORT_COMMON + 1)
  #define OPTION_SYMBOLIC			(OPTION_STATS + 1)
! #define OPTION_TASK_LINK		(OPTION_SYMBOLIC + 1)
  #define OPTION_TBSS			(OPTION_TASK_LINK + 1)
  #define OPTION_TDATA			(OPTION_TBSS + 1)
  #define OPTION_TTEXT			(OPTION_TDATA + 1)
--- 95,102 ----
  #define OPTION_SORT_COMMON		(OPTION_SONAME + 1)
  #define OPTION_STATS			(OPTION_SORT_COMMON + 1)
  #define OPTION_SYMBOLIC			(OPTION_STATS + 1)
! #define OPTION_TARGET_HELP		(OPTION_SYMBOLIC + 1)
! #define OPTION_TASK_LINK		(OPTION_TARGET_HELP + 1)
  #define OPTION_TBSS			(OPTION_TASK_LINK + 1)
  #define OPTION_TDATA			(OPTION_TBSS + 1)
  #define OPTION_TTEXT			(OPTION_TDATA + 1)
*************** static const struct ld_option ld_options
*** 340,345 ****
--- 341,348 ----
        '\0', N_("COUNT"), N_("Split output sections every COUNT relocs"), TWO_DASHES },
    { {"stats", no_argument, NULL, OPTION_STATS},
        '\0', NULL, N_("Print memory usage statistics"), TWO_DASHES },
+   { {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
+       '\0', NULL, N_("Display target specific options"), TWO_DASHES },
    { {"task-link", required_argument, NULL, OPTION_TASK_LINK},
        '\0', N_("SYMBOL"), N_("Do task level linking"), TWO_DASHES },
    { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
*************** parse_args (argc, argv)
*** 906,911 ****
--- 909,917 ----
  	    optarg2[-1] = '=';
  	  }
  	  break;
+ 	case OPTION_TARGET_HELP:
+ 	  /* Mention any target specific options. */
+ 	  exit (0);
  	case OPTION_TBSS:
  	  set_section_start (".bss", optarg);
  	  break;
Index: cppinit.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cppinit.c,v
retrieving revision 1.21
diff -p -r1.21 cppinit.c
*** cppinit.c	2000/06/26 16:14:50	1.21
--- cppinit.c	2000/07/10 16:36:57
*************** new_pending_directive (pend, text, handl
*** 1105,1110 ****
--- 1105,1111 ----
    DEF_OPT("$",                        0,      OPT_dollar)                     \
    DEF_OPT("+",                        0,      OPT_plus)                       \
    DEF_OPT("-help",                    0,      OPT__help)                      \
+   DEF_OPT("-target-help",             0,      OPT_target__help)		      \
    DEF_OPT("-version",                 0,      OPT__version)                   \
    DEF_OPT("A",                        no_ass, OPT_A)                          \
    DEF_OPT("C",                        0,      OPT_C)                          \
*************** handle_option (pfile, argc, argv)
*** 1372,1377 ****
--- 1373,1382 ----
  	  print_help ();
  	  exit (0);  /* XXX */
  	  break;
+ 	case OPT_target__help:
+ 	  /* Print if any target specific options. */
+ 	  exit (0);
+ 	  break;
  	case OPT__version:
  	  fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
  	  exit (0);  /* XXX */
*************** Switches:\n\
*** 1894,1899 ****
--- 1899,1905 ----
    -remap                    Remap file names when including files.\n\
    --version                 Display version information\n\
    -h or --help              Display this information\n\
+   --target-help		    Display target specific command line options\n\
  "), stdout);
    /* start-sanitize-obscured-headers */
    fputs ("\
Index: invoke.texi
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/invoke.texi,v
retrieving revision 1.335
diff -p -r1.335 invoke.texi
*** invoke.texi	2000/06/24 20:03:51	1.335
--- invoke.texi	2000/07/10 16:37:40
*************** in the following sections.
*** 93,99 ****
  @item Overall Options
  @xref{Overall Options,,Options Controlling the Kind of Output}.
  @smallexample
! -c  -S  -E  -o @var{file}  -pipe  -pass-exit-codes  -v  --help  -x @var{language}
  @end smallexample
  
  @item C Language Options
--- 93,99 ----
  @item Overall Options
  @xref{Overall Options,,Options Controlling the Kind of Output}.
  @smallexample
! -c  -S  -E  -o @var{file}  -pipe  -pass-exit-codes  -v  --help  --target-help  -x @var{language}
  @end smallexample
  
  @item C Language Options
*************** invoked by @code{gcc}, so that they can 
*** 696,701 ****
--- 696,705 ----
  they accept.  If the @code{-W} option is also specified then command
  line options which have no documentation associated with them will also
  be displayed.
+ 
+ @item --target-help
+ Print (on the standard output) a description of target specific command
+ line options for each tool.
  @end table
  
  @node Invoking G++





More information about the Gcc-patches mailing list