gccspec.c revision 117395
152284Sobrien/* Specific flags and argument handling of the C front-end. 290075Sobrien Copyright (C) 1999, 2001 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 1890075SobrienSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 1990075Sobrien02111-1307, USA. */ 2052284Sobrien 2152284Sobrien#include "config.h" 2252284Sobrien#include "system.h" 2390075Sobrien#include "gcc.h" 2452284Sobrien 2590075Sobrien/* Filter argc and argv before processing by the gcc driver proper. */ 2652284Sobrienvoid 2790075Sobrienlang_specific_driver (in_argc, in_argv, in_added_libraries) 2852284Sobrien int *in_argc ATTRIBUTE_UNUSED; 2990075Sobrien const char *const **in_argv ATTRIBUTE_UNUSED; 3052284Sobrien int *in_added_libraries ATTRIBUTE_UNUSED; 3152284Sobrien{ 3290075Sobrien#ifdef ENABLE_SHARED_LIBGCC 3390075Sobrien int i; 3490075Sobrien 3590075Sobrien /* The new argument list will be contained in this. */ 3690075Sobrien const char **arglist; 3790075Sobrien 3890075Sobrien /* True if we should add -shared-libgcc to the command-line. */ 3990075Sobrien int shared_libgcc = 0; 4090075Sobrien 4190075Sobrien /* The total number of arguments with the new stuff. */ 4290075Sobrien int argc; 4390075Sobrien 4490075Sobrien /* The argument list. */ 4590075Sobrien const char *const *argv; 4690075Sobrien 4790075Sobrien argc = *in_argc; 4890075Sobrien argv = *in_argv; 4990075Sobrien 5090075Sobrien for (i = 1; i < argc; i++) 5190075Sobrien { 5290075Sobrien if (argv[i][0] == '-') 5390075Sobrien { 5490075Sobrien if (strcmp (argv[i], "-static-libgcc") == 0 5590075Sobrien || strcmp (argv[i], "-static") == 0) 5690075Sobrien return; 5790075Sobrien } 5890075Sobrien else 5990075Sobrien { 60117395Skan int len; 6190075Sobrien 6290075Sobrien /* If the filename ends in .m or .mi, we are compiling ObjC 6390075Sobrien and want to pass -shared-libgcc. */ 6490075Sobrien len = strlen (argv[i]); 6590075Sobrien if ((len > 2 && argv[i][len - 2] == '.' && argv[i][len - 1] == 'm') 6690075Sobrien || (len > 3 && argv[i][len - 3] == '.' && argv[i][len - 2] == 'm' 6790075Sobrien && argv[i][len - 1] == 'i')) 6890075Sobrien shared_libgcc = 1; 6990075Sobrien } 7090075Sobrien } 7190075Sobrien 7290075Sobrien if (shared_libgcc) 7390075Sobrien { 7490075Sobrien /* Make sure to have room for the trailing NULL argument. */ 7590075Sobrien arglist = (const char **) xmalloc ((argc+2) * sizeof (char *)); 7690075Sobrien 7790075Sobrien i = 0; 7890075Sobrien do 7990075Sobrien { 8090075Sobrien arglist[i] = argv[i]; 8190075Sobrien i++; 8290075Sobrien } 8390075Sobrien while (i < argc); 8490075Sobrien 8590075Sobrien arglist[i++] = "-shared-libgcc"; 8690075Sobrien 8790075Sobrien arglist[i] = NULL; 8890075Sobrien 8990075Sobrien *in_argc = i; 9090075Sobrien *in_argv = arglist; 9190075Sobrien } 9290075Sobrien#endif 9352284Sobrien} 9452284Sobrien 9590075Sobrien/* Called before linking. Returns 0 on success and -1 on failure. */ 9652284Sobrienint 9752284Sobrienlang_specific_pre_link () 9852284Sobrien{ 9990075Sobrien return 0; /* Not used for C. */ 10052284Sobrien} 10152284Sobrien 10290075Sobrien/* Number of extra output files that lang_specific_pre_link may generate. */ 10390075Sobrienint lang_specific_extra_outfiles = 0; /* Not used for C. */ 104117395Skan 105117395Skan/* Table of language-specific spec functions. */ 106117395Skanconst struct spec_function lang_specific_spec_functions[] = 107117395Skan{ 108117395Skan { 0, 0 } 109117395Skan}; 110