g++ frontend weirdness

Jim Wilson wilson@cygnus.com
Fri Apr 17 15:21:00 GMT 1998


Jeff Law mentioned an existing patch.  I must have missed that.  I have
been working on my own patch for this problem, and I have something that
I think is reasonable.

Fri Apr 17 13:24:28 1998  Jim Wilson  <wilson@cygnus.com>

	* gcc.c (lang_specific_driver): Add new parm type to prototype.
	(added_libraries): New file scope static variable.
	(process_command): Initialize added_libraries.  Pass it to
	lang_specific_driver.
	(main): Use added_libraries in check for no input files.
	
Fri Apr 17 13:24:28 1998  Jim Wilson  <wilson@cygnus.com>

	* g++spec.c (lang_specific_driver): New argument in_added_libraries.
	New local added_libraries.  Increment count when add library to
	arglist.

Fri Apr 17 13:24:28 1998  Jim Wilson  <wilson@cygnus.com>

	* g77spec.c (lang_specific_driver): New argument in_added_libraries.
	New local added_libraries.  Increment count when add library to
	arglist.

Index: gcc.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/gcc.c,v
retrieving revision 1.25
diff -p -r1.25 gcc.c
*** gcc.c	1998/04/08 22:39:36	1.25
--- gcc.c	1998/04/17 19:40:34
*************** char *xmalloc ();
*** 265,271 ****
  char *xrealloc ();
  
  #ifdef LANG_SPECIFIC_DRIVER
! extern void lang_specific_driver PROTO ((void (*) (), int *, char ***));
  #endif
  
  /* Specs are strings containing lines, each of which (if not blank)
--- 265,271 ----
  char *xrealloc ();
  
  #ifdef LANG_SPECIFIC_DRIVER
! extern void lang_specific_driver PROTO ((void (*) (), int *, char ***, int *));
  #endif
  
  /* Specs are strings containing lines, each of which (if not blank)
*************** static struct infile *infiles;
*** 2291,2296 ****
--- 2291,2301 ----
  
  static int n_infiles;
  
+ /* This counts the number of libraries added by LANG_SPECIFIC_DRIVER, so that
+    we can tell if there were any user supplied any files or libraries.  */
+ 
+ static int added_libraries;
+ 
  /* And a vector of corresponding output files is made up later.  */
  
  static char **outfiles;
*************** process_command (argc, argv)
*** 2373,2378 ****
--- 2378,2384 ----
  
    n_switches = 0;
    n_infiles = 0;
+   added_libraries = 0;
  
    /* Figure compiler version from version string.  */
  
*************** process_command (argc, argv)
*** 2515,2521 ****
  
  #ifdef LANG_SPECIFIC_DRIVER
    /* Do language-specific adjustment/addition of flags.  */
!   lang_specific_driver (fatal, &argc, &argv);
  #endif
  
    /* Scan argv twice.  Here, the first time, just count how many switches
--- 2521,2527 ----
  
  #ifdef LANG_SPECIFIC_DRIVER
    /* Do language-specific adjustment/addition of flags.  */
!   lang_specific_driver (fatal, &argc, &argv, &added_libraries);
  #endif
  
    /* Scan argv twice.  Here, the first time, just count how many switches
*************** main (argc, argv)
*** 4696,4702 ****
  	exit (0);
      }
  
!   if (n_infiles == 0)
      fatal ("No input files");
  
    /* Make a place to record the compiler output file names
--- 4702,4708 ----
  	exit (0);
      }
  
!   if (n_infiles == added_libraries)
      fatal ("No input files");
  
    /* Make a place to record the compiler output file names
Index: cp/g++spec.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/g++spec.c,v
retrieving revision 1.5
diff -p -r1.5 g++spec.c
*** g++spec.c	1998/03/31 13:25:23	1.5
--- g++spec.c	1998/04/17 19:40:38
*************** Boston, MA 02111-1307, USA.  */
*** 38,47 ****
  extern char *xmalloc PROTO((size_t));
  
  void
