xref: /dflybsd-src/contrib/gcc-4.7/gcc/gccspec.c (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* Specific flags and argument handling of the C front-end.
2*e4b17023SJohn Marino    Copyright (C) 1999, 2001, 2003, 2007, 2010 Free Software Foundation, Inc.
3*e4b17023SJohn Marino 
4*e4b17023SJohn Marino This file is part of GCC.
5*e4b17023SJohn Marino 
6*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
7*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
8*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
9*e4b17023SJohn Marino version.
10*e4b17023SJohn Marino 
11*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14*e4b17023SJohn Marino for more details.
15*e4b17023SJohn Marino 
16*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
17*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
18*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
19*e4b17023SJohn Marino 
20*e4b17023SJohn Marino #include "config.h"
21*e4b17023SJohn Marino #include "system.h"
22*e4b17023SJohn Marino #include "coretypes.h"
23*e4b17023SJohn Marino #include "tm.h"
24*e4b17023SJohn Marino #include "gcc.h"
25*e4b17023SJohn Marino #include "opts.h"
26*e4b17023SJohn Marino 
27*e4b17023SJohn Marino /* Filter command line before processing by the gcc driver proper.  */
28*e4b17023SJohn Marino void
lang_specific_driver(struct cl_decoded_option ** in_decoded_options ATTRIBUTE_UNUSED,unsigned int * in_decoded_options_count ATTRIBUTE_UNUSED,int * in_added_libraries ATTRIBUTE_UNUSED)29*e4b17023SJohn Marino lang_specific_driver (struct cl_decoded_option **in_decoded_options ATTRIBUTE_UNUSED,
30*e4b17023SJohn Marino 		      unsigned int *in_decoded_options_count ATTRIBUTE_UNUSED,
31*e4b17023SJohn Marino 		      int *in_added_libraries ATTRIBUTE_UNUSED)
32*e4b17023SJohn Marino {
33*e4b17023SJohn Marino   /* Systems which use the NeXT runtime by default should arrange
34*e4b17023SJohn Marino      for the shared libgcc to be used when -fgnu-runtime is passed
35*e4b17023SJohn Marino      through specs.  */
36*e4b17023SJohn Marino #if defined(ENABLE_SHARED_LIBGCC) && ! NEXT_OBJC_RUNTIME
37*e4b17023SJohn Marino   unsigned int i;
38*e4b17023SJohn Marino 
39*e4b17023SJohn Marino   /* The new argument list will be contained in this.  */
40*e4b17023SJohn Marino   struct cl_decoded_option *new_decoded_options;
41*e4b17023SJohn Marino 
42*e4b17023SJohn Marino   /* True if we should add -shared-libgcc to the command-line.  */
43*e4b17023SJohn Marino   int shared_libgcc = 0;
44*e4b17023SJohn Marino 
45*e4b17023SJohn Marino   /* The total number of arguments with the new stuff.  */
46*e4b17023SJohn Marino   unsigned int argc;
47*e4b17023SJohn Marino 
48*e4b17023SJohn Marino   /* The argument list.  */
49*e4b17023SJohn Marino   struct cl_decoded_option *decoded_options;
50*e4b17023SJohn Marino 
51*e4b17023SJohn Marino   argc = *in_decoded_options_count;
52*e4b17023SJohn Marino   decoded_options = *in_decoded_options;
53*e4b17023SJohn Marino 
54*e4b17023SJohn Marino   for (i = 1; i < argc; i++)
55*e4b17023SJohn Marino     {
56*e4b17023SJohn Marino       switch (decoded_options[i].opt_index)
57*e4b17023SJohn Marino 	{
58*e4b17023SJohn Marino 	case OPT_static_libgcc:
59*e4b17023SJohn Marino 	case OPT_static:
60*e4b17023SJohn Marino 	  return;
61*e4b17023SJohn Marino 
62*e4b17023SJohn Marino 	case OPT_SPECIAL_input_file:
63*e4b17023SJohn Marino 	  {
64*e4b17023SJohn Marino 	    const char *file = decoded_options[i].arg;
65*e4b17023SJohn Marino 	    int len;
66*e4b17023SJohn Marino 
67*e4b17023SJohn Marino 	    /* If the filename ends in .m or .mi, we are compiling
68*e4b17023SJohn Marino 	       ObjC and want to pass -shared-libgcc.  */
69*e4b17023SJohn Marino 	    len = strlen (file);
70*e4b17023SJohn Marino 	    if ((len > 2 && file[len - 2] == '.' && file[len - 1] == 'm')
71*e4b17023SJohn Marino 		||  (len > 3 && file[len - 3] == '.' && file[len - 2] == 'm'
72*e4b17023SJohn Marino 		     && file[len - 1] == 'i'))
73*e4b17023SJohn Marino 	      shared_libgcc = 1;
74*e4b17023SJohn Marino 	  }
75*e4b17023SJohn Marino 	  break;
76*e4b17023SJohn Marino 	}
77*e4b17023SJohn Marino     }
78*e4b17023SJohn Marino 
79*e4b17023SJohn Marino   if  (shared_libgcc)
80*e4b17023SJohn Marino     {
81*e4b17023SJohn Marino       new_decoded_options = XNEWVEC (struct cl_decoded_option, argc + 1);
82*e4b17023SJohn Marino 
83*e4b17023SJohn Marino       i = 0;
84*e4b17023SJohn Marino       do
85*e4b17023SJohn Marino 	{
86*e4b17023SJohn Marino 	  new_decoded_options[i] = decoded_options[i];
87*e4b17023SJohn Marino 	  i++;
88*e4b17023SJohn Marino 	}
89*e4b17023SJohn Marino       while (i < argc);
90*e4b17023SJohn Marino 
91*e4b17023SJohn Marino       generate_option (OPT_shared_libgcc, NULL, 1, CL_DRIVER,
92*e4b17023SJohn Marino 		       &new_decoded_options[i++]);
93*e4b17023SJohn Marino 
94*e4b17023SJohn Marino       *in_decoded_options_count = i;
95*e4b17023SJohn Marino       *in_decoded_options = new_decoded_options;
96*e4b17023SJohn Marino     }
97*e4b17023SJohn Marino #endif
98*e4b17023SJohn Marino }
99*e4b17023SJohn Marino 
100*e4b17023SJohn Marino /* Called before linking.  Returns 0 on success and -1 on failure.  */
101*e4b17023SJohn Marino int
lang_specific_pre_link(void)102*e4b17023SJohn Marino lang_specific_pre_link (void)
103*e4b17023SJohn Marino {
104*e4b17023SJohn Marino   return 0;  /* Not used for C.  */
105*e4b17023SJohn Marino }
106*e4b17023SJohn Marino 
107*e4b17023SJohn Marino /* Number of extra output files that lang_specific_pre_link may generate.  */
108*e4b17023SJohn Marino int lang_specific_extra_outfiles = 0;  /* Not used for C.  */
109