summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-17 21:27:48 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-17 21:27:48 +0000
commitd7a6361cd80444542cf357a49ac38310bfafcb84 (patch)
tree9f973f3feda5485a01017eef4242e7336e209c39
parentae5449f85ea402c44965d0f9e3df1cceaab6d91d (diff)
downloadppe42-gcc-d7a6361cd80444542cf357a49ac38310bfafcb84.tar.gz
ppe42-gcc-d7a6361cd80444542cf357a49ac38310bfafcb84.zip
* gospec.c (lang_specific_driver): If linking, and no -o option
was used, add one. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184351 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/go/ChangeLog5
-rw-r--r--gcc/go/gospec.c58
2 files changed, 41 insertions, 22 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index 255b3f55424..fe896ab2bca 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,8 @@
+2012-02-17 Ian Lance Taylor <iant@google.com>
+
+ * gospec.c (lang_specific_driver): If linking, and no -o option
+ was used, add one.
+
2012-02-14 Ian Lance Taylor <iant@google.com>
PR go/48411
diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c
index 8e8aa2dd2de..20372f0f470 100644
--- a/gcc/go/gospec.c
+++ b/gcc/go/gospec.c
@@ -109,6 +109,11 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
/* Whether the -o option was used. */
bool saw_opt_o = false;
+ /* Whether the -c option was used. Also used for -E, -fsyntax-only,
+ in general anything which implies only compilation and not
+ linking. */
+ bool saw_opt_c = false;
+
/* Whether the -S option was used. */
bool saw_opt_S = false;
@@ -172,6 +177,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
case OPT_fsyntax_only:
/* Don't specify libraries if we won't link, since that would
cause a warning. */
+ saw_opt_c = true;
library = -1;
break;
@@ -272,31 +278,39 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
j++;
}
- /* If we are not linking, add a -o option. This is because we need
+ /* If we didn't see a -o option, add one. This is because we need
the driver to pass all .go files to go1. Without a -o option the
- driver will invoke go1 separately for each input file. */
- if (library < 0 && first_go_file != NULL && !saw_opt_o)
+ driver will invoke go1 separately for each input file. FIXME:
+ This should probably use some other interface to force the driver
+ to set combine_inputs. */
+ if (first_go_file != NULL && !saw_opt_o)
{
- const char *base;
- int baselen;
- int alen;
- char *out;
-
- base = lbasename (first_go_file);
- baselen = strlen (base) - 3;
- alen = baselen + 3;
- out = XNEWVEC (char, alen);
- memcpy (out, base, baselen);
- /* The driver will convert .o to some other suffix (e.g., .obj)
- if appropriate. */
- out[baselen] = '.';
- if (saw_opt_S)
- out[baselen + 1] = 's';
+ if (saw_opt_c || saw_opt_S)
+ {
+ const char *base;
+ int baselen;
+ int alen;
+ char *out;
+
+ base = lbasename (first_go_file);
+ baselen = strlen (base) - 3;
+ alen = baselen + 3;
+ out = XNEWVEC (char, alen);
+ memcpy (out, base, baselen);
+ /* The driver will convert .o to some other suffix (e.g.,
+ .obj) if appropriate. */
+ out[baselen] = '.';
+ if (saw_opt_S)
+ out[baselen + 1] = 's';
+ else
+ out[baselen + 1] = 'o';
+ out[baselen + 2] = '\0';
+ generate_option (OPT_o, out, 1, CL_DRIVER,
+ &new_decoded_options[j]);
+ }
else
- out[baselen + 1] = 'o';
- out[baselen + 2] = '\0';
- generate_option (OPT_o, out, 1, CL_DRIVER,
- &new_decoded_options[j]);
+ generate_option (OPT_o, "a.out", 1, CL_DRIVER,
+ &new_decoded_options[j]);
j++;
}
OpenPOWER on IntegriCloud