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