diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index c29d222cb7bfe474c99c13b9daef1b9ace6a98d1..05f1c991638653877701646888f4531393ca6bd3 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -825,10 +825,14 @@ go_sync_files = \
 	go/sync/waitgroup.go
 
 if LIBGO_IS_SOLARIS
-go_syslog_file = go/syslog/syslog_solaris.go
+go_syslog_file = go/syslog/syslog_libc.go
+else
+if LIBGO_IS_IRIX
+go_syslog_file = go/syslog/syslog_libc.go
 else
 go_syslog_file = go/syslog/syslog_unix.go
 endif
+endif
 
 go_syslog_files = \
 	go/syslog/syslog.go \
@@ -1300,9 +1304,13 @@ else
 if LIBGO_IS_SOLARIS
 syscall_socket_os_file = syscalls/socket_solaris.go
 else
+if LIBGO_IS_IRIX
+syscall_socket_os_file = syscalls/socket_irix.go
+else
 syscall_socket_os_file = syscalls/socket_bsd.go
 endif
 endif
+endif
 
 # Support for epoll.
 if LIBGO_IS_LINUX
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index 1d6f62c44f6f9228f91d1a072def357fad6301c8..cf84f730cdd6fa035a998e9997b376e3df65a2b3 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -1172,8 +1172,9 @@ go_sync_files = \
 	go/sync/rwmutex.go \
 	go/sync/waitgroup.go
 
-@LIBGO_IS_SOLARIS_FALSE@go_syslog_file = go/syslog/syslog_unix.go
-@LIBGO_IS_SOLARIS_TRUE@go_syslog_file = go/syslog/syslog_solaris.go
+@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_syslog_file = go/syslog/syslog_unix.go
+@LIBGO_IS_IRIX_TRUE@@LIBGO_IS_SOLARIS_FALSE@go_syslog_file = go/syslog/syslog_libc.go
+@LIBGO_IS_SOLARIS_TRUE@go_syslog_file = go/syslog/syslog_libc.go
 go_syslog_files = \
 	go/syslog/syslog.go \
 	$(go_syslog_file)
@@ -1656,7 +1657,8 @@ go_testing_script_files = \
 # Declare libc_strerror_r which is the Go name for strerror_r.
 # RTEMS uses newlib in which strerror_r returns char *.
 @LIBGO_IS_RTEMS_TRUE@syscall_errstr_decl_file = syscalls/errstr_decl_rtems.go
-@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@syscall_socket_os_file = syscalls/socket_bsd.go
+@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@syscall_socket_os_file = syscalls/socket_bsd.go
+@LIBGO_IS_IRIX_TRUE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@syscall_socket_os_file = syscalls/socket_irix.go
 @LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_TRUE@syscall_socket_os_file = syscalls/socket_solaris.go
 
 # Define socket sizes and types.
diff --git a/libgo/configure b/libgo/configure
index 611103fc4b51974fe42a1a375ac88a62fcc27f94..565bc89a34169506c2ffbb6df4dfd2d65c0e739d 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -13295,7 +13295,7 @@ is_386=no
 is_alpha=no
 is_arm=no
 is_m68k=no
-mips_abi=""
+mips_abi=unknown
 is_ppc=no
 is_ppc64=no
 is_sparc=no
@@ -13466,7 +13466,7 @@ else
   LIBGO_IS_M68K_FALSE=
 fi
 
- if test $mips_abi != ""; then
+ if test $mips_abi != unknown; then
   LIBGO_IS_MIPS_TRUE=
   LIBGO_IS_MIPS_FALSE='#'
 else
@@ -13561,6 +13561,11 @@ fi
 
 
 case "$target" in
+    mips-sgi-irix6.5*)
+	# IRIX 6 needs _XOPEN_SOURCE=500 for the XPG5 version of struct
+	# msghdr in <sys/socket.h>.
+	OSCFLAGS='-D_XOPEN_SOURCE=500'
+	;;
     *-*-solaris2.[89])
 	# Solaris 8/9 need this so struct msghdr gets the msg_control
 	# etc. fields in <sys/socket.h> (_XPG4_2).
diff --git a/libgo/configure.ac b/libgo/configure.ac
index e772c2a12def2ea03b6c7d815e75b3a404ce6ea6..2451214f7680fb5ef4d8eb329544de2bef08c980 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -140,7 +140,7 @@ is_386=no
 is_alpha=no
 is_arm=no
 is_m68k=no
-mips_abi=""
+mips_abi=unknown
 is_ppc=no
 is_ppc64=no
 is_sparc=no
@@ -233,7 +233,7 @@ AM_CONDITIONAL(LIBGO_IS_386, test $is_386 = yes)
 AM_CONDITIONAL(LIBGO_IS_ALPHA, test $is_alpha = yes)
 AM_CONDITIONAL(LIBGO_IS_ARM, test $is_arm = yes)
 AM_CONDITIONAL(LIBGO_IS_M68K, test $is_m68k = yes)
-AM_CONDITIONAL(LIBGO_IS_MIPS, test $mips_abi != "")
+AM_CONDITIONAL(LIBGO_IS_MIPS, test $mips_abi != unknown)
 AM_CONDITIONAL(LIBGO_IS_MIPSO32, test $mips_abi = o32)
 AM_CONDITIONAL(LIBGO_IS_MIPSN32, test $mips_abi = n32)
 AM_CONDITIONAL(LIBGO_IS_MIPSN64, test $mips_abi = n64)
@@ -260,6 +260,11 @@ AC_SUBST(GO_DEBUG_PROC_REGS_OS_ARCH_FILE)
 
 dnl Some targets need special flags to build sysinfo.go.
 case "$target" in
