To add a new command-line option to
g77, first decide
what kind of option you wish to add.
gcc documentation for one
or more options that is most closely like the one you want to add
(in terms of what kind of effect it has, and so on) to
help clarify its nature.
gcc, but they apply only when compiling Fortran programs.
Fortran options are listed in the file
which is used during the build of
build a list of all options that are accepted by
at least one language's compiler.
This list goes into the `lang_options' array
in `gcc/toplev.c', which uses this array to
determine whether a particular option should be
offered to the linked-in front end for processing
by calling `lang_option_decode', which, for
g77, is in `gcc/f/com.c' and just
If the linked-in front end "rejects" a particular option passed to it, `toplev.c' just ignores the option, because some language's compiler is willing to accept it.
This allows commands like `gcc -fno-asm foo.c bar.f'
to work, even though Fortran compilation does
not currently support the `-fno-asm' option;
even though the
f771 version of `lang_decode_option'
rejects `-fno-asm', `toplev.c' doesn't
produce a diagnostic because some other language (C)
does accept it.
This also means that commands like `g77 -fno-asm foo.f' yield no diagnostics, despite the fact that no phase of the command was able to recognize and process `-fno-asm'---perhaps a warning about this would be helpful if it were possible.
Code that processes Fortran options is found in `gcc/f/top.c', function `ffe_decode_option'. This code needs to check positive and negative forms of each option.
The defaults for Fortran options are set in their
global definitions, also found in `gcc/f/top.c'.
Many of these defaults are actually macros defined
in `gcc/f/target.h', since they might be
However, since, in practice, GNU compilers
should behave the same way on all configurations
(especially when it comes to language constructs),
the practice of setting defaults in `target.h'
is likely to be deprecated and, ultimately, stopped
in future versions of
Accessor macros for Fortran options, used by code
g77 FFE, are defined in `gcc/f/top.h'.
Compiler options are listed in `gcc/toplev.c' in the array `f_options'. An option not listed in `lang_options' is looked up in `f_options' and handled from there.
The defaults for compiler options are set in the global definitions for the corresponding variables, some of which are in `gcc/toplev.c'.
You can set different defaults for Fortran-oriented
or Fortran-reticent compiler options by changing
f771 handles the `-fset-g77-defaults'
option, which is always provided as the first option when
This code is in `ffe_decode_options' in `gcc/f/top.c'. Have it change just the variables that you want to default to a different setting for Fortran compiles compared to compiles of other languages.
The `-fset-g77-defaults' option is passed to
automatically because of the specification information
kept in `gcc/f/lang-specs.h'.
This file tells the
gcc command how to recognize,
in this case, Fortran source files (those to be preprocessed,
and those that are not), and further, how to invoke the
appropriate programs (including
f771) to process
those source files.
It is in `gcc/f/lang-specs.h' that `-fset-g77-defaults', `-fversion', and other options are passed, as appropriate, even when the user has not explicitly specified them. Other "internal" options such as `-quiet' also are passed via this mechanism.
Go to the first, previous, next, last section, table of contents.