diff options
author | Ian Lance Taylor <iant@google.com> | 2012-02-17 21:27:48 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-02-17 21:27:48 +0000 |
commit | f7b675752a96c76ba7800ffeceff196af36f8fa4 (patch) | |
tree | 9f973f3feda5485a01017eef4242e7336e209c39 /gcc/go | |
parent | 904bfee88359ae0c15dea52e7a84f61211479b2f (diff) | |
download | gcc-f7b675752a96c76ba7800ffeceff196af36f8fa4.zip gcc-f7b675752a96c76ba7800ffeceff196af36f8fa4.tar.gz gcc-f7b675752a96c76ba7800ffeceff196af36f8fa4.tar.bz2 |
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
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/go/gospec.c | 58 |
2 files changed, 41 insertions, 22 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 255b3f5..fe896ab 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 8e8aa2dd..20372f0 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++; } |