I've committed a set of patches by James Cowgill to the GCC 7 branch,
backported from trunk.  These patches update the MIPS architecture
names to the names expected by Go programmers.  The backported patches
are:
    https://golang.org/cl/46150
    https://golang.org/cl/46151
    https://golang.org/cl/46152
    https://golang.org/cl/46153
    https://golang.org/cl/46154
    https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01777.html

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to GCC 7 branch.

Ian

2017-10-09  James Cowgill  <james.cowg...@imgtec.com>

* go.test/go-test.exp (go-set-goarch): Update MIPS architecture names.
Index: gcc/testsuite/go.test/go-test.exp
===================================================================
--- gcc/testsuite/go.test/go-test.exp   (revision 253547)
+++ gcc/testsuite/go.test/go-test.exp   (working copy)
@@ -213,29 +213,27 @@
                #error FOO
                #endif
            }] {
-               set goarch "mipso32"
+               set goarch "mips"
            } elseif [check_no_compiler_messages mipsn32 assembly {
                #if _MIPS_SIM != _ABIN32
                #error FOO
                #endif
            }] {
-               set goarch "mipsn32"
+               set goarch "mips64p32"
            } elseif [check_no_compiler_messages mipsn64 assembly {
                #if _MIPS_SIM != _ABI64
                #error FOO
                #endif
            }] {
-               set goarch "mipsn64"
-           } elseif [check_no_compiler_messages mipso64 assembly {
-               #if _MIPS_SIM != _ABIO64
-               #error FOO
-               #endif
-           }] {
-               set goarch "mipso64"
+               set goarch "mips64"
            } else {
                perror "$target_triplet: unrecognized MIPS ABI"
                return ""
            }
+
+           if [istarget "mips*el-*-*"] {
+               append goarch "le"
+           }
        }
        "powerpc*-*-*" {
            if [check_effective_target_ilp32] {
Index: libgo/configure.ac
===================================================================
--- libgo/configure.ac  (revision 253547)
+++ libgo/configure.ac  (working copy)
@@ -197,7 +197,7 @@
 # supported by the gofrontend and all architectures supported by the
 # gc toolchain.
 # N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch).
-ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mipso32 
mipsn32 mipso64 mipsn64 mips mipsle mips64 mips64le mips64p32 mips64p32le ppc 
ppc64 ppc64le s390 s390x sparc sparc64"
+ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mips 
mipsle mips64 mips64le mips64p32 mips64p32le ppc ppc64 ppc64le s390 s390x sparc 
sparc64"
 
 # All known GOARCH_FAMILY values.
 ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 PPC PPC64 
S390 S390X SPARC SPARC64"
@@ -280,18 +280,12 @@
 #error not n64
 #endif],
 [mips_abi="n64"],
-       [AC_COMPILE_IFELSE([
-#if _MIPS_SIM != _ABIO64
-#error not o64
-#endif],
-[mips_abi="o64"],
        [AC_MSG_ERROR([unknown MIPS ABI])
-[mips_abi="n32"]])])])])
+[mips_abi="n32"]])])])
     case "$mips_abi" in
-    "o32") GOARCH=mipso32 ;;
-    "n32") GOARCH=mipsn32 ;;
-    "n64") GOARCH=mipsn64 ;;
-    "o64") GOARCH=mipso64 ;;
+    "o32") GOARCH=mips ;;
+    "n32") GOARCH=mips64p32 ;;
+    "n64") GOARCH=mips64 ;;
     esac
     case "$mips_abi" in
     "o32" | "n32")
@@ -298,13 +292,14 @@
         GOARCH_FAMILY=MIPS
        GOARCH_MINFRAMESIZE=4
         ;;
-    "n64" | "o64")
+    "n64")
         GOARCH_FAMILY=MIPS64
        GOARCH_MINFRAMESIZE=8
         ;;
     esac
     case "${host}" in
-    mips*el)
+    mips*el-*-*)
+        GOARCH="${GOARCH}le"
         ;;
     *)
        GOARCH_BIGENDIAN=1
@@ -569,7 +564,7 @@
 
 GCC_CHECK_UNWIND_GETIPINFO
 
-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h 
sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/user.h 
sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h net/route.h 
netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h 
sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/reboot.h netinet/icmp6.h 
netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h)
+AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h 
sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/user.h 
sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h net/route.h 
netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h 
sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h 
netinet/icmp6.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h 
netinet/if_ether.h)
 
 AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h 
linux/if_tun.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
Index: libgo/go/cmd/cgo/main.go
===================================================================
--- libgo/go/cmd/cgo/main.go    (revision 253547)
+++ libgo/go/cmd/cgo/main.go    (working copy)
@@ -139,51 +139,47 @@
 }
 
 var ptrSizeMap = map[string]int64{
-       "386":      4,
-       "alpha":    8,
-       "amd64":    8,
-       "arm":      4,
-       "arm64":    8,
-       "m68k":     4,
-       "mipso32":  4,
-       "mipsn32":  4,
-       "mipso64":  8,
-       "mipsn64":  8,
-       "mips":     4,
-       "mipsle":   4,
-       "mips64":   8,
-       "mips64le": 8,
-       "ppc":      4,
-       "ppc64":    8,
-       "ppc64le":  8,
-       "s390":     4,
-       "s390x":    8,
-       "sparc":    4,
-       "sparc64":  8,
+       "386":         4,
+       "alpha":       8,
+       "amd64":       8,
+       "arm":         4,
+       "arm64":       8,
+       "m68k":        4,
+       "mips":        4,
+       "mipsle":      4,
+       "mips64":      8,
+       "mips64le":    8,
+       "mips64p32":   4,
+       "mips64p32le": 4,
+       "ppc":         4,
+       "ppc64":       8,
+       "ppc64le":     8,
+       "s390":        4,
+       "s390x":       8,
+       "sparc":       4,
+       "sparc64":     8,
 }
 
 var intSizeMap = map[string]int64{
-       "386":      4,
-       "alpha":    8,
-       "amd64":    8,
-       "arm":      4,
-       "arm64":    8,
-       "m68k":     4,
-       "mipso32":  4,
-       "mipsn32":  4,
-       "mipso64":  8,
-       "mipsn64":  8,
-       "mips":     4,
-       "mipsle":   4,
-       "mips64":   8,
-       "mips64le": 8,
-       "ppc":      4,
-       "ppc64":    8,
-       "ppc64le":  8,
-       "s390":     4,
-       "s390x":    8,
-       "sparc":    4,
-       "sparc64":  8,
+       "386":         4,
+       "alpha":       8,
+       "amd64":       8,
+       "arm":         4,
+       "arm64":       8,
+       "m68k":        4,
+       "mips":        4,
+       "mipsle":      4,
+       "mips64":      8,
+       "mips64le":    8,
+       "mips64p32":   8,
+       "mips64p32le": 8,
+       "ppc":         4,
+       "ppc64":       8,
+       "ppc64le":     8,
+       "s390":        4,
+       "s390x":       8,
+       "sparc":       4,
+       "sparc64":     8,
 }
 
 var cPrefix string
Index: libgo/go/go/build/syslist.go
===================================================================
--- libgo/go/go/build/syslist.go        (revision 253547)
+++ libgo/go/go/build/syslist.go        (working copy)
@@ -5,4 +5,4 @@
 package build
 
 const goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd 
