Index: gcc/go/Make-lang.in
===================================================================
--- gcc/go/Make-lang.in	(revision 167515)
+++ gcc/go/Make-lang.in	(working copy)
@@ -218,10 +218,16 @@ GO_IMPORT_H = go/gofrontend/import.h go/
 
 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
 
Index: gcc/go/go-lang.c
===================================================================
--- gcc/go/go-lang.c	(revision 167515)
+++ gcc/go/go-lang.c	(working copy)
@@ -162,6 +162,17 @@ go_langhook_init_options_struct (struct 
   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;
 
Index: gcc/go/gccgo.texi
===================================================================
--- gcc/go/gccgo.texi	(revision 167515)
+++ gcc/go/gccgo.texi	(working copy)
@@ -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
Index: libgo/Makefile.am
===================================================================
--- libgo/Makefile.am	(revision 167515)
+++ libgo/Makefile.am	(working copy)
@@ -15,6 +15,8 @@ endif
 
 SUBDIRS = ${subdirs}
 
+gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
+
 MAINT_CHARSET = latin1
 
 mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
@@ -95,7 +97,9 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
 toolexeclib_LTLIBRARIES = libgo.la
 toolexeclib_LIBRARIES = libgobegin.a
 
-toolexeclib_DATA = \
+toolexeclibgodir = $(toolexeclibdir)/go/$(gcc_version)/$(target_alias)
+
+toolexeclibgo_DATA = \
 	asn1.gox \
 	big.gox \
 	bufio.gox \
@@ -145,30 +149,30 @@ toolexeclib_DATA = \
 	websocket.gox \
 	xml.gox
 
-toolexeclibarchivedir = $(toolexeclibdir)/archive
+toolexeclibgoarchivedir = $(toolexeclibgodir)/archive
 
-toolexeclibarchive_DATA = \
+toolexeclibgoarchive_DATA = \
 	archive/tar.gox \
 	archive/zip.gox
 
-toolexeclibcompressdir = $(toolexeclibdir)/compress
+toolexeclibgocompressdir = $(toolexeclibgodir)/compress
 
-toolexeclibcompress_DATA = \
+toolexeclibgocompress_DATA = \
 	compress/flate.gox \
 	compress/gzip.gox \
 	compress/zlib.gox
 
-toolexeclibcontainerdir = $(toolexeclibdir)/container
+toolexeclibgocontainerdir = $(toolexeclibgodir)/container
 
-toolexeclibcontainer_DATA = \
+toolexeclibgocontainer_DATA = \
 	container/heap.gox \
 	container/list.gox \
 	container/ring.gox \
 	container/vector.gox
 
-toolexeclibcryptodir = $(toolexeclibdir)/crypto
+toolexeclibgocryptodir = $(toolexeclibgodir)/crypto
 
-toolexeclibcrypto_DATA = \
+toolexeclibgocrypto_DATA = \
 	crypto/aes.gox \
 	crypto/block.gox \
 	crypto/blowfish.gox \
@@ -189,9 +193,9 @@ toolexeclibcrypto_DATA = \
 	crypto/x509.gox \
 	crypto/xtea.gox
 
-toolexeclibdebugdir = $(toolexeclibdir)/debug
+toolexeclibgodebugdir = $(toolexeclibgodir)/debug
 
-toolexeclibdebug_DATA = \
+toolexeclibgodebug_DATA = \
 	debug/dwarf.gox \
 	debug/elf.gox \
 	debug/gosym.gox \
@@ -199,9 +203,9 @@ toolexeclibdebug_DATA = \
 	debug/pe.gox \
 	debug/proc.gox
 
-toolexeclibencodingdir = $(toolexeclibdir)/encoding
+toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
 
-toolexeclibencoding_DATA = \
+toolexeclibgoencoding_DATA = \
 	encoding/ascii85.gox \
 	encoding/base64.gox \
 	encoding/binary.gox \
@@ -209,16 +213,16 @@ toolexeclibencoding_DATA = \
 	encoding/hex.gox \
 	encoding/pem.gox
 
-toolexeclibexpdir = $(toolexeclibdir)/exp
+toolexeclibgoexpdir = $(toolexeclibgodir)/exp
 
-toolexeclibexp_DATA = \
+toolexeclibgoexp_DATA = \
 	exp/datafmt.gox \
 	exp/draw.gox \
 	exp/eval.gox
 
-toolexeclibgodir = $(toolexeclibdir)/go
+toolexeclibgogodir = $(toolexeclibgodir)/go
 
-toolexeclibgo_DATA = \
+toolexeclibgogo_DATA = \
 	go/ast.gox \
 	go/doc.gox \
 	go/parser.gox \
@@ -227,63 +231,63 @@ toolexeclibgo_DATA = \
 	go/token.gox \
 	go/typechecker.gox
 
-toolexeclibhashdir = $(toolexeclibdir)/hash
+toolexeclibgohashdir = $(toolexeclibgodir)/hash
 
-toolexeclibhash_DATA = \
+toolexeclibgohash_DATA = \
 	hash/adler32.gox \
 	hash/crc32.gox \
 	hash/crc64.gox
 
-toolexeclibhttpdir = $(toolexeclibdir)/http
+toolexeclibgohttpdir = $(toolexeclibgodir)/http
 
-toolexeclibhttp_DATA = \
+toolexeclibgohttp_DATA = \
 	http/pprof.gox
 
-toolexeclibimagedir = $(toolexeclibdir)/image
+toolexeclibgoimagedir = $(toolexeclibgodir)/image
 
-toolexeclibimage_DATA = \
+toolexeclibgoimage_DATA = \
 	image/jpeg.gox \
 	image/png.gox
 
-toolexeclibindexdir = $(toolexeclibdir)/index
+toolexeclibgoindexdir = $(toolexeclibgodir)/index
 
-toolexeclibindex_DATA = \
+toolexeclibgoindex_DATA = \
 	index/suffixarray.gox
 
-toolexeclibiodir = $(toolexeclibdir)/io
+toolexeclibgoiodir = $(toolexeclibgodir)/io
 
-toolexeclibio_DATA = \
+toolexeclibgoio_DATA = \
 	io/ioutil.gox
 
-toolexeclibmimedir = $(toolexeclibdir)/mime
+toolexeclibgomimedir = $(toolexeclibgodir)/mime
 
-toolexeclibmime_DATA = \
+toolexeclibgomime_DATA = \
 	mime/multipart.gox
 
-toolexeclibnetdir = $(toolexeclibdir)/net
+toolexeclibgonetdir = $(toolexeclibgodir)/net
 
-toolexeclibnet_DATA = \
+toolexeclibgonet_DATA = \
 	net/dict.gox \
 	net/textproto.gox
 
-toolexeclibosdir = $(toolexeclibdir)/os
+toolexeclibgoosdir = $(toolexeclibgodir)/os
 
-toolexeclibos_DATA = \
+toolexeclibgoos_DATA = \
 	os/signal.gox
 
-toolexeclibrpcdir = $(toolexeclibdir)/rpc
+toolexeclibgorpcdir = $(toolexeclibgodir)/rpc
 
-toolexeclibrpc_DATA = \
+toolexeclibgorpc_DATA = \
 	rpc/jsonrpc.gox
 
-toolexeclibruntimedir = $(toolexeclibdir)/runtime
+toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
 
-toolexeclibruntime_DATA = \
+toolexeclibgoruntime_DATA = \
 	runtime/pprof.gox
 
-toolexeclibtestingdir = $(toolexeclibdir)/testing
+toolexeclibgotestingdir = $(toolexeclibgodir)/testing
 
-toolexeclibtesting_DATA = \
+toolexeclibgotesting_DATA = \
 	testing/iotest.gox \
 	testing/quick.gox \
 	testing/script.gox
