1 @c Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
2 @c This is part of the G77 manual.
3 @c For copying conditions, see the file g77.texi.
5 @set last-update-install 2000-11-05
10 @chapter Installing GNU Fortran
11 @cindex installing, GNU Fortran
13 The following information describes how to install @code{g77}.
15 Note that, for users of the @value{which-g77} version of @code{g77},
16 much of the information is obsolete,
17 and is superseded by the
18 @value{which-gcc} installation procedures.
19 Such information is accordingly omitted and flagged as such.
22 @emph{Warning:} The information below is still under development,
23 and might not accurately reflect the @code{g77} code base
24 of which it is a part.
25 Efforts are made to keep it somewhat up-to-date,
26 but they are particularly concentrated
27 on any version of this information
28 that is distributed as part of a @emph{released} @code{g77}.
30 In particular, while this information is intended to apply to
31 the @value{which-g77} version of @code{g77},
32 only an official @emph{release} of that version
33 is expected to contain documentation that is
34 most consistent with the @code{g77} product in that version.
37 The following information was last updated on @value{last-update-install}:
40 * Prerequisites:: Make sure your system is ready for @code{g77}.
41 * Problems Installing:: Known trouble areas.
42 * Settings:: Changing @code{g77} internals before building.
43 * Quick Start:: The easier procedure for non-experts.
44 * Complete Installation:: For experts, or those who want to be: the details.
45 * Distributing Binaries:: If you plan on distributing your @code{g77}.
49 @section Prerequisites
52 For users of the @value{which-g77} version of @code{g77},
53 this information is superseded by the
54 @value{which-gcc} installation instructions.
56 @node Problems Installing
57 @section Problems Installing
58 @cindex problems installing
59 @cindex installation problems
61 This is a list of problems (and some apparent problems which don't
62 really mean anything is wrong) that show up when configuring,
63 building, installing, or porting GNU Fortran.
65 @xref{Installation Problems,,,gcc,Using and Porting GNU CC},
66 for more information on installation problems that can afflict
67 either @code{gcc} or @code{g77}.
70 * General Problems:: Problems afflicting most or all systems.
71 * System-specific Problems:: Problems afflicting particular systems.
72 * Cross-compiler Problems:: Problems afflicting cross-compilation setups.
75 @node General Problems
76 @subsection General Problems
78 These problems can occur on most or all systems.
81 * GNU C Required:: Why even ANSI C is not enough.
82 * Patching GNU CC:: Why @code{gcc} needn't be patched.
83 * Building GNU CC Necessary:: Why you can't build @emph{just} Fortran.
84 * Missing strtoul or bsearch:: When linking @code{f771} fails.
85 * Cleanup Kills Stage Directories:: For @code{g77} developers.
86 * LANGUAGES Macro Ignored:: Sometimes @code{LANGUAGES} is ignored.
90 @subsubsection GNU C Required
91 @cindex GNU C required
92 @cindex requirements, GNU C
94 Compiling @code{g77} requires GNU C, not just ANSI C.
96 be very hard (just tedious), but the code using GNU extensions to
97 the C language is expected to be rewritten for 0.6 anyway,
98 so there are no plans for an interim fix.
100 This requirement does not mean you must already have @code{gcc}
101 installed to build @code{g77}.
102 As long as you have a working C compiler, you can use a
103 ``bootstrap'' build to automate the process of first building
104 @code{gcc} using the working C compiler you have, then building
105 @code{g77} and rebuilding @code{gcc} using that just-built @code{gcc},
108 @node Patching GNU CC
109 @subsubsection Patching GNU CC
113 @code{g77} no longer requires application of a patch file
114 to the @code{gcc} compiler tree.
115 In fact, no such patch file is distributed with @code{g77}.
116 This is as of version 0.5.23
117 and @code{egcs} version 1.0.
119 @node Building GNU CC Necessary
120 @subsubsection Building GNU CC Necessary
121 @cindex @code{gcc}, building
124 It should be possible to build the runtime without building @code{cc1}
125 and other non-Fortran items, but, for now, an easy way to do that
126 is not yet established.
128 @node Missing strtoul or bsearch
129 @subsubsection Missing strtoul or bsearch
134 @cindex undefined reference (_bsearch)
135 @cindex undefined reference (_strtoul)
136 @cindex f771, linking error for
137 @cindex linking error for f771
138 @cindex @code{ld}, error linking f771
139 @cindex @code{ld}, can't find _bsearch
140 @cindex @code{ld}, can't find _strtoul
143 This information does not apply to
144 the @value{which-g77} version of @code{g77},
146 @node Cleanup Kills Stage Directories
147 @subsubsection Cleanup Kills Stage Directories
148 @cindex stage directories
151 It'd be helpful if @code{g77}'s @file{Makefile.in} or @file{Make-lang.in}
152 would create the various @file{stage@var{n}} directories and their
153 subdirectories, so developers and expert installers wouldn't have to
154 reconfigure after cleaning up.
156 That help has arrived as of version 0.5.23 of @code{g77}
157 and version 1.1 of @code{egcs}.
158 Configuration itself no longer creates any particular directories
159 that are unique to @code{g77}.
160 The build procedures in @file{Make-lang.in} take care of
163 @node LANGUAGES Macro Ignored
164 @subsubsection LANGUAGES Macro Ignored
165 @cindex @code{LANGUAGES} macro ignored
166 @cindex ignoring @code{LANGUAGES} macro
168 Prior to version 0.5.23 of @code{g77}
169 and version 1.1 of @code{egcs},
170 @code{g77} would sometimes ignore
171 the absence of @code{f77} and @code{F77} in the
172 @code{LANGUAGES} macro definition used for the
173 @code{make} command being processed.
175 As of @code{g77} version 0.5.23
176 and @code{egcs} version 1.1,
177 @code{g77} now obeys this macro
178 in all relevant situations.
180 However, in versions of @code{gcc} through 2.8.1,
181 non-@code{g77} portions of @code{gcc},
183 are known to go ahead and perform various
184 language-specific activities when their
185 respective language strings do not appear
186 in the @code{LANGUAGES} macro in effect
187 during that invocation of @code{make}.
189 It is expected that these remaining problems will
190 be fixed in a future version of @code{gcc}.
192 @node System-specific Problems
193 @subsection System-specific Problems
196 A linker bug on some versions of AIX 4.1 might prevent building
197 when @code{g77} is built within @code{gcc}.
200 @node Cross-compiler Problems
201 @subsection Cross-compiler Problems
202 @cindex cross-compiler, problems
204 @code{g77} has been in alpha testing since September of
205 1992, and in public beta testing since February of 1995.
206 Alpha testing was done by a small number of people worldwide on a fairly
207 wide variety of machines, involving self-compilation in most or
209 Beta testing has been done primarily via self-compilation,
210 but in more and more cases, cross-compilation (and ``criss-cross
211 compilation'', where a version of a compiler is built on one machine
212 to run on a second and generate code that runs on a third) has
213 been tried and has succeeded, to varying extents.
215 Generally, @code{g77} can be ported to any configuration to which
216 @code{gcc}, @code{f2c}, and @code{libf2c} can be ported and made
217 to work together, aside from the known problems described in this
219 If you want to port @code{g77} to a particular configuration,
220 you should first make sure @code{gcc} and @code{libf2c} can be
221 ported to that configuration before focusing on @code{g77}, because
222 @code{g77} is so dependent on them.
224 Even for cases where @code{gcc} and @code{libf2c} work,
225 you might run into problems with cross-compilation on certain machines,
230 There is one known bug
231 (a design bug to be fixed in 0.6) that prevents configuration of
232 @code{g77} as a cross-compiler in some cases,
233 though there are assumptions made during
234 configuration that probably make doing non-self-hosting builds
235 a hassle, requiring manual intervention.
238 @code{gcc} might still have some trouble being configured
239 for certain combinations of machines.
240 For example, it might not know how to handle floating-point
244 Improvements to the way @code{libg2c} is built could make
245 building @code{g77} as a cross-compiler easier---for example,
246 passing and using @samp{$(LD)} and @samp{$(AR)} in the appropriate
248 (This was improved in the @code{egcs} version of @code{g77},
249 especially as of version 1.1.)
252 There are still some challenges putting together the right
253 run-time libraries (needed by @code{libg2c}) for a target
254 system, depending on the systems involved in the configuration.
255 (This is a general problem with cross-compilation, and with
256 @code{gcc} in particular.)
260 @section Changing Settings Before Building
262 Here are some internal @code{g77} settings that can be changed
263 by editing source files in @file{@value{path-g77}/} before building.
265 This information, and perhaps even these settings, represent
266 stop-gap solutions to problems people doing various ports
267 of @code{g77} have encountered.
268 As such, none of the following information is expected to
269 be pertinent in future versions of @code{g77}.
272 * Larger File Unit Numbers:: Raising @code{MXUNIT}.
273 * Always Flush Output:: Synchronizing write errors.
274 * Maximum Stackable Size:: Large arrays forced off the stack.
275 * Floating-point Bit Patterns:: Possible programs building @code{g77}
277 * Large Initialization:: Large arrays with @code{DATA}
279 * Alpha Problems Fixed:: Problems with 64-bit systems like
283 @node Larger File Unit Numbers
284 @subsection Larger File Unit Numbers
287 @cindex maximum unit number
288 @cindex illegal unit number
289 @cindex increasing maximum unit number
291 As distributed, whether as part of @code{f2c} or @code{g77},
292 @code{libf2c} accepts file unit numbers only in the range
294 For example, a statement such as @samp{WRITE (UNIT=100)} causes
295 a run-time crash in @code{libf2c}, because the unit number,
296 100, is out of range.
298 If you know that Fortran programs at your installation require
299 the use of unit numbers higher than 99, you can change the
300 value of the @code{MXUNIT} macro, which represents the maximum unit
301 number, to an appropriately higher value.
303 To do this, edit the file @file{@value{path-libf2c}/libI77/fio.h} in your
304 @code{g77} source tree, changing the following line:
310 Change the line so that the value of @code{MXUNIT} is defined to be
311 at least one @emph{greater} than the maximum unit number used by
312 the Fortran programs on your system.
314 (For example, a program that does @samp{WRITE (UNIT=255)} would require
315 @code{MXUNIT} set to at least 256 to avoid crashing.)
317 Then build or rebuild @code{g77} as appropriate.
319 @emph{Note:} Changing this macro has @emph{no} effect on other limits
320 your system might place on the number of files open at the same time.
321 That is, the macro might allow a program to do @samp{WRITE (UNIT=100)},
322 but the library and operating system underlying @code{libf2c} might
323 disallow it if many other files have already been opened (via @code{OPEN} or
324 implicitly via @code{READ}, @code{WRITE}, and so on).
325 Information on how to increase these other limits should be found
326 in your system's documentation.
328 @node Always Flush Output
329 @subsection Always Flush Output
331 @cindex synchronous write errors
333 @cindex flushing output
335 @cindex I/O, flushing
336 @cindex output, flushing
337 @cindex writes, flushing
339 @cindex network file system
341 Some Fortran programs require output
342 (writes) to be flushed to the operating system (under UNIX,
343 via the @code{fflush()} library call) so that errors,
344 such as disk full, are immediately flagged via the relevant
345 @code{ERR=} and @code{IOSTAT=} mechanism, instead of such
346 errors being flagged later as subsequent writes occur, forcing
347 the previously written data to disk, or when the file is
350 Essentially, the difference can be viewed as synchronous error
351 reporting (immediate flagging of errors during writes) versus
352 asynchronous, or, more precisely, buffered error reporting
353 (detection of errors might be delayed).
355 @code{libg2c} supports flagging write errors immediately when
356 it is built with the @code{ALWAYS_FLUSH} macro defined.
357 This results in a @code{libg2c} that runs slower, sometimes
358 quite a bit slower, under certain circumstances---for example,
359 accessing files via the networked file system NFS---but the
360 effect can be more reliable, robust file I/O.
362 If you know that Fortran programs requiring this level of precision
363 of error reporting are to be compiled using the
364 version of @code{g77} you are building, you might wish to
365 modify the @code{g77} source tree so that the version of
366 @code{libg2c} is built with the @code{ALWAYS_FLUSH} macro
367 defined, enabling this behavior.
369 To do this, find this line in @file{@value{path-libf2c}/f2c.h} in
370 your @code{g77} source tree:
373 /* #define ALWAYS_FLUSH */
376 Remove the leading @samp{/*@w{ }},
377 so the line begins with @samp{#define},
378 and the trailing @samp{@w{ }*/}.
380 Then build or rebuild @code{g77} as appropriate.
382 @node Maximum Stackable Size
383 @subsection Maximum Stackable Size
384 @vindex FFECOM_sizeMAXSTACKITEM
385 @cindex code, stack variables
386 @cindex maximum stackable size
387 @cindex stack, allocation
388 @cindex segmentation violation
389 @code{g77}, on most machines, puts many variables and arrays on the stack
390 where possible, and can be configured (by changing
391 @code{FFECOM_sizeMAXSTACKITEM} in @file{@value{path-g77}/com.c}) to force
392 smaller-sized entities into static storage (saving
393 on stack space) or permit larger-sized entities to be put on the
394 stack (which can improve run-time performance, as it presents
395 more opportunities for the GBE to optimize the generated code).
397 @emph{Note:} Putting more variables and arrays on the stack
398 might cause problems due to system-dependent limits on stack size.
399 Also, the value of @code{FFECOM_sizeMAXSTACKITEM} has no
400 effect on automatic variables and arrays.
401 @xref{But-bugs}, for more information.
403 @node Floating-point Bit Patterns
404 @subsection Floating-point Bit Patterns
406 @cindex cross-compiler, building
407 @cindex floating-point bit patterns
409 The @code{g77} build will crash if an attempt is made to build
410 it as a cross-compiler
411 for a target when @code{g77} cannot reliably determine the bit pattern of
412 floating-point constants for the target.
413 Planned improvements for version 0.6 of @code{g77}
414 will give it the capabilities it needs to not have to crash the build
415 but rather generate correct code for the target.
416 (Currently, @code{g77}
417 would generate bad code under such circumstances if it didn't crash
418 during the build, e.g. when compiling a source file that does
419 something like @samp{EQUIVALENCE (I,R)} and @samp{DATA R/9.43578/}.)
421 @node Large Initialization
422 @subsection Initialization of Large Aggregate Areas
424 @cindex speed, of compiler
425 @cindex slow compiler
426 @cindex memory utilization
427 @cindex large initialization
428 @cindex aggregate initialization
429 A warning message is issued when @code{g77} sees code that provides
430 initial values (e.g. via @code{DATA}) to an aggregate area (@code{COMMON}
431 or @code{EQUIVALENCE}, or even a large enough array or @code{CHARACTER}
433 that is large enough to increase @code{g77}'s compile time by roughly
436 This size currently is quite small, since @code{g77}
437 currently has a known bug requiring too much memory
438 and time to handle such cases.
439 In @file{@value{path-g77}/data.c}, the macro
440 @code{FFEDATA_sizeTOO_BIG_INIT_} is defined
441 to the minimum size for the warning to appear.
442 The size is specified in storage units,
443 which can be bytes, words, or whatever, on a case-by-case basis.
445 After changing this macro definition, you must
446 (of course) rebuild and reinstall @code{g77} for
447 the change to take effect.
449 Note that, as of version 0.5.18, improvements have
450 reduced the scope of the problem for @emph{sparse}
451 initialization of large arrays, especially those
452 with large, contiguous uninitialized areas.
453 However, the warning is issued at a point prior to
454 when @code{g77} knows whether the initialization is sparse,
455 and delaying the warning could mean it is produced
456 too late to be helpful.
458 Therefore, the macro definition should not be adjusted to
459 reflect sparse cases.
460 Instead, adjust it to generate the warning when densely
461 initialized arrays begin to cause responses noticeably slower
462 than linear performance would suggest.
464 @node Alpha Problems Fixed
465 @subsection Alpha Problems Fixed
467 @cindex Alpha, support
468 @cindex 64-bit systems
469 @code{g77} used to warn when it was used to compile Fortran code
470 for a target configuration that is not basically a 32-bit
471 machine (such as an Alpha, which is a 64-bit machine, especially
472 if it has a 64-bit operating system running on it).
473 That was because @code{g77} was known to not work
474 properly on such configurations.
476 As of version 0.5.20, @code{g77} is believed to work well
477 enough on such systems.
478 So, the warning is no longer needed or provided.
480 However, support for 64-bit systems, especially in
481 areas such as cross-compilation and handling of
482 intrinsics, is still incomplete.
484 are believed to be compile-time diagnostics rather
485 than the generation of bad code.
486 It is hoped that version 0.6 will completely support 64-bit
493 For users of the @value{which-g77} version of @code{g77},
494 this information is superseded by the
495 @value{which-gcc} installation instructions.
497 @node Complete Installation
498 @section Complete Installation
500 For users of the @value{which-g77} version of @code{g77},
501 this information is superseded by the
502 @value{which-gcc} installation instructions.
504 @node Distributing Binaries
505 @section Distributing Binaries
506 @cindex binaries, distributing
507 @cindex code, distributing
509 For users of the @value{which-g77} version of @code{g77},
510 this information is superseded by the
511 @value{which-gcc} installation instructions.