aboutsummaryrefslogtreecommitdiff
path: root/gcc/README.g77
blob: f22f1799c35e53578e99a3705ef8cf6ee9a4b94f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
1998-08-11

This directory contains the egcs variant of version 0.5.24 of the
GNU Fortran compiler (g77).  The GNU Fortran compiler is free software.
See the file COPYING.g77 for copying permission.

Currently, two variants of g77 exist.  One is the Free Software Foundation
(FSF) variant.  The other is the egcs variant.  As of egcs version 1.1,
these variants are kept fairly similar in most respects.  Pertinent
differences, such as the layout of the source code, are specified below.

Below, `[FSF]' denotes information applicable to only the FSF variant of
g77, while `[egcs]' denotes egcs-only information.


* IMPORTANT: Things you *must* do (or avoid) are marked with a * at the
  beginning of the line in this file!!!


The email address to which bugs are to be reported is either
[FSF] <fortran@gnu.org> or [egcs] <egcs-bugs@cygnus.com>.

* *DO NOT* send any email (reporting bugs, asking questions, etc.) to
  either of these addresses without *first* reading the g77 documentation.
  Use `info', Info mode in GNU Emacs, or a text viewer such as `more' to
  do this.

  The g77 documentation is in the source files named `g77.info',
  `g77.info-1', `g77.info-2', and so on in the `f' subdirectory.  If these
  files are not present or you can't find them, contact the person or
  organization that put together the g77 distribution you are using (probably
  not the FSF or egcs), or ask your system administrator for help.


This README applies to only the g77-specific portions of the source-code
tree that contains it.  These portions include:

  -  The README.g77 and [FSF] COPYING.g77 files, in this directory, "this
     directory" being [FSF] the top-level directory containing a g77
     distribution or [egcs] the gcc/ subdirectory of an egcs distribution.

  -  The g77 front end, in the f/ subdirectory of this directory.

  -  The libg2c library, in [FSF] the f/runtime/ subdirectory of this
     directory or [egcs] the libf2c/ directory under the top-level
     directory of the egcs distribution.


* To build g77, you must have a source distribution of [FSF] gcc
  version 2.8 or [egcs] egcs version 1.1.  Do not attempt to use
  any other version of gcc or egcs, because this version of g77 is
  designed to work with only those versions.

  Note that you must have *source* copies of the gcc or egcs distribution!
  You cannot build g77 just using binaries of gcc or egcs.  Also, unless
  you are an expert, avoid using any distribution of gcc or egcs not
  identical to the ones distributed by the FSF and Cygnus Support,
  respectively.  The primary FSF distribution site is:

    <ftp://ftp.gnu.org/pub/gnu/>

  The primary egcs distribution site is:

    <ftp://ftp.cygnus.com/pub/egcs/>

  Both of these sites have approved mirror sites from which valid
  distributions also may be obtained.

* Do not attempt to combine the egcs version of g77 with the FSF
  gcc distribution, or the FSF version of g77 with the egcs gcc
  distribution.  Although the differences are minor, they might
  be sufficient to prevent g77 from building properly, or from
  working properly if the build appears to succeed.

[FSF] g77 is distributed as g77-<version>/f/ so that unpacking the g77
distribution is done in the normal GNU way, resulting in a directory having
the version number in the name.  However, to build g77, the g77 distribution
must be merged with an appropriate gcc distribution, normally in a gcc
source directory, before configuring, building, and installing g77.

[FSF] If you have just unpacked the g77 distribution, before proceeding,
you must merge the contents of the g77 distribution with the appropriate
gcc distribution on your system.

* [FSF] Read and follow the instructions in f/INSTALL that
  explain how to merge a g77 source directory into a gcc source
  directory.  You can use Info to read the same installation
  instructions via:

    info -f f/g77.info -n Unpacking

[FSF] The resulting directory layout includes the following, where gcc/
might be a link to, for example, gcc-2.8.1/:

    gcc/                    Non-g77 files in gcc
    gcc/COPYING.g77         A copy of the GPL, under which g77 is licensed
    gcc/README.g77          This file
    gcc/f/                  GNU Fortran front end
    gcc/f/runtime/          libg2c configuration and g2c.h file generation
    gcc/f/runtime/libF77/   Non-I/O portion of libg2c
    gcc/f/runtime/libI77/   I/O portion of libg2c
    gcc/f/runtime/libU77/   Additional interfaces to libc for libg2c

[FSF] Applying g77 patches in the form of .diff files is done by typing
`patch -p1 -d gcc' (where gcc/ contains the f/ subdirectory).  That is,
g77 patches are distributed in the same form, and at the same directory
level, as patches to the gcc distribution.  (Note: make sure you're
using GNU patch, version 2.5 or later!  Other versions of patch
have trouble with g77-related patches.)

