This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

generalized LANG_SPECIFIC_DRIVER hooks for gcc.c


I just checked the following patch into egcs.

This is a patch to add another hook in gcc.c to support the
LANG_SPECIFIC_DRIVER feature.  This is used to build the
G++ front-end.  I need these hooks to build a similar Java
front-end.  Specifically, I have the option:
	--main=CLASSNAME
to generate a main() function that calls the main method of
CLASSNAME.

If any languages besides c++ and f77 use LANG_SPECIFIC_DRIVER,
they need to be updated, just like g++specs.c.
(I have updated gcc/f/g77spec.c.)

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner

	* gcc.c (lang_specific_pre_link):  New LANG_SPECIFIC_DRIVER function.
	(lang_specific_extra_outfiles):  New LANG_SPECIFIC_DRIVER variable.
	(do_spec, input_filename, input_filename_length):  Make public.
	(main):  Adjust outfiles allocation by lang_specific_extra_outfiles.
	Call lang_specific_pre_link befor elinking.

	* g++spec.c (lang_specific_pre_link, lang_specific_extra_ofiles):
	Define - update needed by gcc.c change.

	* g77spec.c (lang_specific_pre_link, lang_specific_extra_ofiles):
	Define - update needed by gcc.c change.

Index: gcc.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/gcc.c,v
retrieving revision 1.224
diff -u -r1.224 gcc.c
--- gcc.c	1998/05/31 19:36:49	1.224
+++ gcc.c	1998/06/04 19:24:12
@@ -243,7 +243,7 @@
 static char *handle_braces	PROTO((char *));
 static char *save_string	PROTO((char *, int));
 static char *concat		PVPROTO((char *, ...));
-static int do_spec		PROTO((char *));
+extern int do_spec		PROTO((char *));
 static int do_spec_1		PROTO((char *, int, char *));
 static char *find_file		PROTO((char *));
 static int is_directory		PROTO((char *, char *, int));
@@ -265,7 +265,14 @@
 char *xrealloc ();
 
 #ifdef LANG_SPECIFIC_DRIVER
+/* Called before processing to change/add/remove arguments. */
 extern void lang_specific_driver PROTO ((void (*) PVPROTO((char *, ...)), int *, char ***, int *));
+
+/* Called before linking.  Returns 0 on success and -1 on failure. */
+extern int lang_specific_pre_link ();
+
+/* Number of extra output files that lang_specific_pre_link may generate. */
+extern int lang_specific_extra_ofiles;
 #endif
 
 /* Specs are strings containing lines, each of which (if not blank)
@@ -3477,9 +3484,9 @@
    sans all directory names, and basename_length is the number
    of characters starting there excluding the suffix .c or whatever.  */
 
-static char *input_filename;
+char *input_filename;
 static int input_file_number;
-static size_t input_filename_length;
+size_t input_filename_length;
 static int basename_length;
 static char *input_basename;
 static char *input_suffix;
@@ -3509,7 +3516,7 @@
 /* Process the spec SPEC and run the commands specified therein.
    Returns 0 if the spec is successfully processed; -1 if failed.  */
 
-static int
+int
 do_spec (spec)
      char *spec;
 {
@@ -5115,7 +5122,11 @@
   /* Make a place to record the compiler output file names
      that correspond to the input files.  */
 
-  outfiles = (char **) xmalloc (n_infiles * sizeof (char *));
+  i = n_infiles;
+#ifdef LANG_SPECIFIC_DRIVER
+  i += lang_specific_extra_ofiles;
+#endif
+  outfiles = (char **) xmalloc (i * sizeof (char *));
   bzero ((char *) outfiles, n_infiles * sizeof (char *));
 
   /* Record which files were specified explicitly as link input.  */
@@ -5210,6 +5221,12 @@
       /* If this compilation succeeded, don't delete those files later.  */
       clear_failure_queue ();
     }
+
+#ifdef LANG_SPECIFIC_DRIVER
+  if (error_count == 0
+      && lang_specific_pre_link ())
+    error_count++;
+#endif
 
   /* Run ld to link all the compiler output files.  */
 
Index: cp/g++spec.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/g++spec.c,v
retrieving revision 1.10
diff -u -r1.10 g++spec.c
--- g++spec.c	1998/05/08 20:49:54	1.10
+++ g++spec.c	1998/06/04 19:24:12
@@ -255,3 +255,12 @@
   *in_argv = arglist;
   *in_added_libraries = added_libraries;
 }
+
+/* Called before linking.  Returns 0 on success and -1 on failure. */
+int lang_specific_pre_link ()  /* Not used for C++. */
+{
+  return 0;
+}
+
+/* Number of extra output files that lang_specific_pre_link may generate. */
+int lang_specific_extra_ofiles = 0;  /* Not used for C++. */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]