This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


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

3.0.2 PATCH: Allow jvgenmain to work with ASM_FINAL_SPEC (version 3)


This is an updated version of

	http://gcc.gnu.org/ml/java-patches/2001-q3/msg00164.html

The buggy change to osf.h has been removed from the patch and the
underlying problem fixed differently, so this addresses Richard Kenner's
problem which lead to the reversion of the previous version:

	http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00853.html

The patch below has survived a full bootstrap and regression test on
alpha-dec-osf5.1.

The patch (and an acompanying update to

	http://gcc.gnu.org/ml/java-patches/2001-q3/msg00128.html

to be submitted shortly) finally enables libgcj support on Tru64 UNIX,
which worked in gcc 2.95, but got broken afterwards, so it fixes a
regression from that release.  I'd really like to get it into 3.0.2 for
that reason.

Ok for branch and mainline now?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University

Email: ro@TechFak.Uni-Bielefeld.DE


Mon Sep 24 16:44:08 2001  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* gcc.c (set_input): Export.
	Move declaration ...
	gcc.h (set_input): ... here.

	java:
	* jvspec.c (jvgenmain_spec): Cannot use %umain, breaks
	ASM_FINAL_SPEC.
	(lang_specific_pre_link): Use set_input to set input_filename.
	Append `main' here.
	* jvgenmain.c (usage): Append literal `main' to CLASSNAME.
	(main): Fix definition.
	Strip `main' from classname.
	Fixes PR java/227.

Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.205.2.20
diff -u -p -r1.205.2.20 gcc.c
--- gcc.c	2001/08/12 20:22:17	1.205.2.20
+++ gcc.c	2001/09/24 14:31:39
@@ -266,7 +267,6 @@ static void process_command		PARAMS ((in
 static int execute			PARAMS ((void));
 static void clear_args			PARAMS ((void));
 static void fatal_error			PARAMS ((int));
-static void set_input			PARAMS ((const char *));
 static void init_gcc_specs              PARAMS ((struct obstack *,
 						 const char *,
 						 const char *));
@@ -5395,7 +5456,7 @@ is_directory (path1, path2, linker)
 /* Set up the various global variables to indicate that we're processing
    the input file named FILENAME.  */
 
-static void
+void
 set_input (filename)
      const char *filename;
 {
Index: gcc/gcc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.h,v
retrieving revision 1.3.6.4
diff -u -p -r1.3.6.4 gcc.h
--- gcc.h	2001/08/12 20:22:18	1.3.6.4
+++ gcc.h	2001/09/24 14:43:17
@@ -33,6 +33,7 @@ extern void fatal PARAMS ((const char *,
      ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
 extern void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
 extern void pfatal_with_name PARAMS ((const char *)) ATTRIBUTE_NORETURN;
+extern void set_input PARAMS ((const char *));
 
 /* Spec files linked with gcc.c must provide definitions for these. */
 
Index: gcc/java/jvgenmain.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jvgenmain.c,v
retrieving revision 1.23.2.3
diff -u -p -r1.23.2.3 jvgenmain.c
--- jvgenmain.c	2001/08/12 20:22:20	1.23.2.3
+++ jvgenmain.c	2001/09/24 14:31:45
@@ -62,14 +62,14 @@ static void usage (const char *) ATTRIBU
 static void
 usage (const char *name)
 {
-  fprintf (stderr, "Usage: %s [OPTIONS]... CLASSNAME [OUTFILE]\n", name);
+  fprintf (stderr, "Usage: %s [OPTIONS]... CLASSNAMEmain [OUTFILE]\n", name);
   exit (1);
 }
 
 int
-main (int argc, const char **argv)
+main (int argc, char **argv)
 {
-  const char *classname;
+  char *classname, *p;
   FILE *stream;
   const char *mangled_classname;
   int i, last_arg;
@@ -92,6 +92,13 @@ main (int argc, const char **argv)
   last_arg = i;
 
   classname = argv[i];
+
+  /* gcj always appends `main' to classname.  We need to strip this here.  */
+  p = strrchr (classname, 'm');
+  if (p == NULL || p == classname || strcmp (p, "main") != 0)
+    usage (argv[0]);
+  else
+    *p = '\0';
 
   gcc_obstack_init (mangle_obstack);
   mangled_classname = do_mangle_classname (classname);
Index: gcc/java/jvspec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jvspec.c,v
retrieving revision 1.35.2.8
diff -u -p -r1.35.2.8 jvspec.c
--- jvspec.c	2001/08/12 20:22:20	1.35.2.8
+++ jvspec.c	2001/09/24 14:31:50
@@ -52,8 +52,8 @@ int lang_specific_extra_outfiles = 0;
 int shared_libgcc = 1;
 
 const char jvgenmain_spec[] =
-  "jvgenmain %{D*} %i %{!pipe:%umain.i} |\n\
-   cc1 %{!pipe:%Umain.i} %1 \
+  "jvgenmain %{D*} %b %{!pipe:%u.i} |\n\
+   cc1 %{!pipe:%U.i} %1 \
 		   %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
 		   %{g*} %{O*} \
 		   %{v:-version} %{pg:-p} %{p}\
@@ -67,8 +67,8 @@ const char jvgenmain_spec[] =
 		   %{f*} -fdollars-in-identifiers\
 		   %{aux-info*}\
 		   %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
-		   %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%Umain.s}} |\n\
-              %{!S:as %a %Y -o %d%w%umain%O %{!pipe:%Umain.s} %A\n }";
+		   %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+              %{!S:as %a %Y -o %d%w%u%O %{!pipe:%g.s} %A\n }";
 
 /* Return full path name of spec file if it is in DIR, or NULL if
    not.  */
@@ -528,8 +528,14 @@ lang_specific_pre_link ()
   int err;
   if (main_class_name == NULL)
     return 0;
-  input_filename = main_class_name;
-  input_filename_length = strlen (main_class_name);
+  /* Append `main' to make the filename unique and allow
+
+	gcj --main=hello -save-temps hello.java
+
+     to work.  jvgenmain needs to strip this `main' to arrive at the correct
+     class name.  Append dummy `.c' that can be stripped by set_input so %b
+     is correct.  */ 
+  set_input (concat (main_class_name, "main.c", NULL));
   err = do_spec (jvgenmain_spec);
   if (err == 0)
     {


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