Commit f7b67575 by Ian Lance Taylor Committed by Ian Lance Taylor

gospec.c (lang_specific_driver): If linking, and no -o option was used, add one.

	* gospec.c (lang_specific_driver): If linking, and no -o option
	was used, add one.

From-SVN: r184351
parent 904bfee8
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> 2012-02-14 Ian Lance Taylor <iant@google.com>
PR go/48411 PR go/48411
......
...@@ -109,6 +109,11 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, ...@@ -109,6 +109,11 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
/* Whether the -o option was used. */ /* Whether the -o option was used. */
bool saw_opt_o = false; 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. */ /* Whether the -S option was used. */
bool saw_opt_S = false; bool saw_opt_S = false;
...@@ -172,6 +177,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, ...@@ -172,6 +177,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
case OPT_fsyntax_only: case OPT_fsyntax_only:
/* Don't specify libraries if we won't link, since that would /* Don't specify libraries if we won't link, since that would
cause a warning. */ cause a warning. */
saw_opt_c = true;
library = -1; library = -1;
break; break;
...@@ -272,31 +278,39 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, ...@@ -272,31 +278,39 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
j++; 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 the driver to pass all .go files to go1. Without a -o option the
driver will invoke go1 separately for each input file. */ driver will invoke go1 separately for each input file. FIXME:
if (library < 0 && first_go_file != NULL && !saw_opt_o) 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; if (saw_opt_c || saw_opt_S)
int baselen; {
int alen; const char *base;
char *out; int baselen;
int alen;
base = lbasename (first_go_file); char *out;
baselen = strlen (base) - 3;
alen = baselen + 3; base = lbasename (first_go_file);
out = XNEWVEC (char, alen); baselen = strlen (base) - 3;
memcpy (out, base, baselen); alen = baselen + 3;
/* The driver will convert .o to some other suffix (e.g., .obj) out = XNEWVEC (char, alen);
if appropriate. */ memcpy (out, base, baselen);
out[baselen] = '.'; /* The driver will convert .o to some other suffix (e.g.,
if (saw_opt_S) .obj) if appropriate. */
out[baselen + 1] = 's'; 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 else
out[baselen + 1] = 'o'; generate_option (OPT_o, "a.out", 1, CL_DRIVER,
out[baselen + 2] = '\0'; &new_decoded_options[j]);
generate_option (OPT_o, out, 1, CL_DRIVER,
&new_decoded_options[j]);
j++; j++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment