diff options
author | Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> | 2001-08-02 12:26:00 +0000 |
---|---|---|
committer | Rainer Orth <ro@gcc.gnu.org> | 2001-08-02 12:26:00 +0000 |
commit | 578672a2676308528001f385e2f3773595ec3387 (patch) | |
tree | 9d31c155fc6533acc82d406f6aeb96eb7ad549f9 /gcc/java | |
parent | 1dbb6023c73cfb340b24d8c81cf31f41f8f1805b (diff) | |
download | gcc-578672a2676308528001f385e2f3773595ec3387.zip gcc-578672a2676308528001f385e2f3773595ec3387.tar.gz gcc-578672a2676308528001f385e2f3773595ec3387.tar.bz2 |
re PR java/227 (mips-tfile:internal error (when compiling java code))
* gcc.c (set_collect_gcc_options): New function, split out from
main.
Ignore elided switches.
(do_spec_1): Invoke before executing command.
(set_input): Export.
Move declaration ...
* gcc.h (set_input): ... here.
* config/alpha/osf.h (ASM_FINAL_SPEC): Use %U.s to refer to input
file.
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.
From-SVN: r44572
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/java/jvgenmain.c | 13 | ||||
-rw-r--r-- | gcc/java/jvspec.c | 18 |
3 files changed, 33 insertions, 9 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 3c02e80..24f5c40 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -22,6 +22,17 @@ syntax error encountered during class definition. Fixes PR java/2956 +2001-08-02 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> + + * 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. + 2001-07-18 Tom Tromey <tromey@redhat.com> For PR java/2812: diff --git a/gcc/java/jvgenmain.c b/gcc/java/jvgenmain.c index ab43ddd..9a42571 100644 --- a/gcc/java/jvgenmain.c +++ b/gcc/java/jvgenmain.c @@ -61,14 +61,14 @@ static void usage (const char *) ATTRIBUTE_NORETURN; 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) 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); diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index 44342cf..761c580 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -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}\ @@ -68,8 +68,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:%U.s}} |\n\ + %{!S:as %a %Y -o %d%w%u%O %{!pipe:%U.s} %A\n }"; /* Return full path name of spec file if it is in DIR, or NULL if not. */ @@ -529,8 +529,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) { |