diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/go/Make-lang.in | 12 | ||||
-rw-r--r-- | gcc/go/gccgo.texi | 13 | ||||
-rw-r--r-- | gcc/go/go-lang.c | 61 |
4 files changed, 86 insertions, 14 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index b68f4bb070b..d70dc40c4c6 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,17 @@ +2010-12-06 Ian Lance Taylor <iant@google.com> + + PR other/46789 + PR bootstrap/46812 + * go-lang.c (go_char_p): Define type and vectors. + (go_search_dirs): New static variable. + (go_langhook_handle_option): Use version and version/machine + directories for -L. + (go_langhook_post_options): Add non-specific -L paths. + * Make-lang.in (go/go-lang.o): Define DEFAULT_TARGET_VERSION and + DEFAULT_TARGET_MACHINE when compiling. + * gccgo.texi (Invoking gccgo): Only document -L for linking. + (Import and Export): Don't mention -L for finding import files. + 2010-12-03 Ian Lance Taylor <iant@google.com> PR bootstrap/46776 diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in index fc981d4a5fb..4d008161a1c 100644 --- a/gcc/go/Make-lang.in +++ b/gcc/go/Make-lang.in @@ -218,10 +218,16 @@ GO_IMPORT_H = go/gofrontend/import.h go/gofrontend/export.h go/go-backend.o: go/go-backend.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TREE_H) $(TM_H) $(TM_P_H) + go/go-lang.o: go/go-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(OPTS_H) \ - $(TREE_H) $(GIMPLE_H) $(GGC_H) $(TOPLEV_H) debug.h options.h \ - $(FLAGS_H) convert.h $(DIAGNOSTIC_H) langhooks.h $(LANGHOOKS_DEF_H) \ - $(EXCEPT_H) $(TARGET_H) $(GO_C_H) gt-go-go-lang.h gtype-go.h + $(TREE_H) $(GIMPLE_H) $(GGC_H) $(TOPLEV_H) debug.h options.h \ + $(FLAGS_H) convert.h $(DIAGNOSTIC_H) langhooks.h \ + $(LANGHOOKS_DEF_H) $(EXCEPT_H) $(TARGET_H) $(GO_C_H) \ + gt-go-go-lang.h gtype-go.h + $(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \ + -DDEFAULT_TARGET_VERSION=\"$(version)\" \ + -DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\" \ + -c $< $(OUTPUT_OPTION) GOINCLUDES = -I $(srcdir)/go -I $(srcdir)/go/gofrontend diff --git a/gcc/go/gccgo.texi b/gcc/go/gccgo.texi index 0e41261eec1..b6f8910a8db 100644 --- a/gcc/go/gccgo.texi +++ b/gcc/go/gccgo.texi @@ -154,8 +154,8 @@ compile time. @item -L@var{dir} @cindex @option{-L} -When compiling, synonymous with @option{-I}. When linking, specify a -library search directory, as with @command{gcc}. +When linking, specify a library search directory, as with +@command{gcc}. @item -fgo-prefix=@var{string} @cindex @option{-fgo-prefix} @@ -198,11 +198,10 @@ first one that it finds. @end table The compiler will search for these files in the directories named by -any @option{-I} or @option{-L} options, in order in which the -directories appear on the command line. The compiler will then search -several standard system directories. Finally the compiler will search -the current directory (to search the current directory earlier, use -@samp{-I.}). +any @option{-I} options, in order in which the directories appear on +the command line. The compiler will then search several standard +system directories. Finally the compiler will search the current +directory (to search the current directory earlier, use @samp{-I.}). The compiler will extract the export information directly from the compiled object file. The file @file{@var{gopackage}.gox} will diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c index 9c85ab7f7a2..0f3c1838f4b 100644 --- a/gcc/go/go-lang.c +++ b/gcc/go/go-lang.c @@ -162,6 +162,17 @@ go_langhook_init_options_struct (struct gcc_options *opts) opts->x_flag_non_call_exceptions = 1; } +/* Infrastructure for a VEC of char * pointers. */ + +typedef const char *go_char_p; +DEF_VEC_P(go_char_p); +DEF_VEC_ALLOC_P(go_char_p, heap); + +/* The list of directories to search after all the Go specific + directories have been searched. */ + +static VEC(go_char_p, heap) *go_search_dirs; + /* Handle Go specific options. Return 0 if we didn't do anything. */ static bool @@ -179,13 +190,47 @@ go_langhook_handle_option ( switch (code) { case OPT_I: - case OPT_L: - /* For the compiler, we currently handle -I and -L exactly the - same way: they give us a directory to search for import - statements. */ go_add_search_path (arg); break; + case OPT_L: + /* A -L option is assumed to come from the compiler driver. + This is a system directory. We search the following + directories, if they exist, before this one: + dir/go/VERSION + dir/go/VERSION/MACHINE + This is like include/c++. */ + { + static const char dir_separator_str[] = { DIR_SEPARATOR, 0 }; + size_t len; + char *p; + struct stat st; + + len = strlen (arg); + p = XALLOCAVEC (char, + (len + sizeof "go" + sizeof DEFAULT_TARGET_VERSION + + sizeof DEFAULT_TARGET_MACHINE + 3)); + strcpy (p, arg); + if (len > 0 && !IS_DIR_SEPARATOR (p[len - 1])) + strcat (p, dir_separator_str); + strcat (p, "go"); + strcat (p, dir_separator_str); + strcat (p, DEFAULT_TARGET_VERSION); + if (stat (p, &st) == 0 && S_ISDIR (st.st_mode)) + { + go_add_search_path (p); + strcat (p, dir_separator_str); + strcat (p, DEFAULT_TARGET_MACHINE); + if (stat (p, &st) == 0 && S_ISDIR (st.st_mode)) + go_add_search_path (p); + } + + /* Search ARG too, but only after we've searched to Go + specific directories for all -L arguments. */ + VEC_safe_push (go_char_p, heap, go_search_dirs, arg); + } + break; + case OPT_fgo_dump_: ret = go_enable_dump (arg) ? true : false; break; @@ -207,8 +252,16 @@ go_langhook_handle_option ( static bool go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED) { + unsigned int ix; + const char *dir; + gcc_assert (num_in_fnames > 0); + FOR_EACH_VEC_ELT (go_char_p, go_search_dirs, ix, dir) + go_add_search_path (dir); + VEC_free (go_char_p, heap, go_search_dirs); + go_search_dirs = NULL; + if (flag_excess_precision_cmdline == EXCESS_PRECISION_DEFAULT) flag_excess_precision_cmdline = EXCESS_PRECISION_STANDARD; |