xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/fortran/gfortranspec.c (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
1627f7eb2Smrg /* Specific flags and argument handling of the Fortran front-end.
2*4c3eb207Smrg    Copyright (C) 1997-2020 Free Software Foundation, Inc.
3627f7eb2Smrg 
4627f7eb2Smrg This file is part of GCC.
5627f7eb2Smrg 
6627f7eb2Smrg GNU CC is free software; you can redistribute it and/or modify
7627f7eb2Smrg it under the terms of the GNU General Public License as published by
8627f7eb2Smrg the Free Software Foundation; either version 3, or (at your option)
9627f7eb2Smrg any later version.
10627f7eb2Smrg 
11627f7eb2Smrg GNU CC is distributed in the hope that it will be useful,
12627f7eb2Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of
13627f7eb2Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14627f7eb2Smrg GNU General Public License for more details.
15627f7eb2Smrg 
16627f7eb2Smrg You should have received a copy of the GNU General Public License
17627f7eb2Smrg along with GCC; see the file COPYING3.  If not see
18627f7eb2Smrg <http://www.gnu.org/licenses/>.  */
19627f7eb2Smrg 
20627f7eb2Smrg /* This file is copied more or less verbatim from g77.  */
21627f7eb2Smrg /* This file contains a filter for the main `gcc' driver, which is
22627f7eb2Smrg    replicated for the `gfortran' driver by adding this filter.  The purpose
23627f7eb2Smrg    of this filter is to be basically identical to gcc (in that
24627f7eb2Smrg    it faithfully passes all of the original arguments to gcc) but,
25627f7eb2Smrg    unless explicitly overridden by the user in certain ways, ensure
26627f7eb2Smrg    that the needs of the language supported by this wrapper are met.
27627f7eb2Smrg 
28627f7eb2Smrg    For GNU Fortran 95(gfortran), we do the following to the argument list
29627f7eb2Smrg    before passing it to `gcc':
30627f7eb2Smrg 
31627f7eb2Smrg    1.  Make sure `-lgfortran -lm' is at the end of the list.
32627f7eb2Smrg 
33627f7eb2Smrg    2.  Make sure each time `-lgfortran' or `-lm' is seen, it forms
34627f7eb2Smrg        part of the series `-lgfortran -lm'.
35627f7eb2Smrg 
36627f7eb2Smrg    #1 and #2 are not done if `-nostdlib' or any option that disables
37627f7eb2Smrg    the linking phase is present, or if `-xfoo' is in effect.  Note that
38627f7eb2Smrg    a lack of source files or -l options disables linking.
39627f7eb2Smrg 
40627f7eb2Smrg    This program was originally made out of gcc/cp/g++spec.c, but the
41627f7eb2Smrg    way it builds the new argument list was rewritten so it is much
42627f7eb2Smrg    easier to maintain, improve the way it decides to add or not add
43627f7eb2Smrg    extra arguments, etc.  And several improvements were made in the
44627f7eb2Smrg    handling of arguments, primarily to make it more consistent with
45627f7eb2Smrg    `gcc' itself.  */
46627f7eb2Smrg 
47627f7eb2Smrg #include "config.h"
48627f7eb2Smrg #include "system.h"
49627f7eb2Smrg #include "coretypes.h"
50627f7eb2Smrg #include "opt-suggestions.h"
51627f7eb2Smrg #include "gcc.h"
52627f7eb2Smrg #include "opts.h"
53627f7eb2Smrg 
54627f7eb2Smrg #include "tm.h"
55627f7eb2Smrg #include "intl.h"
56627f7eb2Smrg 
57627f7eb2Smrg #ifndef MATH_LIBRARY
58627f7eb2Smrg #define MATH_LIBRARY "m"
59627f7eb2Smrg #endif
60627f7eb2Smrg 
61627f7eb2Smrg #ifndef FORTRAN_LIBRARY
62627f7eb2Smrg #define FORTRAN_LIBRARY "gfortran"
63627f7eb2Smrg #endif
64627f7eb2Smrg 
65627f7eb2Smrg /* Name of the spec file.  */
66627f7eb2Smrg #define SPEC_FILE "libgfortran.spec"
67627f7eb2Smrg 
68627f7eb2Smrg /* The original argument list and related info is copied here.  */
69627f7eb2Smrg static unsigned int g77_xargc;
70627f7eb2Smrg static const struct cl_decoded_option *g77_x_decoded_options;
71627f7eb2Smrg static void append_arg (const struct cl_decoded_option *);
72627f7eb2Smrg 
73627f7eb2Smrg /* The new argument list will be built here.  */
74627f7eb2Smrg static unsigned int g77_newargc;
75627f7eb2Smrg static struct cl_decoded_option *g77_new_decoded_options;
76627f7eb2Smrg 
77627f7eb2Smrg /* This will be NULL if we encounter a situation where we should not
78627f7eb2Smrg    link in the fortran libraries.  */
79627f7eb2Smrg static const char *library = NULL;
80627f7eb2Smrg 
81627f7eb2Smrg 
82627f7eb2Smrg /* Return whether strings S1 and S2 are both NULL or both the same
83627f7eb2Smrg    string.  */
84627f7eb2Smrg 
85627f7eb2Smrg static bool
strings_same(const char * s1,const char * s2)86627f7eb2Smrg strings_same (const char *s1, const char *s2)
87627f7eb2Smrg {
88627f7eb2Smrg   return s1 == s2 || (s1 != NULL && s2 != NULL && strcmp (s1, s2) == 0);
89627f7eb2Smrg }
90627f7eb2Smrg 
91627f7eb2Smrg /* Return whether decoded option structures OPT1 and OPT2 are the
92627f7eb2Smrg    same.  */
93627f7eb2Smrg 
94627f7eb2Smrg static bool
options_same(const struct cl_decoded_option * opt1,const struct cl_decoded_option * opt2)95627f7eb2Smrg options_same (const struct cl_decoded_option *opt1,
96627f7eb2Smrg 	      const struct cl_decoded_option *opt2)
97627f7eb2Smrg {
98627f7eb2Smrg   return (opt1->opt_index == opt2->opt_index
99627f7eb2Smrg 	  && strings_same (opt1->arg, opt2->arg)
100627f7eb2Smrg 	  && strings_same (opt1->orig_option_with_args_text,
101627f7eb2Smrg 			   opt2->orig_option_with_args_text)
102627f7eb2Smrg 	  && strings_same (opt1->canonical_option[0],
103627f7eb2Smrg 			   opt2->canonical_option[0])
104627f7eb2Smrg 	  && strings_same (opt1->canonical_option[1],
105627f7eb2Smrg 			   opt2->canonical_option[1])
106627f7eb2Smrg 	  && strings_same (opt1->canonical_option[2],
107627f7eb2Smrg 			   opt2->canonical_option[2])
108627f7eb2Smrg 	  && strings_same (opt1->canonical_option[3],
109627f7eb2Smrg 			   opt2->canonical_option[3])
110627f7eb2Smrg 	  && (opt1->canonical_option_num_elements
111627f7eb2Smrg 	      == opt2->canonical_option_num_elements)
112627f7eb2Smrg 	  && opt1->value == opt2->value
113627f7eb2Smrg 	  && opt1->errors == opt2->errors);
114627f7eb2Smrg }
115627f7eb2Smrg 
116627f7eb2Smrg /* Append another argument to the list being built.  As long as it is
117627f7eb2Smrg    identical to the corresponding arg in the original list, just increment
118627f7eb2Smrg    the new arg count.  Otherwise allocate a new list, etc.  */
119627f7eb2Smrg 
120627f7eb2Smrg static void
append_arg(const struct cl_decoded_option * arg)121627f7eb2Smrg append_arg (const struct cl_decoded_option *arg)
122627f7eb2Smrg {
123627f7eb2Smrg   static unsigned int newargsize;
124627f7eb2Smrg 
125627f7eb2Smrg   if (g77_new_decoded_options == g77_x_decoded_options
126627f7eb2Smrg       && g77_newargc < g77_xargc
127627f7eb2Smrg       && options_same (arg, &g77_x_decoded_options[g77_newargc]))
128627f7eb2Smrg     {
129627f7eb2Smrg       ++g77_newargc;
130627f7eb2Smrg       return;			/* Nothing new here.  */
131627f7eb2Smrg     }
132627f7eb2Smrg 
133627f7eb2Smrg   if (g77_new_decoded_options == g77_x_decoded_options)
134627f7eb2Smrg     {				/* Make new arglist.  */
135627f7eb2Smrg       unsigned int i;
136627f7eb2Smrg 
137627f7eb2Smrg       newargsize = (g77_xargc << 2) + 20;	/* This should handle all.  */
138627f7eb2Smrg       g77_new_decoded_options = XNEWVEC (struct cl_decoded_option, newargsize);
139627f7eb2Smrg 
140627f7eb2Smrg       /* Copy what has been done so far.  */
141627f7eb2Smrg       for (i = 0; i < g77_newargc; ++i)
142627f7eb2Smrg 	g77_new_decoded_options[i] = g77_x_decoded_options[i];
143627f7eb2Smrg     }
144627f7eb2Smrg 
145627f7eb2Smrg   if (g77_newargc == newargsize)
146*4c3eb207Smrg     fatal_error (input_location, "overflowed output argument list for %qs",
147627f7eb2Smrg 		 arg->orig_option_with_args_text);
148627f7eb2Smrg 
149627f7eb2Smrg   g77_new_decoded_options[g77_newargc++] = *arg;
150627f7eb2Smrg }
151627f7eb2Smrg 
152627f7eb2Smrg /* Append an option described by OPT_INDEX, ARG and VALUE to the list
153627f7eb2Smrg    being built.  */
154627f7eb2Smrg static void
append_option(size_t opt_index,const char * arg,int value)155627f7eb2Smrg append_option (size_t opt_index, const char *arg, int value)
156627f7eb2Smrg {
157627f7eb2Smrg   struct cl_decoded_option decoded;
158627f7eb2Smrg 
159627f7eb2Smrg   generate_option (opt_index, arg, value, CL_DRIVER, &decoded);
160627f7eb2Smrg   append_arg (&decoded);
161627f7eb2Smrg }
162627f7eb2Smrg 
163627f7eb2Smrg /* Append a libgfortran argument to the list being built.  If
164627f7eb2Smrg    FORCE_STATIC, ensure the library is linked statically.  */
165627f7eb2Smrg 
166627f7eb2Smrg static void
add_arg_libgfortran(bool force_static ATTRIBUTE_UNUSED)167627f7eb2Smrg add_arg_libgfortran (bool force_static ATTRIBUTE_UNUSED)
168627f7eb2Smrg {
169627f7eb2Smrg #ifdef HAVE_LD_STATIC_DYNAMIC
170627f7eb2Smrg   if (force_static)
171627f7eb2Smrg     append_option (OPT_Wl_, LD_STATIC_OPTION, 1);
172627f7eb2Smrg #endif
173627f7eb2Smrg   append_option (OPT_l, FORTRAN_LIBRARY, 1);
174627f7eb2Smrg #ifdef HAVE_LD_STATIC_DYNAMIC
175627f7eb2Smrg   if (force_static)
176627f7eb2Smrg     append_option (OPT_Wl_, LD_DYNAMIC_OPTION, 1);
177627f7eb2Smrg #endif
178627f7eb2Smrg }
179627f7eb2Smrg 
180627f7eb2Smrg void
lang_specific_driver(struct cl_decoded_option ** in_decoded_options,unsigned int * in_decoded_options_count,int * in_added_libraries ATTRIBUTE_UNUSED)181627f7eb2Smrg lang_specific_driver (struct cl_decoded_option **in_decoded_options,
182627f7eb2Smrg 		      unsigned int *in_decoded_options_count,
183627f7eb2Smrg 		      int *in_added_libraries ATTRIBUTE_UNUSED)
184627f7eb2Smrg {
185627f7eb2Smrg   unsigned int argc = *in_decoded_options_count;
186627f7eb2Smrg   struct cl_decoded_option *decoded_options = *in_decoded_options;
187627f7eb2Smrg   unsigned int i;
188627f7eb2Smrg   int verbose = 0;
189627f7eb2Smrg 
190627f7eb2Smrg   /* 0 => -xnone in effect.
191627f7eb2Smrg      1 => -xfoo in effect.  */
192627f7eb2Smrg   int saw_speclang = 0;
193627f7eb2Smrg 
194627f7eb2Smrg   /* 0 => initial/reset state
195627f7eb2Smrg      1 => last arg was -l<library>
196627f7eb2Smrg      2 => last two args were -l<library> -lm.  */
197627f7eb2Smrg   int saw_library = 0;
198627f7eb2Smrg 
199627f7eb2Smrg   /* By default, we throw on the math library if we have one.  */
200627f7eb2Smrg   int need_math = (MATH_LIBRARY[0] != '\0');
201627f7eb2Smrg 
202627f7eb2Smrg   /* Whether we should link a static libgfortran.  */
203627f7eb2Smrg   int static_lib = 0;
204627f7eb2Smrg 
205627f7eb2Smrg   /* Whether we need to link statically.  */
206627f7eb2Smrg   int static_linking = 0;
207627f7eb2Smrg 
208627f7eb2Smrg   /* The number of input and output files in the incoming arg list.  */
209627f7eb2Smrg   int n_infiles = 0;
210627f7eb2Smrg   int n_outfiles = 0;
211627f7eb2Smrg 
212627f7eb2Smrg   library = FORTRAN_LIBRARY;
213627f7eb2Smrg 
214627f7eb2Smrg #if 0
215627f7eb2Smrg   fprintf (stderr, "Incoming:");
216627f7eb2Smrg   for (i = 0; i < argc; i++)
217627f7eb2Smrg     fprintf (stderr, " %s", decoded_options[i].orig_option_with_args_text);
218627f7eb2Smrg   fprintf (stderr, "\n");
219627f7eb2Smrg #endif
220627f7eb2Smrg 
221627f7eb2Smrg   g77_xargc = argc;
222627f7eb2Smrg   g77_x_decoded_options = decoded_options;
223627f7eb2Smrg   g77_newargc = 0;
224627f7eb2Smrg   g77_new_decoded_options = decoded_options;
225627f7eb2Smrg 
226627f7eb2Smrg   /* First pass through arglist.
227627f7eb2Smrg 
228627f7eb2Smrg      If -nostdlib or a "turn-off-linking" option is anywhere in the
229627f7eb2Smrg      command line, don't do any library-option processing (except
230627f7eb2Smrg      relating to -x).  */
231627f7eb2Smrg 
232627f7eb2Smrg   for (i = 1; i < argc; ++i)
233627f7eb2Smrg     {
234627f7eb2Smrg       if (decoded_options[i].errors & CL_ERR_MISSING_ARG)
235627f7eb2Smrg 	continue;
236627f7eb2Smrg 
237627f7eb2Smrg       switch (decoded_options[i].opt_index)
238627f7eb2Smrg 	{
239627f7eb2Smrg 	case OPT_SPECIAL_input_file:
240627f7eb2Smrg 	  ++n_infiles;
241627f7eb2Smrg 	  continue;
242627f7eb2Smrg 
243627f7eb2Smrg 	case OPT_nostdlib:
244627f7eb2Smrg 	case OPT_nodefaultlibs:
245627f7eb2Smrg 	case OPT_c:
246627f7eb2Smrg 	case OPT_r:
247627f7eb2Smrg 	case OPT_S:
248627f7eb2Smrg 	case OPT_fsyntax_only:
249627f7eb2Smrg 	case OPT_E:
250627f7eb2Smrg 	  /* These options disable linking entirely or linking of the
251627f7eb2Smrg 	     standard libraries.  */
252627f7eb2Smrg 	  library = 0;
253627f7eb2Smrg 	  break;
254627f7eb2Smrg 
255627f7eb2Smrg 	case OPT_static_libgfortran:
256627f7eb2Smrg #ifdef HAVE_LD_STATIC_DYNAMIC
257627f7eb2Smrg 	  static_lib = 1;
258627f7eb2Smrg #endif
259627f7eb2Smrg 	  break;
260627f7eb2Smrg 
261627f7eb2Smrg 	case OPT_static:
262627f7eb2Smrg #ifdef HAVE_LD_STATIC_DYNAMIC
263627f7eb2Smrg 	  static_linking = 1;
264627f7eb2Smrg #endif
265627f7eb2Smrg 	  break;
266627f7eb2Smrg 
267627f7eb2Smrg 	case OPT_l:
268627f7eb2Smrg 	  ++n_infiles;
269627f7eb2Smrg 	  break;
270627f7eb2Smrg 
271627f7eb2Smrg 	case OPT_o:
272627f7eb2Smrg 	  ++n_outfiles;
273627f7eb2Smrg 	  break;
274627f7eb2Smrg 
275627f7eb2Smrg 	case OPT_v:
276627f7eb2Smrg 	  verbose = 1;
277627f7eb2Smrg 	  break;
278627f7eb2Smrg 
279627f7eb2Smrg 	case OPT__version:
280627f7eb2Smrg 	  printf ("GNU Fortran %s%s\n", pkgversion_string, version_string);
281*4c3eb207Smrg 	  printf ("Copyright %s 2020 Free Software Foundation, Inc.\n",
282627f7eb2Smrg 		  _("(C)"));
283627f7eb2Smrg 	  fputs (_("This is free software; see the source for copying conditions.  There is NO\n\
284627f7eb2Smrg warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
285627f7eb2Smrg 		stdout);
286627f7eb2Smrg 	  exit (0);
287627f7eb2Smrg 	  break;
288627f7eb2Smrg 
289627f7eb2Smrg 	case OPT__help:
290627f7eb2Smrg 	  /* Let gcc.c handle this, as it has a really
291627f7eb2Smrg 	     cool facility for handling --help and --verbose --help.  */
292627f7eb2Smrg 	  return;
293627f7eb2Smrg 
294627f7eb2Smrg 	default:
295627f7eb2Smrg 	  break;
296627f7eb2Smrg 	}
297627f7eb2Smrg     }
298627f7eb2Smrg 
299627f7eb2Smrg   if ((n_outfiles != 0) && (n_infiles == 0))
300627f7eb2Smrg     fatal_error (input_location,
301627f7eb2Smrg 		 "no input files; unwilling to write output files");
302627f7eb2Smrg 
303627f7eb2Smrg   /* If there are no input files, no need for the library.  */
304627f7eb2Smrg   if (n_infiles == 0)
305627f7eb2Smrg     library = 0;
306627f7eb2Smrg 
307627f7eb2Smrg   /* Second pass through arglist, transforming arguments as appropriate.  */
308627f7eb2Smrg 
309627f7eb2Smrg   append_arg (&decoded_options[0]); /* Start with command name, of course.  */
310627f7eb2Smrg 
311627f7eb2Smrg   for (i = 1; i < argc; ++i)
312627f7eb2Smrg     {
313627f7eb2Smrg       if (decoded_options[i].errors & CL_ERR_MISSING_ARG)
314627f7eb2Smrg 	{
315627f7eb2Smrg 	  append_arg (&decoded_options[i]);
316627f7eb2Smrg 	  continue;
317627f7eb2Smrg 	}
318627f7eb2Smrg 
319627f7eb2Smrg       if (decoded_options[i].opt_index == OPT_SPECIAL_input_file
320627f7eb2Smrg 	  && decoded_options[i].arg[0] == '\0')
321627f7eb2Smrg 	{
322627f7eb2Smrg 	  /* Interesting.  Just append as is.  */
323627f7eb2Smrg 	  append_arg (&decoded_options[i]);
324627f7eb2Smrg 	  continue;
325627f7eb2Smrg 	}
326627f7eb2Smrg 
327627f7eb2Smrg       if (decoded_options[i].opt_index != OPT_l
328627f7eb2Smrg 	  && (decoded_options[i].opt_index != OPT_SPECIAL_input_file
329627f7eb2Smrg 	      || strcmp (decoded_options[i].arg, "-") == 0))
330627f7eb2Smrg 	{
331627f7eb2Smrg 	  /* Not a filename or library.  */
332627f7eb2Smrg 
333627f7eb2Smrg 	  if (saw_library == 1 && need_math)	/* -l<library>.  */
334627f7eb2Smrg 	    append_option (OPT_l, MATH_LIBRARY, 1);
335627f7eb2Smrg 
336627f7eb2Smrg 	  saw_library = 0;
337627f7eb2Smrg 
338627f7eb2Smrg 	  if (decoded_options[i].opt_index == OPT_SPECIAL_input_file)
339627f7eb2Smrg 	    {
340627f7eb2Smrg 	      append_arg (&decoded_options[i]);	/* "-" == Standard input.  */
341627f7eb2Smrg 	      continue;
342627f7eb2Smrg 	    }
343627f7eb2Smrg 
344627f7eb2Smrg 	  if (decoded_options[i].opt_index == OPT_x)
345627f7eb2Smrg 	    {
346627f7eb2Smrg 	      /* Track input language.  */
347627f7eb2Smrg 	      const char *lang = decoded_options[i].arg;
348627f7eb2Smrg 
349627f7eb2Smrg 	      saw_speclang = (strcmp (lang, "none") != 0);
350627f7eb2Smrg 	    }
351627f7eb2Smrg 
352627f7eb2Smrg 	  append_arg (&decoded_options[i]);
353627f7eb2Smrg 
354627f7eb2Smrg 	  continue;
355627f7eb2Smrg 	}
356627f7eb2Smrg 
357627f7eb2Smrg       /* A filename/library, not an option.  */
358627f7eb2Smrg 
359627f7eb2Smrg       if (saw_speclang)
360627f7eb2Smrg 	saw_library = 0;	/* -xfoo currently active.  */
361627f7eb2Smrg       else
362627f7eb2Smrg 	{			/* -lfoo or filename.  */
363627f7eb2Smrg 	  if (decoded_options[i].opt_index == OPT_l
364627f7eb2Smrg 	      && strcmp (decoded_options[i].arg, MATH_LIBRARY) == 0)
365627f7eb2Smrg 	    {
366627f7eb2Smrg 	      if (saw_library == 1)
367627f7eb2Smrg 		saw_library = 2;	/* -l<library> -lm.  */
368627f7eb2Smrg 	      else
369627f7eb2Smrg 		add_arg_libgfortran (static_lib && !static_linking);
370627f7eb2Smrg 	    }
371627f7eb2Smrg 	  else if (decoded_options[i].opt_index == OPT_l
372627f7eb2Smrg 	      && strcmp (decoded_options[i].arg, FORTRAN_LIBRARY) == 0)
373627f7eb2Smrg 	    {
374627f7eb2Smrg 	      saw_library = 1;	/* -l<library>.  */
375627f7eb2Smrg 	      add_arg_libgfortran (static_lib && !static_linking);
376627f7eb2Smrg 	      continue;
377627f7eb2Smrg 	    }
378627f7eb2Smrg 	  else
379627f7eb2Smrg 	    {			/* Other library, or filename.  */
380627f7eb2Smrg 	      if (saw_library == 1 && need_math)
381627f7eb2Smrg 		append_option (OPT_l, MATH_LIBRARY, 1);
382627f7eb2Smrg 	      saw_library = 0;
383627f7eb2Smrg 	    }
384627f7eb2Smrg 	}
385627f7eb2Smrg       append_arg (&decoded_options[i]);
386627f7eb2Smrg     }
387627f7eb2Smrg 
388627f7eb2Smrg   /* Append `-lgfortran -lm' as necessary.  */
389627f7eb2Smrg 
390627f7eb2Smrg   if (library)
391627f7eb2Smrg     {				/* Doing a link and no -nostdlib.  */
392627f7eb2Smrg       if (saw_speclang)
393627f7eb2Smrg 	append_option (OPT_x, "none", 1);
394627f7eb2Smrg 
395627f7eb2Smrg       switch (saw_library)
396627f7eb2Smrg 	{
397627f7eb2Smrg 	case 0:
398627f7eb2Smrg 	  add_arg_libgfortran (static_lib && !static_linking);
399627f7eb2Smrg 	  /* Fall through.  */
400627f7eb2Smrg 
401627f7eb2Smrg 	case 1:
402627f7eb2Smrg 	  if (need_math)
403627f7eb2Smrg 	    append_option (OPT_l, MATH_LIBRARY, 1);
404627f7eb2Smrg 	default:
405627f7eb2Smrg 	  break;
406627f7eb2Smrg 	}
407627f7eb2Smrg     }
408627f7eb2Smrg 
409627f7eb2Smrg #ifdef ENABLE_SHARED_LIBGCC
410627f7eb2Smrg   if (library)
411627f7eb2Smrg     {
412627f7eb2Smrg       unsigned int i;
413627f7eb2Smrg 
414627f7eb2Smrg       for (i = 1; i < g77_newargc; i++)
415627f7eb2Smrg 	if (g77_new_decoded_options[i].opt_index == OPT_static_libgcc
416627f7eb2Smrg 	    || g77_new_decoded_options[i].opt_index == OPT_static)
417627f7eb2Smrg 	  break;
418627f7eb2Smrg 
419627f7eb2Smrg       if (i == g77_newargc)
420627f7eb2Smrg 	append_option (OPT_shared_libgcc, NULL, 1);
421627f7eb2Smrg     }
422627f7eb2Smrg 
423627f7eb2Smrg #endif
424627f7eb2Smrg 
425627f7eb2Smrg   if (verbose && g77_new_decoded_options != g77_x_decoded_options)
426627f7eb2Smrg     {
427627f7eb2Smrg       fprintf (stderr, _("Driving:"));
428627f7eb2Smrg       for (i = 0; i < g77_newargc; i++)
429627f7eb2Smrg 	fprintf (stderr, " %s",
430627f7eb2Smrg 		 g77_new_decoded_options[i].orig_option_with_args_text);
431627f7eb2Smrg       fprintf (stderr, "\n");
432627f7eb2Smrg     }
433627f7eb2Smrg 
434627f7eb2Smrg   *in_decoded_options_count = g77_newargc;
435627f7eb2Smrg   *in_decoded_options = g77_new_decoded_options;
436627f7eb2Smrg }
437627f7eb2Smrg 
438627f7eb2Smrg 
439627f7eb2Smrg /* Called before linking.  Returns 0 on success and -1 on failure.  */
440627f7eb2Smrg int
lang_specific_pre_link(void)441627f7eb2Smrg lang_specific_pre_link (void)
442627f7eb2Smrg {
443627f7eb2Smrg   if (library)
444627f7eb2Smrg     do_spec ("%:include(libgfortran.spec)");
445627f7eb2Smrg 
446627f7eb2Smrg   return 0;
447627f7eb2Smrg }
448627f7eb2Smrg 
449627f7eb2Smrg /* Number of extra output files that lang_specific_pre_link may generate.  */
450627f7eb2Smrg int lang_specific_extra_outfiles = 0;	/* Not used for F77.  */
451