plan9 solaris windows zos "
-const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be alpha m68k 
ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le mipso32 mipsn32 
mipsn64 mipso64 ppc s390 s390x sparc sparc64 "
+const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be alpha m68k 
ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc s390 s390x 
sparc sparc64 "
Index: libgo/go/internal/syscall/unix/getrandom_linux_mips64p32x.go
===================================================================
--- libgo/go/internal/syscall/unix/getrandom_linux_mips64p32x.go        
(revision 0)
+++ libgo/go/internal/syscall/unix/getrandom_linux_mips64p32x.go        
(working copy)
@@ -0,0 +1,11 @@
+// Copyright 2016 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.
+
+// +build mips64p32 mips64p32le
+
+package unix
+
+// Linux getrandom system call number.
+// See GetRandom in getrandom_linux.go.
+const randomTrap uintptr = 6317
Index: libgo/go/internal/syscall/unix/getrandom_linux_mips64x.go
===================================================================
--- libgo/go/internal/syscall/unix/getrandom_linux_mips64x.go   (revision 
253547)
+++ libgo/go/internal/syscall/unix/getrandom_linux_mips64x.go   (working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build mips64 mips64le mipsn64 mipso64
+// +build mips64 mips64le
 
 package unix
 
Index: libgo/go/internal/syscall/unix/getrandom_linux_mipsn32.go
===================================================================
--- libgo/go/internal/syscall/unix/getrandom_linux_mipsn32.go   (revision 
253547)
+++ libgo/go/internal/syscall/unix/getrandom_linux_mipsn32.go   (working copy)
@@ -1,11 +0,0 @@
-// Copyright 2016 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.
-
-// +build mipsn32
-
-package unix
-
-// Linux getrandom system call number.
-// See GetRandom in getrandom_linux.go.
-const randomTrap uintptr = 6317
Index: libgo/go/internal/syscall/unix/getrandom_linux_mipso32.go
===================================================================
--- libgo/go/internal/syscall/unix/getrandom_linux_mipso32.go   (revision 
253547)
+++ libgo/go/internal/syscall/unix/getrandom_linux_mipso32.go   (working copy)
@@ -1,11 +0,0 @@
-// Copyright 2016 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.
-
-// +build mipso32
-
-package unix
-
-// Linux getrandom system call number.
-// See GetRandom in getrandom_linux.go.
-const randomTrap uintptr = 4353
Index: libgo/go/runtime/hash32.go
===================================================================
--- libgo/go/runtime/hash32.go  (revision 253547)
+++ libgo/go/runtime/hash32.go  (working copy)
@@ -6,7 +6,7 @@
 //   xxhash: https://code.google.com/p/xxhash/
 // cityhash: https://code.google.com/p/cityhash/
 
-// +build 386 arm armbe m68k mipso32 mipsn32 mips mipsle ppc s390 sparc
+// +build 386 arm armbe m68k mips mipsle ppc s390 sparc
 
 package runtime
 
Index: libgo/go/runtime/hash64.go
===================================================================
--- libgo/go/runtime/hash64.go  (revision 253547)
+++ libgo/go/runtime/hash64.go  (working copy)
@@ -6,7 +6,7 @@
 //   xxhash: https://code.google.com/p/xxhash/
 // cityhash: https://code.google.com/p/cityhash/
 
-// +build amd64 amd64p32 arm64 mips64 mips64le ppc64 ppc64le s390x alpha 
arm64be ia64 mipso64 mipsn64 mips64p32 mips64p32le sparc64
+// +build amd64 amd64p32 arm64 mips64 mips64le ppc64 ppc64le s390x alpha 
arm64be ia64 mips64p32 mips64p32le sparc64
 
 package runtime
 
Index: libgo/go/runtime/lfstack_32bit.go
===================================================================
--- libgo/go/runtime/lfstack_32bit.go   (revision 253547)
+++ libgo/go/runtime/lfstack_32bit.go   (working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build 386 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le mipso32 
mipsn32 ppc s390 sparc
+// +build 386 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le ppc s390 
sparc
 
 package runtime
 
Index: libgo/go/runtime/lfstack_64bit.go
===================================================================
--- libgo/go/runtime/lfstack_64bit.go   (revision 253547)
+++ libgo/go/runtime/lfstack_64bit.go   (working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build amd64 arm64 mips64 mips64le ppc64 ppc64le s390x arm64be alpha 
mipsn64 sparc64
+// +build amd64 arm64 mips64 mips64le ppc64 ppc64le s390x arm64be alpha sparc64
 
 package runtime
 
Index: libgo/go/runtime/unaligned2.go
===================================================================
--- libgo/go/runtime/unaligned2.go      (revision 253547)
+++ libgo/go/runtime/unaligned2.go      (working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build arm mips mipsle mips64 mips64le armbe m68k mipso32 mipsn32 sparc 
alpha ia64 mipso64 mipsn64 mips64p32 mips64p32le sparc64
+// +build arm mips mipsle mips64 mips64le armbe m68k sparc alpha ia64 
mips64p32 mips64p32le sparc64
 
 package runtime
 
Index: libgo/go/syscall/endian_big.go
===================================================================
--- libgo/go/syscall/endian_big.go      (revision 253547)
+++ libgo/go/syscall/endian_big.go      (working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 //
-// +build ppc64 s390x mips mips64 armbe arm64be m68k ppc mipso32 mipsn32 
mipso64 mipsn64 mips64p32 s390 sparc sparc64
+// +build ppc64 s390x mips mips64 armbe arm64be m68k ppc mips64p32 s390 sparc 
sparc64
 
 package syscall
 
Index: libgo/go/syscall/syscall_linux_mips64x.go
===================================================================
--- libgo/go/syscall/syscall_linux_mips64x.go   (revision 253547)
+++ libgo/go/syscall/syscall_linux_mips64x.go   (working copy)
@@ -1,20 +0,0 @@
-// Copyright 2009 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.
-
-// +build linux
-// +build mips64 mips64le
-
-package syscall
-
-func (r *PtraceRegs) PC() uint64 { return r.Regs[64] }
-
-func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc }
-
-func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
-       return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
-}
-
-func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
-       return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
-}
Index: libgo/go/syscall/syscall_linux_mipsx.go
===================================================================
--- libgo/go/syscall/syscall_linux_mipsx.go     (revision 253547)
+++ libgo/go/syscall/syscall_linux_mipsx.go     (working copy)
@@ -3,10 +3,24 @@
 // license that can be found in the LICENSE file.
 
 // +build linux
-// +build mips mipsle
+// +build mips mipsle mips64 mips64le mips64p32 mips64p32le
 
 package syscall
 
-func (r *PtraceRegs) PC() uint64 { return uint64(r.Regs[64]) }
+import "unsafe"
 
-func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = uint32(pc) }
+func (r *PtraceRegs) PC() uint64 {
+       return r.Cp0_epc
+}
+
+func (r *PtraceRegs) SetPC(pc uint64) {
+       r.Cp0_epc = pc
+}
+
+func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
+       return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
+}
+
+func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
+       return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
+}
Index: libgo/match.sh
===================================================================
--- libgo/match.sh      (revision 253547)
+++ libgo/match.sh      (working copy)
@@ -116,7 +116,7 @@
        android | darwin | dragonfly | freebsd | linux | nacl | netbsd | 