[egcs] The egcs version of g77 is distributed already merged with
the rest of egcs (such as the gcc back end).

[egcs] The resulting directory layout includes the following, where egcs/
might be a link to, for example, egcs-1.1/:

    egcs/gcc/               Non-g77 files in gcc
    egcs/gcc/README.g77     This file
    egcs/gcc/f/             GNU Fortran front end
    egcs/libf2c/            libg2c configuration and g2c.h file generation
    egcs/libf2c/libF77/     Non-I/O portion of libg2c
    egcs/libf2c/libI77/     I/O portion of libg2c
    egcs/libf2c/libU77/     Additional interfaces to libc for libg2c

[egcs] Applying g77-specific patches to egcs is done the same way as
applying other egcs patches.


Below, `libf2c/' shall denote [FSF] gcc/f/runtime/ or [egcs] egcs/libf2c/,
while `f/' shall denote [FSF] the rest of gcc/f/ or [egcs] egcs/gcc/f/.


Components of note in g77 are described below.

f/ as a whole contains the program GNU Fortran (g77), while libf2c/
contains a portion of the separate program f2c.  Note: The libf2c
code is not part of the program g77, just distributed with it.

f/ contains text files that document the Fortran compiler, source
files for the GNU Fortran Front End (FFE), and some other stuff.
The g77 compiler code is placed in f/ because it, along with its contents,
is designed to be a subdirectory of a GNU CC (gcc) source directory, gcc/,
which is structured so that language-specific front ends can be "dropped
in" as subdirectories.  The C++ front end (g++), is an example of this --
it resides in the cp/ subdirectory.  Note that the C front end (also
referred to as gcc) is an exception to this, as its source files reside
in the gcc/ directory itself.

libf2c/ contains the run-time libraries for the f2c program, also used
by g77.  These libraries normally referred to collectively as libf2c.
When built as part of g77, libf2c is installed under the name libg2c to avoid
conflict with any existing version of libf2c, and thus is often referred
to as libg2c when the g77 version is specifically being referred to.

The netlib version of libf2c/ contains two distinct libraries, libF77 and
libI77, each in their own subdirectories.  In g77, this distinction is not
made, beyond maintaining the subdirectory structure in the source-code tree.

libf2c/ is not part of the program g77, just distributed with it.  It
contains files not present in the official (netlib) version of libf2c,
and also contains some minor changes made from libf2c, to fix some bugs,
and to facilitate automatic configuration, building, and installation of
libf2c (as libg2c) for use by g77 users.

* See libf2c/README for more information, including licensing conditions
  governing distribution of programs containing code from libg2c.

libg2c, g77's version of libf2c, adds Dave Love's implementation of
libU77, in the libf2c/libU77/ directory.  This library is distributed
under the GNU Library General Public License (LGPL) -- see the
file libf2c/libU77/COPYING.LIB for more information, as this license
governs distribution conditions for programs containing code from
this portion of the library.


Files of note in g77 are described below.

f/BUGS lists some important bugs known to be in g77.  Or:

  info -f f/g77.info -n "Actual Bugs"

f/ChangeLog lists recent changes to g77 internals.

libf2c/ChangeLog lists recent changes to libg2c internals.