! lang_specific_driver (fn, in_argc, in_argv)
       void (*fn)();
       int *in_argc;
       char ***in_argv;
  {
    int i, j;
  
--- 38,48 ----
  extern char *xmalloc PROTO((size_t));
  
  void
! lang_specific_driver (fn, in_argc, in_argv, in_added_libraries)
       void (*fn)();
       int *in_argc;
       char ***in_argv;
+      int *in_added_libraries;
  {
    int i, j;
  
*************** lang_specific_driver (fn, in_argc, in_ar
*** 88,99 ****
    /* The argument list.  */
    char **argv;
  
    /* The total number of arguments with the new stuff.  */
    int num_args = 1;
  
    argc = *in_argc;
    argv = *in_argv;
! 
  
    args = (int *) xmalloc (argc * sizeof (int));
    bzero ((char *) args, argc * sizeof (int));
--- 89,103 ----
    /* The argument list.  */
    char **argv;
  
+   /* The number of libraries added in.  */
+   int added_libraries;
+ 
    /* The total number of arguments with the new stuff.  */
    int num_args = 1;
  
    argc = *in_argc;
    argv = *in_argv;
!   added_libraries = *in_added_libraries;
  
    args = (int *) xmalloc (argc * sizeof (int));
    bzero ((char *) args, argc * sizeof (int));
*************** lang_specific_driver (fn, in_argc, in_ar
*** 231,241 ****
  
    /* Add `-lstdc++' if we haven't already done so.  */
    if (library)
!     arglist[j++] = "-lstdc++";
    if (saw_math)
      arglist[j++] = saw_math;
    else if (library)
!     arglist[j++] = MATH_LIBRARY;
    if (saw_libc)
      arglist[j++] = saw_libc;
  
--- 235,251 ----
  
    /* Add `-lstdc++' if we haven't already done so.  */
    if (library)
!     {
!       arglist[j++] = "-lstdc++";
!       added_libraries++;
!     }
    if (saw_math)
      arglist[j++] = saw_math;
    else if (library)
!     {
!       arglist[j++] = MATH_LIBRARY;
!       added_libraries++;
!     }
    if (saw_libc)
      arglist[j++] = saw_libc;
  
*************** lang_specific_driver (fn, in_argc, in_ar
*** 243,246 ****
--- 253,257 ----
  
    *in_argc = j;
    *in_argv = arglist;
+   *in_added_libraries = added_libraries;
  }
Index: f/g77spec.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/f/g77spec.c,v
retrieving revision 1.1
diff -p -r1.1 g77spec.c
*** g77spec.c	1997/10/13 18:09:13	1.1
--- g77spec.c	1998/04/17 20:21:12
*************** Boston, MA 02111-1307, USA.  */
*** 51,60 ****
  extern char *xmalloc PROTO((size_t));
  
  void
! lang_specific_driver (fn, in_argc, in_argv)
       void (*fn)();
       int *in_argc;
       char ***in_argv;
  {
    int i, j;
  
--- 51,61 ----
  extern char *xmalloc PROTO((size_t));
  
  void
! lang_specific_driver (fn, in_argc, in_argv, in_added_libraries)
       void (*fn)();
       int *in_argc;
       char ***in_argv;
+      int *in_added_libraries;
  {
    int i, j;
  
*************** lang_specific_driver (fn, in_argc, in_ar
*** 101,111 ****
--- 102,116 ----
    /* The argument list.  */
    char **argv;
  
+   /* The number of libraries added in.  */
+   int added_libraries;
+ 
    /* The total number of arguments with the new stuff.  */
    int num_args = 1;
  
    argc = *in_argc;
    argv = *in_argv;
+   added_libraries = *in_added_libraries;
  
    args = (int *) xmalloc (argc * sizeof (int));
    bzero ((char *) args, argc * sizeof (int));
*************** lang_specific_driver (fn, in_argc, in_ar
*** 254,264 ****
  
    /* Add `-lf2c' if we haven't already done so.  */
    if (library)
!     arglist[j++] = FORTRAN_LIBRARY;
    if (saw_math)
      arglist[j++] = saw_math;
    else if (library)
!     arglist[j++] = MATH_LIBRARY;
    if (saw_libc)
      arglist[j++] = saw_libc;
  
--- 259,275 ----
  
    /* Add `-lf2c' if we haven't already done so.  */
    if (library)
!     {
!       arglist[j++] = FORTRAN_LIBRARY;
!       added_libraries++;
!     }
    if (saw_math)
      arglist[j++] = saw_math;
    else if (library)
!     {
!       arglist[j++] = MATH_LIBRARY;
!       added_libraries++;
!     }
    if (saw_libc)
      arglist[j++] = saw_libc;
  
*************** lang_specific_driver (fn, in_argc, in_ar
*** 266,269 ****
--- 277,281 ----
  
    *in_argc = j;
    *in_argv = arglist;
+   *in_added_libraries = added_libraries;
  }



More information about the Gcc-bugs mailing list