From: Jeffrey D. Oldham Date: Wed, 21 Feb 2001 19:54:18 +0000 (+0000) Subject: gcc.c: Add comment explaining how to add a command-line option. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e889f41a2b4cbf5c292e20c647beecc9047bd3b2;p=gcc.git gcc.c: Add comment explaining how to add a command-line option. 2001-02-21 Jeffrey D. Oldham * gcc.c: Add comment explaining how to add a command-line option. Add title to specs language comment. From-SVN: r39960 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c0ee3c38808..569002a0a14 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2001-02-21 Jeffrey D. Oldham + + * gcc.c: Add comment explaining how to add a command-line option. + Add title to specs language comment. + 2001-02-21 Jeffrey Oldham * gcc.c (cc1_options): Add "-param". diff --git a/gcc/gcc.c b/gcc/gcc.c index e77db507511..f4010431f81 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -32,6 +32,44 @@ CC recognizes how to compile each input file by suffixes in the file names. Once it knows which kind of compilation to perform, the procedure for compilation is specified by a string called a "spec". */ +/* A Short Introduction to Adding a Command-Line Option. + + Before adding a command-line option, consider if it is really + necessary. Each additional command-line option adds complexity and + is difficult to remove in subsequent versions. + + In the following, consider adding the command-line argument + `--bar'. + + 1. Each command-line option is specified in the specs file. The + notation is described below in the comment entitled "The Specs + Language". Read it. + + 2. In this file, add an entry to "option_map" equating the long + `--' argument version and any shorter, single letter version. Read + the comments in the declaration of "struct option_map" for an + explanation. Do not omit the first `-'. + + 3. Look in the "specs" file to determine which program or option + list should be given the argument, e.g., "cc1_options". Add the + appropriate syntax for the shorter option version to the + corresponding "const char *" entry in this file. Omit the first + `-' from the option. For example, use `-bar', rather than `--bar'. + + 4. If the argument takes an argument, e.g., `--baz argument1', + modify either DEFAULT_SWITCH_TAKES_ARG or + DEFAULT_WORD_SWITCH_TAKES_ARG in this file. Omit the first `-' + from `--baz'. + + 5. Document the option in this file's display_help(). If the + option is passed to a subprogram, modify its corresponding + function, e.g., cppinit.c:print_help() or toplev.c:display_help(), + instead. + + 6. Compile and test. Make sure that your new specs file is being + read. For example, use a debugger to investigate the value of + "specs_file" in main(). */ + #include "config.h" #include "system.h" #include @@ -272,7 +310,9 @@ static void init_gcc_specs PARAMS ((struct obstack *, const char *, const char *)); -/* Specs are strings containing lines, each of which (if not blank) +/* The Specs Language + +Specs are strings containing lines, each of which (if not blank) is made up of a program name, and arguments separated by spaces. The program name must be exact and start from root, since no path is searched and it is unreliable to depend on the current working directory.