152284Sobrien/* Specific flags and argument handling of the C front-end. 2132718Skan Copyright (C) 1999, 2001, 2003 Free Software Foundation, Inc. 352284Sobrien 490075SobrienThis file is part of GCC. 552284Sobrien 690075SobrienGCC is free software; you can redistribute it and/or modify it under 790075Sobrienthe terms of the GNU General Public License as published by the Free 890075SobrienSoftware Foundation; either version 2, or (at your option) any later 990075Sobrienversion. 1052284Sobrien 1190075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY 1290075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or 1390075SobrienFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1490075Sobrienfor more details. 1552284Sobrien 1652284SobrienYou should have received a copy of the GNU General Public License 1790075Sobrienalong with GCC; see the file COPYING. If not, write to the Free 18169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 19169689Skan02110-1301, USA. */ 2052284Sobrien 2152284Sobrien#include "config.h" 2252284Sobrien#include "system.h" 23132718Skan#include "coretypes.h" 24132718Skan#include "tm.h" 2590075Sobrien#include "gcc.h" 2652284Sobrien 2790075Sobrien/* Filter argc and argv before processing by the gcc driver proper. */ 2852284Sobrienvoid 29132718Skanlang_specific_driver (int *in_argc ATTRIBUTE_UNUSED, 30132718Skan const char *const **in_argv ATTRIBUTE_UNUSED, 31132718Skan int *in_added_libraries ATTRIBUTE_UNUSED) 3252284Sobrien{ 33169689Skan /* Systems which use the NeXT runtime by default should arrange 34169689Skan for the shared libgcc to be used when -fgnu-runtime is passed 35169689Skan through specs. */ 36169689Skan#if defined(ENABLE_SHARED_LIBGCC) && ! defined(NEXT_OBJC_RUNTIME) 3790075Sobrien int i; 3890075Sobrien 3990075Sobrien /* The new argument list will be contained in this. */ 4090075Sobrien const char **arglist; 4190075Sobrien 4290075Sobrien /* True if we should add -shared-libgcc to the command-line. */ 4390075Sobrien int shared_libgcc = 0; 4490075Sobrien 4590075Sobrien /* The total number of arguments with the new stuff. */ 4690075Sobrien int argc; 4790075Sobrien 4890075Sobrien /* The argument list. */ 4990075Sobrien const char *const *argv; 5090075Sobrien 5190075Sobrien argc = *in_argc; 5290075Sobrien argv = *in_argv; 5390075Sobrien 5490075Sobrien for (i = 1; i < argc; i++) 5590075Sobrien { 5690075Sobrien if (argv[i][0] == '-') 5790075Sobrien { 5890075Sobrien if (strcmp (argv[i], "-static-libgcc") == 0 5990075Sobrien || strcmp (argv[i], "-static") == 0) 6090075Sobrien return; 6190075Sobrien } 6290075Sobrien else 6390075Sobrien { 64117395Skan int len; 6590075Sobrien 6690075Sobrien /* If the filename ends in .m or .mi, we are compiling ObjC 6790075Sobrien and want to pass -shared-libgcc. */ 6890075Sobrien len = strlen (argv[i]); 6990075Sobrien if ((len > 2 && argv[i][len - 2] == '.' && argv[i][len - 1] == 'm') 7090075Sobrien || (len > 3 && argv[i][len - 3] == '.' && argv[i][len - 2] == 'm' 7190075Sobrien && argv[i][len - 1] == 'i')) 7290075Sobrien shared_libgcc = 1; 7390075Sobrien } 7490075Sobrien } 7590075Sobrien 7690075Sobrien if (shared_libgcc) 7790075Sobrien { 7890075Sobrien /* Make sure to have room for the trailing NULL argument. */ 79169689Skan arglist = XNEWVEC (const char *, argc + 2); 8090075Sobrien 8190075Sobrien i = 0; 8290075Sobrien do 8390075Sobrien { 8490075Sobrien arglist[i] = argv[i]; 8590075Sobrien i++; 8690075Sobrien } 8790075Sobrien while (i < argc); 8890075Sobrien 8990075Sobrien arglist[i++] = "-shared-libgcc"; 9090075Sobrien 9190075Sobrien arglist[i] = NULL; 9290075Sobrien 9390075Sobrien *in_argc = i; 9490075Sobrien *in_argv = arglist; 9590075Sobrien } 9690075Sobrien#endif 9752284Sobrien} 9852284Sobrien 9990075Sobrien/* Called before linking. Returns 0 on success and -1 on failure. */ 10052284Sobrienint 101132718Skanlang_specific_pre_link (void) 10252284Sobrien{ 10390075Sobrien return 0; /* Not used for C. */ 10452284Sobrien} 10552284Sobrien 10690075Sobrien/* Number of extra output files that lang_specific_pre_link may generate. */ 10790075Sobrienint lang_specific_extra_outfiles = 0; /* Not used for C. */ 108