openbsd | plan9 | solaris | windows)
            tag1=nonmatchingtag
            ;;
-       386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | 
m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | mipso32 | mipsn32 | mipsn64 | mipso64 | ppc | s390 | s390x | 
sparc | sparc64)
+       386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | 
m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | ppc | s390 | s390x | sparc | sparc64)
            tag1=nonmatchingtag
            ;;
     esac
@@ -128,7 +128,7 @@
        android | darwin | dragonfly | freebsd | linux | nacl | netbsd | 
openbsd | plan9 | solaris | windows)
            tag2=nonmatchingtag
            ;;
-       386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | 
m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | mipso32 | mipsn32 | mipsn64 | mipso64 | ppc | s390 | s390x | 
sparc | sparc64)
+       386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | 
m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | ppc | s390 | s390x | sparc | sparc64)
            tag2=nonmatchingtag
            ;;
     esac
Index: libgo/mksysinfo.sh
===================================================================
--- libgo/mksysinfo.sh  (revision 253547)
+++ libgo/mksysinfo.sh  (working copy)
@@ -302,9 +302,13 @@
     upcase_fields "__user_psw_struct" "PtracePsw" >> ${OUT} || true
     upcase_fields "__user_fpregs_struct" "PtraceFpregs" >> ${OUT} || true
     upcase_fields "__user_per_struct" "PtracePer" >> ${OUT} || true
+  else
+    # mips*
+    regs=`grep '^type _pt_regs struct' gen-sysinfo.go || true`
   fi
 fi
 if test "$regs" != ""; then
+  regs=`echo $regs | sed -e 's/type _pt_regs struct//'`
   regs=`echo $regs |
     sed -e 's/type __*user_regs_struct struct //' -e 's/[{}]//g'`
   regs=`echo $regs | sed -e s'/^ *//'`
Index: libgo/sysinfo.c
===================================================================
--- libgo/sysinfo.c     (revision 253547)
+++ libgo/sysinfo.c     (working copy)
@@ -102,6 +102,9 @@
 #if defined(HAVE_LINUX_NETLINK_H)
 #include <linux/netlink.h>
 #endif
+#if defined(HAVE_LINUX_PTRACE_H)
+#include <linux/ptrace.h>
+#endif
 #if defined(HAVE_LINUX_RTNETLINK_H)
 #include <linux/rtnetlink.h>
 #endif
Index: libgo/testsuite/gotest
===================================================================
--- libgo/testsuite/gotest      (revision 253547)
+++ libgo/testsuite/gotest      (working copy)
@@ -314,7 +314,7 @@
            android | darwin | dragonfly | freebsd | linux | nacl | netbsd | 
openbsd | plan9 | solaris | windows)
                tag1=nonmatchingtag
                ;;
-           386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | mipso32 | mipsn32 | mipsn64 | mipso64 | ppc | s390 | s390x | 
sparc | sparc64)
+           386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | ppc | s390 | s390x | sparc | sparc64)
                tag1=nonmatchingtag
                ;;
            esac
@@ -326,7 +326,7 @@
            android | darwin | dragonfly | freebsd | linux | nacl | netbsd | 
openbsd | plan9 | solaris | windows)
                tag2=nonmatchingtag
                ;;
-           386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | mipso32 | mipsn32 | mipsn64 | mipso64 | ppc | s390 | s390x | 
sparc | sparc64)
+           386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | ppc | s390 | s390x | sparc | sparc64)
                tag2=nonmatchingtag
                ;;
            esac

Reply via email to