aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/Makefile.in7
-rw-r--r--gcc/main.c35
-rw-r--r--gcc/toplev.c15
-rw-r--r--gcc/toplev.h1
5 files changed, 59 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 029af4b..6946e61 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2001-03-05 Fergus Henderson <fjh@cs.mu.oz.au>
+
+ Put main() in a separate file, so that the language
+ front-end can use a different main().
+
+ * main.c: New.
+ * toplev.c: (main): Rename as toplev_main.
+ * toplev.h: Declare toplev_main.
+ * Makefile.in (OBJS): add toplev.o.
+ (BACKEND): remove toplev.o, add main.o.
+
2001-03-04 Neil Booth <neil@daikokuya.demon.co.uk>
* cppfiles.c (search_from): Special case the empty string.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9f48da4..365a644 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -746,11 +746,11 @@ OBJS = \
recog.o reg-stack.o regclass.o regmove.o regrename.o reload.o \
reload1.o reorg.o resource.o rtl.o rtlanal.o sbitmap.o sched-deps.o \
sched-ebb.o sched-rgn.o sched-vis.o sdbout.o sibcall.o simplify-rtx.o \
- splay-tree.o ssa.o stmt.o stor-layout.o stringpool.o timevar.o tree.o \
- unroll.o varasm.o varray.o version.o xcoffout.o \
+ splay-tree.o ssa.o stmt.o stor-layout.o stringpool.o timevar.o \
+ toplev.o tree.o unroll.o varasm.o varray.o version.o xcoffout.o \
$(GGC) $(out_object_file) $(EXTRA_OBJS)
-BACKEND = toplev.o libbackend.a
+BACKEND = main.o libbackend.a
# GEN files are listed separately, so they can be built before doing parallel
# makes for cc1 or cc1plus. Otherwise sequent parallel make attempts to load
@@ -1348,6 +1348,7 @@ toplev.o : toplev.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) function.h \
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(MAYBE_USE_COLLECT2) \
-DTARGET_NAME=\"$(target_alias)\" \
-c $(srcdir)/toplev.c
+main.o : main.c toplev.h
rtl.o : rtl.c $(GCONFIG_H) system.h $(RTL_H) bitmap.h $(GGC_H) toplev.h
$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
diff --git a/gcc/main.c b/gcc/main.c
new file mode 100644
index 0000000..34f7aa8
--- /dev/null
+++ b/gcc/main.c
@@ -0,0 +1,35 @@
+/* main.c: defines main() for cc1, cc1plus, etc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "gansidecl.h"
+#include "toplev.h"
+
+int main PARAMS ((int argc, char **argv));
+
+/* We define main() to call toplev_main(), which is defined in toplev.c.
+ We do this in a separate file in order to allow the language front-end
+ to define a different main(), if it so desires. */
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ return toplev_main (argc, argv);
+}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 73f1b8f..dd1321c 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -192,7 +192,7 @@ static void print_switch_values PARAMS ((FILE *, int, int, const char *,
const char *progname;
-/* Copy of arguments to main. */
+/* Copy of arguments to toplev_main. */
int save_argc;
char **save_argv;
@@ -4582,14 +4582,15 @@ independent_decode_option (argc, argv)
return 1;
}
-/* Entry point of cc1/c++. Decode command args, then call compile_file.
- Exit code is 35 if can't open files, 34 if fatal error,
- 33 if had nonfatal errors, else success. */
-
-extern int main PARAMS ((int, char **));
+/* Entry point of cc1, cc1plus, jc1, f771, etc.
+ Decode command args, then call compile_file.
+ Exit code is FATAL_EXIT_CODE if can't open files or if there were
+ any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
+
+ It is not safe to call this function more than once. */
int
-main (argc, argv)
+toplev_main (argc, argv)
int argc;
char **argv;
{
diff --git a/gcc/toplev.h b/gcc/toplev.h
index 44772f3..08c6112 100644
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -31,6 +31,7 @@ struct rtx_def;
#define skip_leading_substring(whole, part) \
(strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
+extern int toplev_main PARAMS ((int argc, char **argv));
extern int read_integral_parameter PARAMS ((const char *, const char *,
const int));
extern int count_error PARAMS ((int));