[FSF] f/INSTALL describes how to build and install GNU Fortran.  Or:

  info -f f/g77.info -n Installation

f/NEWS contains the per-release changes.  These include the user-visible
changes described under "Changes" in the g77 documentation, plus internal
changes of import.  Or:

  info -f f/g77.info -n News

* All users of g77 (not just installers) should read f/g77.info*
  as well, using the `more' command if neither the `info' command,
  nor GNU Emacs (with its Info mode), are available, or if they
  aren't yet accustomed to using these tools.  Read f/BUGS and f/NEWS
  plus, if you are planning on building or installing the FSF version
  of g77, f/INSTALL, at the very least!  All of these files are
  readable as "plain text" files.

* Also see <ftp://alpha.gnu.org/g77.plan> for up-to-date information
  regarding g77 bug reports, known bugs, bug-fixes, and new versions.


The rest of this file is of note to only those who wish to
debug, modify, or test the FFE (in conjunction with the gcc back end).

If you want to explore the FFE code, which lives entirely in f/, here
are a few clues.  The file g77spec.c contains the g77-specific source code
for the `g77' command only -- this just forms a variant of the `gcc'
command, so, just as the `gcc' command itself does not contain
the C front end, the `g77' command does not contain the Fortran front
end (FFE).  The FFE code ends up in an executable named `f771', which
does the actual compiling, so it contains the FFE plus the gcc back end
(the latter to do most of the optimization, and the code generation).

The file parse.c is the source file for main() for a stand-alone FFE and
yyparse() for f771.  (Stand-alone building of the FFE doesn't work these days.)
The file top.c contains the top-level FFE function ffe_file and it (along
with top.h) define all ffe_[a-z].*, ffe[A-Z].*, and FFE_[A-Za-z].* symbols.
The file fini.c is a main() program that is used when building the FFE to
generate C header and source files for recognizing keywords.  The files
malloc.c and malloc.h comprise a memory manager that defines all
malloc_[a-z].*, malloc[A-Z].*, and MALLOC_[A-Za-z].* symbols.  All other
modules named <xyz> are comprised of all files named <xyz>*.<ext> and
define all ffe<xyz>_[a-z].*, ffe<xyz>[A-Z].*, and FFE<XYZ>_[A-Za-z].* symbols.
If you understand all this, congratulations -- it's easier for me to remember
how it works than to type in these grep patterns (such as they are).  But it
does make it easy to find where a symbol is defined -- for example,
the symbol "ffexyz_set_something" would be defined in xyz.h and implemented
there (if it's a macro) or in xyz.c.

The "porting" files of note currently are: proj.h, which defines the
"language" used by all the other source files (the language being
Standard C plus some useful things like ARRAY_SIZE and such) -- change
this file when you find your system doesn't properly define a Standard C
macro or function, for example; target.h and target.c, which describe
the target machine in terms of what data types are supported, how they are
denoted (what C type does an INTEGER*8 map to, for example), how to convert
between them, and so on (though as of 0.5.3, more and more of this information
is being dynamically configured by ffecom_init_0); com.h and com.c, which
interface to the target back end (currently only FFE stand-alone and the GBE);
ste.c, which contains code for implementing recognized executable statements
in the target back end (again currently either FFE or GBE); src.h and src.c,
which describe information on the format(s) of source files (such as whether
they are never to be processed as case-insensitive with regard to Fortran
keywords); and proj.c, which contains whatever code is needed to support
the language defined by proj.h.

If you want to debug the f771 executable, for example if it crashes,
note that the global variables "lineno" and "input_filename" are set
to reflect the current line being read by the lexer during the first-pass
analysis of a program unit and to reflect the current line being
processed during the second-pass compilation of a program unit.  If
an invocation of the function ffestd_exec_end() is on the stack,
the compiler is in the second pass, otherwise it is in the first.
(This information might help you reduce a test case and/or work around
a bug in g77 until a fix is available.)

Any questions or comments on these topics?  Read the g77 documentation!