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