+    mips-sgi-irix6.5*)
+	# IRIX 6 needs _XOPEN_SOURCE=500 for the XPG5 version of struct
+	# msghdr in <sys/socket.h>.
+	OSCFLAGS='-D_XOPEN_SOURCE=500'
+	;;
     *-*-solaris2.[[89]])
 	# Solaris 8/9 need this so struct msghdr gets the msg_control
 	# etc. fields in <sys/socket.h> (_XPG4_2).
diff --git a/libgo/go/syslog/syslog_solaris.go b/libgo/go/syslog/syslog_libc.go
similarity index 100%
rename from libgo/go/syslog/syslog_solaris.go
rename to libgo/go/syslog/syslog_libc.go
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index 05f4af01ab323b38b7b145fe1e42d218c6a33552..fecaeb6b31206271c814bf41ad746b3a4665a35d 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -29,12 +29,6 @@ cat > sysinfo.c <<EOF
 #define _LARGEFILE_SOURCE
 #define _FILE_OFFSET_BITS 64
 
-#ifdef __sgi__
-/* IRIX 6 needs _XOPEN_SOURCE=500 for the XPG5 version of struct msghdr in
-   <sys/socket.h>.  */
-#define _XOPEN_SOURCE 500
-#endif
-
 #include <sys/types.h>
 #include <dirent.h>
 #include <errno.h>
@@ -93,13 +87,15 @@ echo 'package syscall' > ${OUT}
 grep -v '^// ' gen-sysinfo.go | \
   grep -v '^func' | \
   grep -v '^type _timeval ' | \
-  grep -v '^type _timespec\(_t\)\? ' | \
+  grep -v '^type _timespec_t ' | \
+  grep -v '^type _timespec ' | \
   grep -v '^type _timestruc_t ' | \
   grep -v '^type _epoll_' | \
   grep -v 'in6_addr' | \
   grep -v 'sockaddr_in6' | \
   sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
-      -e 's/\([^a-zA-Z0-9_]\)_timespec\(_t\)\?\([^a-zA-Z0-9_]\)/\1Timespec\3/g' \
+      -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
+      -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
       -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
     >> ${OUT}
 
@@ -317,7 +313,8 @@ timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
 echo "type Timespec_sec_t $timespec_sec" >> ${OUT}
 echo "type Timespec_nsec_t $timespec_nsec" >> ${OUT}
 echo $timespec | \
-  sed -e 's/^type \(__\)\?_timespec /type Timespec /' \
+  sed -e 's/^type ___timespec /type Timespec /' \
+      -e 's/^type _timespec /type Timespec /' \
       -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \
       -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT}
 
@@ -356,7 +353,8 @@ fi | sed -e 's/type _stat64/type Stat_t/' \
          -e 's/st_mtim/Mtime/' \
          -e 's/st_ctim/Ctime/' \
          -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
-         -e 's/\([^a-zA-Z0-9_]\)_timespec\(_t\)\?\([^a-zA-Z0-9_]\)/\1Timespec\3/g' \
+         -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
+         -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
          -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
        >> ${OUT}
 
diff --git a/libgo/syscalls/socket_irix.go b/libgo/syscalls/socket_irix.go
new file mode 100644
index 0000000000000000000000000000000000000000..34190362c3f8910cbc5d287a249660f1be322dcc
--- /dev/null
+++ b/libgo/syscalls/socket_irix.go
@@ -0,0 +1,84 @@
+// socket_irix.go -- Socket handling specific to IRIX 6.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+const SizeofSockaddrInet4 = 16
+const SizeofSockaddrInet6 = 28
+const SizeofSockaddrUnix = 110
+
+type RawSockaddrInet4 struct {
+	Family uint16
+	Port   uint16
+	Addr   [4]byte /* in_addr */
+	Zero   [8]uint8
+}
+
+func (sa *RawSockaddrInet4) setLen() Socklen_t {
+	return SizeofSockaddrInet4
+}
+
+type RawSockaddrInet6 struct {
+	Family   uint16
+	Port     uint16
+	Flowinfo uint32
+	Addr     [16]byte /* in6_addr */
+	Scope_id uint32
+}
+
+func (sa *RawSockaddrInet6) setLen() Socklen_t {
+	return SizeofSockaddrInet6
+}
+
+type RawSockaddrUnix struct {
+	Family uint16
+	Path   [108]int8
+}
+
+func (sa *RawSockaddrUnix) setLen(int) {
+}
+
+func (sa *RawSockaddrUnix) getLen() (int, int) {
+	if sa.Path[0] == 0 {
+		// "Abstract" Unix domain socket.
+		// Rewrite leading NUL as @ for textual display.
+		// (This is the standard convention.)
+		// Not friendly to overwrite in place,
+		// but the callers below don't care.
+		sa.Path[0] = '@'
+	}
+
+	// Assume path ends at NUL.
+	// This is not technically the Linux semantics for
+	// abstract Unix domain sockets--they are supposed
+	// to be uninterpreted fixed-size binary blobs--but
+	// everyone uses this convention.
+	n := 0
+	for n < len(sa.Path)-3 && sa.Path[n] != 0 {
+		n++
+	}
+
+	return n, 0
+}
+
+type RawSockaddr struct {
+	Family uint16
+	Data   [14]int8
+}
+
+// BindToDevice binds the socket associated with fd to device.
+func BindToDevice(fd int, device string) (errno int) {
+	return ENOSYS
+}
+
+// struct ip_mreg is provived in <netinet/in.h>, but protected with _SGIAPI.
+// This could be enabled with -D_SGI_SOURCE, but conflicts with
+// -D_XOPEN_SOURCE=500 required for msg_control etc. in struct msghgr, so
+// simply provide it here.
+type IpMreq struct {
+	Multiaddr [4]byte
+	Interface [4]byte
+}