On Sun, Jan 2, 2011 at 3:03 PM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Sun, Jan 2, 2011 at 2:05 PM, H.J. Lu <hjl.to...@gmail.com> wrote: >> On Sun, Jan 2, 2011 at 1:18 PM, Ian Lance Taylor <i...@google.com> wrote: >>> Richard Guenther <richard.guent...@gmail.com> writes: >>> >>>> On Sun, Jan 2, 2011 at 9:24 PM, Ian Lance Taylor <i...@google.com> wrote: >>>>> Richard Guenther <richard.guent...@gmail.com> writes: >>>>> >>>>>> Your small patch removing have_o || is ok I guess. >>>>> >>>>> Wait. That will change the behaviour of >>>>> gcc -o foo.o -c f1.c f2.c f3.c >>>>> Is that what we want? >>>> >>>> Does it? I don't think so. Most of the combine handling was removed by >>>> the patch that caused the regression, so -o and -c doesn't combine anymore >>>> (with multiple sources). >>> >>> Sorry, you're right. The difference is that @c has 0 for the combinable >>> field, and @assembler has 1. Before H.J.'s change, this worked >>> gcc -c -o f.o f1.s f2.s >>> After his change, it does not. That is probably not a big deal. >>> >>> I wonder why @assembler has 1 for combinable? It seems to have been set >>> to 1 when the combinable field was added in 2004-04-05 with -combine. >>> Now that -combine has been removed, if the combinable field for >>> @assembler were 0, it seems to me that H.J.'s problem would also be >>> fixed. And it seems to me that it should be 0. >>> >>> >>>>> Also, right now the gccgo driver depends on the -o behaviour to combine >>>>> inputs. If that changes, the driver will need to provide some other way >>>>> to let the frontend force inputs to be combined. >>>> >>>> For go it isn't equivalent to do gcgo -c t1.go; gcgo -c t2.go; gcgo t1.o >>>> t2.o >>>> compared to gcgo t1.go t2.go? >>> >>> No, it is not. All .go input files must be passed to go1 at once. >>> H.J.'s patch has indeed broken gccgo. >>> >> >> Can you try this patch? >> >> Thanks. >> >> >> -- >> H.J. >> --- >> diff --git a/gcc/gcc.c b/gcc/gcc.c >> index 0d633a4..d0b2c96 100644 >> --- a/gcc/gcc.c >> +++ b/gcc/gcc.c >> @@ -6582,7 +6582,20 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR >> A P >> ARTICULAR PURPOSE.\n\n" >> >> explicit_link_files = XCNEWVEC (char, n_infiles); >> >> + /* Check if we should combine inputs. */ >> combine_inputs = flag_wpa; >> + if (!combine_inputs) >> + for (i = 1; i < decoded_options_count; i++) >> + { >> + if (decoded_options[i].opt_index == OPT_x) >> + { >> + struct compiler *compiler >> + = lookup_compiler (NULL, 0, decoded_options[i].arg); >> + if (compiler) >> + combine_inputs = compiler->combinable; >> + break; >> + } >> + } >> >> for (i = 0; (int) i < n_infiles; i++) >> { >> > > This doesn't work for go since -xgo isn't used with gccgo. Is there > a way to tell what the default language is for a gcc driver? >
I am testing this patch with all languages on Linux/x86-64. -- H.J. --- gcc/ 2011-01-02 H.J. Lu <hongjiu...@intel.com> PR driver/47137 * gcc.c (default_language): New. (main): Lookup compiler to check if we should combine inputs. * gcc.h (default_language): New. gcc/go/ 2011-01-02 H.J. Lu <hongjiu...@intel.com> PR driver/47137 * gospec.c (lang_specific_driver): Set default_language if needed.
gcc/ 2011-01-02 H.J. Lu <hongjiu...@intel.com> PR driver/47137 * gcc.c (default_language): New. (main): Lookup compiler to check if we should combine inputs. * gcc.h (default_language): New. gcc/go/ 2011-01-02 H.J. Lu <hongjiu...@intel.com> PR driver/47137 * gospec.c (lang_specific_driver): Set default_language if needed. diff --git a/gcc/gcc.c b/gcc/gcc.c index 0d633a4..dc09937 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -2810,6 +2810,10 @@ static struct infile *infiles; int n_infiles; +/* Default language. */ + +const char *default_language; + static int n_infiles_alloc; /* True if multiple input files are being compiled to a single @@ -6582,7 +6586,23 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" explicit_link_files = XCNEWVEC (char, n_infiles); + /* Check if we should combine inputs. */ combine_inputs = flag_wpa; + if (!combine_inputs) + { + struct compiler *compiler = NULL; + for (i = 1; i < decoded_options_count; i++) + if (decoded_options[i].opt_index == OPT_x) + { + compiler = lookup_compiler (NULL, 0, + decoded_options[i].arg); + break; + } + if (!compiler && default_language) + compiler = lookup_compiler (NULL, 0, default_language); + if (compiler) + combine_inputs = compiler->combinable; + } for (i = 0; (int) i < n_infiles; i++) { diff --git a/gcc/gcc.h b/gcc/gcc.h index 091d9c8..7bad86b 100644 --- a/gcc/gcc.h +++ b/gcc/gcc.h @@ -49,6 +49,8 @@ extern int lang_specific_pre_link (void); extern int n_infiles; +extern const char *default_language; + /* Number of extra output files that lang_specific_pre_link may generate. */ extern int lang_specific_extra_outfiles; diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c index 7d21ace..3e483e9 100644 --- a/gcc/go/gospec.c +++ b/gcc/go/gospec.c @@ -109,6 +109,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* Whether the -o option was used. */ bool saw_opt_o = false; + /* Whether the -x option was used. */ + bool saw_opt_x = false; + /* The first input file with an extension of .go. */ const char *first_go_file = NULL; @@ -150,6 +153,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, break; case OPT_x: + saw_opt_x = true; if (library == 0 && strcmp (arg, "go") == 0) library = 1; break; @@ -207,6 +211,10 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, } } + /* Set default_language if needed. */ + if (!saw_opt_x) + default_language = "go"; + /* There's no point adding -shared-libgcc if we don't have a shared libgcc. */ #ifndef ENABLE_SHARED_LIBGCC