11debfc3dSmrg /* Specific flags and argument handling of the C front-end.
2*8feb0f0bSmrg Copyright (C) 1999-2020 Free Software Foundation, Inc.
31debfc3dSmrg
41debfc3dSmrg This file is part of GCC.
51debfc3dSmrg
61debfc3dSmrg GCC is free software; you can redistribute it and/or modify it under
71debfc3dSmrg the terms of the GNU General Public License as published by the Free
81debfc3dSmrg Software Foundation; either version 3, or (at your option) any later
91debfc3dSmrg version.
101debfc3dSmrg
111debfc3dSmrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
121debfc3dSmrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
131debfc3dSmrg FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
141debfc3dSmrg for more details.
151debfc3dSmrg
161debfc3dSmrg You should have received a copy of the GNU General Public License
171debfc3dSmrg along with GCC; see the file COPYING3. If not see
181debfc3dSmrg <http://www.gnu.org/licenses/>. */
191debfc3dSmrg
201debfc3dSmrg #include "config.h"
211debfc3dSmrg #include "system.h"
221debfc3dSmrg #include "coretypes.h"
231debfc3dSmrg #include "tm.h"
241debfc3dSmrg #include "opts.h"
251debfc3dSmrg
261debfc3dSmrg /* Filter command line before processing by the gcc driver proper. */
271debfc3dSmrg 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)281debfc3dSmrg lang_specific_driver (struct cl_decoded_option **in_decoded_options ATTRIBUTE_UNUSED,
291debfc3dSmrg unsigned int *in_decoded_options_count ATTRIBUTE_UNUSED,
301debfc3dSmrg int *in_added_libraries ATTRIBUTE_UNUSED)
311debfc3dSmrg {
321debfc3dSmrg /* Systems which use the NeXT runtime by default should arrange
331debfc3dSmrg for the shared libgcc to be used when -fgnu-runtime is passed
341debfc3dSmrg through specs. */
351debfc3dSmrg #if defined(ENABLE_SHARED_LIBGCC) && ! NEXT_OBJC_RUNTIME
361debfc3dSmrg unsigned int i;
371debfc3dSmrg
381debfc3dSmrg /* The new argument list will be contained in this. */
391debfc3dSmrg struct cl_decoded_option *new_decoded_options;
401debfc3dSmrg
411debfc3dSmrg /* True if we should add -shared-libgcc to the command-line. */
421debfc3dSmrg int shared_libgcc = 0;
431debfc3dSmrg
441debfc3dSmrg /* The total number of arguments with the new stuff. */
451debfc3dSmrg unsigned int argc;
461debfc3dSmrg
471debfc3dSmrg /* The argument list. */
481debfc3dSmrg struct cl_decoded_option *decoded_options;
491debfc3dSmrg
501debfc3dSmrg argc = *in_decoded_options_count;
511debfc3dSmrg decoded_options = *in_decoded_options;
521debfc3dSmrg
531debfc3dSmrg for (i = 1; i < argc; i++)
541debfc3dSmrg {
551debfc3dSmrg switch (decoded_options[i].opt_index)
561debfc3dSmrg {
571debfc3dSmrg case OPT_static_libgcc:
581debfc3dSmrg case OPT_static:
591debfc3dSmrg return;
601debfc3dSmrg
611debfc3dSmrg case OPT_SPECIAL_input_file:
621debfc3dSmrg {
631debfc3dSmrg const char *file = decoded_options[i].arg;
641debfc3dSmrg int len;
651debfc3dSmrg
661debfc3dSmrg /* If the filename ends in .m or .mi, we are compiling
671debfc3dSmrg ObjC and want to pass -shared-libgcc. */
681debfc3dSmrg len = strlen (file);
691debfc3dSmrg if ((len > 2 && file[len - 2] == '.' && file[len - 1] == 'm')
701debfc3dSmrg || (len > 3 && file[len - 3] == '.' && file[len - 2] == 'm'
711debfc3dSmrg && file[len - 1] == 'i'))
721debfc3dSmrg shared_libgcc = 1;
731debfc3dSmrg }
741debfc3dSmrg break;
751debfc3dSmrg }
761debfc3dSmrg }
771debfc3dSmrg
781debfc3dSmrg if (shared_libgcc)
791debfc3dSmrg {
801debfc3dSmrg new_decoded_options = XNEWVEC (struct cl_decoded_option, argc + 1);
811debfc3dSmrg
821debfc3dSmrg i = 0;
831debfc3dSmrg do
841debfc3dSmrg {
851debfc3dSmrg new_decoded_options[i] = decoded_options[i];
861debfc3dSmrg i++;
871debfc3dSmrg }
881debfc3dSmrg while (i < argc);
891debfc3dSmrg
901debfc3dSmrg generate_option (OPT_shared_libgcc, NULL, 1, CL_DRIVER,
911debfc3dSmrg &new_decoded_options[i++]);
921debfc3dSmrg
931debfc3dSmrg *in_decoded_options_count = i;
941debfc3dSmrg *in_decoded_options = new_decoded_options;
951debfc3dSmrg }
961debfc3dSmrg #endif
971debfc3dSmrg }
981debfc3dSmrg
991debfc3dSmrg /* Called before linking. Returns 0 on success and -1 on failure. */
1001debfc3dSmrg int
lang_specific_pre_link(void)1011debfc3dSmrg lang_specific_pre_link (void)
1021debfc3dSmrg {
1031debfc3dSmrg return 0; /* Not used for C. */
1041debfc3dSmrg }
1051debfc3dSmrg
1061debfc3dSmrg /* Number of extra output files that lang_specific_pre_link may generate. */
1071debfc3dSmrg int lang_specific_extra_outfiles = 0; /* Not used for C. */
108