diff mbox series

libgo patch committed: Update to Go1.14beta1

Message ID CAOyqgcVuWBiyja1pSjq=9pDbdxQi77Zm395_wuzT4kWAgD-Ewg@mail.gmail.com
State New
Headers show
Series libgo patch committed: Update to Go1.14beta1 | expand

Commit Message

Ian Lance Taylor Jan. 22, 2020, 7:53 a.m. UTC
I've committed a patch to update libgo to Go 1.14beta1.  As usual with
these updates the patch is far too large to include in this e-mail
message.  I've included the diffs for gccgo-specific files.
Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
mainline.

Ian

gotools/ChangeLog:

2020-01-21  Ian Lance Taylor  <iant@golang.org>

* Makefile.am (gofmt$(EXEEXT)): Link against $(LIBGOTOOL).
(check-go-tool): Copy some vendor directories.
* Makefile.in: Regenerate.

Comments

Rainer Orth Jan. 22, 2020, 8:17 p.m. UTC | #1
Hi Ian,

> I've committed a patch to update libgo to Go 1.14beta1.  As usual with
> these updates the patch is far too large to include in this e-mail
> message.  I've included the diffs for gccgo-specific files.
> Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
> mainline.

the patch broke Solaris bootstrap:

/vol/gcc/src/hg/master/local/libgo/go/runtime/os_only_solaris.go:11:1: error: redefinition of 'getncpu'
   11 | func getncpu() int32 {
      | ^
/vol/gcc/src/hg/master/local/libgo/go/runtime/os3_solaris.go:20:1: note: previous definition of 'getncpu' was here
   20 | func getncpu() int32 {
      | ^

There are 3 definitions in the Solaris/Illumos space:

* os_only_solaris.go is guarded by !illumos

* os3_solaris.go has no explicit guard

* illumos hat its own one in os_illumos.go

so the os3_solaris.go one can go.

/vol/gcc/src/hg/master/local/libgo/go/runtime/stubs2.go:40:3: error: osinit is not defined
   40 | //go:linkname osinit runtime.osinit
      |   ^

Upstream has a definition in os3_solaris.go.

The following patch allows compilation to succeed.

	Rainer
Ian Lance Taylor Jan. 22, 2020, 11:14 p.m. UTC | #2
On Wed, Jan 22, 2020 at 12:18 PM Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
> > I've committed a patch to update libgo to Go 1.14beta1.  As usual with
> > these updates the patch is far too large to include in this e-mail
> > message.  I've included the diffs for gccgo-specific files.
> > Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
> > mainline.
>
> the patch broke Solaris bootstrap:
>
> /vol/gcc/src/hg/master/local/libgo/go/runtime/os_only_solaris.go:11:1: error: redefinition of 'getncpu'
>    11 | func getncpu() int32 {
>       | ^
> /vol/gcc/src/hg/master/local/libgo/go/runtime/os3_solaris.go:20:1: note: previous definition of 'getncpu' was here
>    20 | func getncpu() int32 {
>       | ^
>
> There are 3 definitions in the Solaris/Illumos space:
>
> * os_only_solaris.go is guarded by !illumos
>
> * os3_solaris.go has no explicit guard
>
> * illumos hat its own one in os_illumos.go
>
> so the os3_solaris.go one can go.
>
> /vol/gcc/src/hg/master/local/libgo/go/runtime/stubs2.go:40:3: error: osinit is not defined
>    40 | //go:linkname osinit runtime.osinit
>       |   ^
>
> Upstream has a definition in os3_solaris.go.
>
> The following patch allows compilation to succeed.

Thanks, I already committed a patch before I got to your e-mail.
Sorry for the duplicate work.

Ian
Maciej W. Rozycki Jan. 23, 2020, 7:31 p.m. UTC | #3
On Tue, 21 Jan 2020, Ian Lance Taylor wrote:

> I've committed a patch to update libgo to Go 1.14beta1.  As usual with
> these updates the patch is far too large to include in this e-mail
> message.  I've included the diffs for gccgo-specific files.

 It seems to have broken the `riscv64-linux-gnu' target:

cpugen.go:2:7: error: redefinition of 'CacheLinePadSize'
    2 | const CacheLinePadSize = 64
      |       ^
.../libgo/go/internal/cpu/cpu_riscv64.go:7:7: note: previous definition of 'CacheLinePadSize' was here
    7 | const CacheLinePadSize = 32
      |       ^
make[4]: *** [Makefile:2830: internal/cpu.lo] Error 1
make[4]: Leaving directory '.../riscv64-linux-gnu/libgo'

  Maciej
Rainer Orth Jan. 23, 2020, 8:06 p.m. UTC | #4
Hi Ian,

> On Wed, Jan 22, 2020 at 12:18 PM Rainer Orth
> <ro@cebitec.uni-bielefeld.de> wrote:
>>
>> > I've committed a patch to update libgo to Go 1.14beta1.  As usual with
>> > these updates the patch is far too large to include in this e-mail
>> > message.  I've included the diffs for gccgo-specific files.
>> > Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
>> > mainline.
>>
>> the patch broke Solaris bootstrap:
>>
>> /vol/gcc/src/hg/master/local/libgo/go/runtime/os_only_solaris.go:11:1:
>> error: redefinition of 'getncpu'
>>    11 | func getncpu() int32 {
>>       | ^
>> /vol/gcc/src/hg/master/local/libgo/go/runtime/os3_solaris.go:20:1: note:
>> previous definition of 'getncpu' was here
>>    20 | func getncpu() int32 {
>>       | ^
>>
>> There are 3 definitions in the Solaris/Illumos space:
>>
>> * os_only_solaris.go is guarded by !illumos
>>
>> * os3_solaris.go has no explicit guard
>>
>> * illumos hat its own one in os_illumos.go
>>
>> so the os3_solaris.go one can go.
>>
>> /vol/gcc/src/hg/master/local/libgo/go/runtime/stubs2.go:40:3: error:
>> osinit is not defined
>>    40 | //go:linkname osinit runtime.osinit
>>       |   ^
>>
>> Upstream has a definition in os3_solaris.go.
>>
>> The following patch allows compilation to succeed.
>
> Thanks, I already committed a patch before I got to your e-mail.
> Sorry for the duplicate work.

no worries: it didn't take long to devise the fix.

Thanks.
        Rainer
Ian Lance Taylor Jan. 24, 2020, 12:06 a.m. UTC | #5
On Thu, Jan 23, 2020 at 11:32 AM Maciej W. Rozycki <macro@wdc.com> wrote:
>
> On Tue, 21 Jan 2020, Ian Lance Taylor wrote:
>
> > I've committed a patch to update libgo to Go 1.14beta1.  As usual with
> > these updates the patch is far too large to include in this e-mail
> > message.  I've included the diffs for gccgo-specific files.
>
>  It seems to have broken the `riscv64-linux-gnu' target:
>
> cpugen.go:2:7: error: redefinition of 'CacheLinePadSize'
>     2 | const CacheLinePadSize = 64
>       |       ^
> .../libgo/go/internal/cpu/cpu_riscv64.go:7:7: note: previous definition of 'CacheLinePadSize' was here
>     7 | const CacheLinePadSize = 32
>       |       ^
> make[4]: *** [Makefile:2830: internal/cpu.lo] Error 1
> make[4]: Leaving directory '.../riscv64-linux-gnu/libgo'

Thanks.  Fixed like so.  Committed to mainline.

Ian
b83c78fe8fd12ce6c14fe2ca234edbbdac22cd79
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a8ba3afe86e..fc1dbaca8b9 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-7d3081ce69dda123d77e35e8b9d282e40e9465e2
+10a8dbfc9945c672d59af8edb9790e2019cdeb27
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/internal/cpu/cpu_riscv64.go b/libgo/go/internal/cpu/cpu_riscv64.go
index c49cab79fdc..d920fcf7a6d 100644
--- a/libgo/go/internal/cpu/cpu_riscv64.go
+++ b/libgo/go/internal/cpu/cpu_riscv64.go
@@ -3,5 +3,3 @@
 // license that can be found in the LICENSE file.
 
 package cpu
-
-const CacheLinePadSize = 32
Andreas Schwab Feb. 1, 2020, 1:38 p.m. UTC | #6
../../../libgo/go/syscall/syscall_linux_riscv64.go:7:14: error: imported and not used: unsafe
    7 | import "unsafe"
      |              ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:13:1: error: redefinition of 'SetLen'
   13 | func (iov *Iovec) SetLen(length int) {
      | ^
../../../libgo/go/syscall/socket.go:437:1: note: previous definition of 'SetLen' was here
  437 | func (iov *Iovec) SetLen(length int) {
      | ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:17:1: error: redefinition of 'SetControllen'
   17 | func (msghdr *Msghdr) SetControllen(length int) {
      | ^
../../../libgo/go/syscall/socket.go:441:1: note: previous definition of 'SetControllen' was here
  441 | func (msghdr *Msghdr) SetControllen(length int) {
      | ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:21:1: error: redefinition of 'SetLen'
   21 | func (cmsg *Cmsghdr) SetLen(length int) {
      | ^
../../../libgo/go/syscall/socket.go:445:1: note: previous definition of 'SetLen' was here
  445 | func (cmsg *Cmsghdr) SetLen(length int) {
      | ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:14:10: error: incompatible types in assignment (cannot use type uint64 as type Iovec_len_t)
   14 |  iov.Len = uint64(length)
      |          ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:18:20: error: incompatible types in assignment (cannot use type uint64 as type Msghdr_controllen_t)
   18 |  msghdr.Controllen = uint64(length)
      |                    ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:22:11: error: incompatible types in assignment (cannot use type uint64 as type Cmsghdr_len_t)
   22 |  cmsg.Len = uint64(length)
      |           ^

Andreas.
Andreas Schwab Feb. 2, 2020, 10:27 a.m. UTC | #7
I'm getting these errors on aarch64 with -mabi=ilp32:

../../../../libgo/go/runtime/mpagealloc.go:226:38: error: shift count overflow
  226 |  chunks [1 << pallocChunksL1Bits]*[1 << pallocChunksL2Bits]pallocData
      |                                      ^
../../../../libgo/go/runtime/mgcscavenge.go:487:15: error: shift count overflow
  487 |    l2 := (*[1 << pallocChunksL2Bits]pallocData)(atomic.Loadp(unsafe.Pointer(&s.chunks[i.l1()])))
      |               ^
../../../../libgo/go/runtime/mpagealloc.go:138:22: error: shift count overflow
  138 |   return uint(i) & (1<<pallocChunksL2Bits - 1)
      |                      ^
../../../../libgo/go/runtime/mpagealloc.go:129:21: error: integer constant overflow
  129 |   return uint(i) >> pallocChunksL1Shift
      |                     ^
../../../../libgo/go/runtime/mpagealloc_64bit.go:34:2: error: integer constant overflow
   34 |  summaryL0Bits,
      |  ^

Andreas.
David Abdurachmanov Feb. 3, 2020, 8:32 a.m. UTC | #8
On Sat, Feb 1, 2020 at 2:38 PM Andreas Schwab <schwab@linux-m68k.org> wrote:

> ../../../libgo/go/syscall/syscall_linux_riscv64.go:7:14: error: imported
> and not used: unsafe
>     7 | import "unsafe"
>       |              ^


I see the same issue in Fedora/RISCV, the last two builds of GCC 10 failed
due to it.

Btw, 1.14 Beta 2 should ship riscv64 support (marked as experimental).
See: https://go-review.googlesource.com/c/go/+/216757/

david
Ian Lance Taylor Feb. 4, 2020, 2:15 a.m. UTC | #9
On Sat, Feb 1, 2020 at 5:38 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:7:14: error: imported and not used: unsafe
>     7 | import "unsafe"
>       |              ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:13:1: error: redefinition of 'SetLen'
>    13 | func (iov *Iovec) SetLen(length int) {
>       | ^
> ../../../libgo/go/syscall/socket.go:437:1: note: previous definition of 'SetLen' was here
>   437 | func (iov *Iovec) SetLen(length int) {
>       | ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:17:1: error: redefinition of 'SetControllen'
>    17 | func (msghdr *Msghdr) SetControllen(length int) {
>       | ^
> ../../../libgo/go/syscall/socket.go:441:1: note: previous definition of 'SetControllen' was here
>   441 | func (msghdr *Msghdr) SetControllen(length int) {
>       | ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:21:1: error: redefinition of 'SetLen'
>    21 | func (cmsg *Cmsghdr) SetLen(length int) {
>       | ^
> ../../../libgo/go/syscall/socket.go:445:1: note: previous definition of 'SetLen' was here
>   445 | func (cmsg *Cmsghdr) SetLen(length int) {
>       | ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:14:10: error: incompatible types in assignment (cannot use type uint64 as type Iovec_len_t)
>    14 |  iov.Len = uint64(length)
>       |          ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:18:20: error: incompatible types in assignment (cannot use type uint64 as type Msghdr_controllen_t)
>    18 |  msghdr.Controllen = uint64(length)
>       |                    ^
> ../../../libgo/go/syscall/syscall_linux_riscv64.go:22:11: error: incompatible types in assignment (cannot use type uint64 as type Cmsghdr_len_t)
>    22 |  cmsg.Len = uint64(length)
>       |           ^


Thanks.  Fixed like so.  Committed to mainline.

Ian
79530f94e9c53153c4fae3b50a8c938f89db0c32
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 40529518b26..27f4ce342e5 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d796680b5a78f686ed118578e81d5b1adf48508d
+c94637ad6fd38d4814fb02d094a1a73f19323d71
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/syscall/syscall_linux_riscv64.go b/libgo/go/syscall/syscall_linux_riscv64.go
index e9aab94e3a1..16d8709708d 100644
--- a/libgo/go/syscall/syscall_linux_riscv64.go
+++ b/libgo/go/syscall/syscall_linux_riscv64.go
@@ -4,20 +4,6 @@
 
 package syscall
 
-import "unsafe"
-
 func (r *PtraceRegs) PC() uint64 { return r.Pc }
 
 func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
-
-func (iov *Iovec) SetLen(length int) {
-	iov.Len = uint64(length)
-}
-
-func (msghdr *Msghdr) SetControllen(length int) {
-	msghdr.Controllen = uint64(length)
-}
-
-func (cmsg *Cmsghdr) SetLen(length int) {
-	cmsg.Len = uint64(length)
-}
Ian Lance Taylor Feb. 4, 2020, 2:17 a.m. UTC | #10
On Sun, Feb 2, 2020 at 2:27 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> I'm getting these errors on aarch64 with -mabi=ilp32:
>
> ../../../../libgo/go/runtime/mpagealloc.go:226:38: error: shift count overflow
>   226 |  chunks [1 << pallocChunksL1Bits]*[1 << pallocChunksL2Bits]pallocData
>       |                                      ^
> ../../../../libgo/go/runtime/mgcscavenge.go:487:15: error: shift count overflow
>   487 |    l2 := (*[1 << pallocChunksL2Bits]pallocData)(atomic.Loadp(unsafe.Pointer(&s.chunks[i.l1()])))
>       |               ^
> ../../../../libgo/go/runtime/mpagealloc.go:138:22: error: shift count overflow
>   138 |   return uint(i) & (1<<pallocChunksL2Bits - 1)
>       |                      ^
> ../../../../libgo/go/runtime/mpagealloc.go:129:21: error: integer constant overflow
>   129 |   return uint(i) >> pallocChunksL1Shift
>       |                     ^
> ../../../../libgo/go/runtime/mpagealloc_64bit.go:34:2: error: integer constant overflow
>    34 |  summaryL0Bits,
>       |  ^

I'm not sure that gccgo ever fully worked with aarch64 -mabi=ilp32.
In Go I think that will have to be represented with a new GOARCH
value, arm64p32.

Ian
Andrew Pinski Feb. 5, 2020, 4:40 a.m. UTC | #11
Something like attached.
I will clean it up next week and submit it then.
It should also fix some arm64be related issues too.

Thanks,
Andrew Pinski

On Mon, Feb 3, 2020 at 6:17 PM Ian Lance Taylor <iant@golang.org> wrote:
>
> On Sun, Feb 2, 2020 at 2:27 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
> >
> > I'm getting these errors on aarch64 with -mabi=ilp32:
> >
> > ../../../../libgo/go/runtime/mpagealloc.go:226:38: error: shift count overflow
> >   226 |  chunks [1 << pallocChunksL1Bits]*[1 << pallocChunksL2Bits]pallocData
> >       |                                      ^
> > ../../../../libgo/go/runtime/mgcscavenge.go:487:15: error: shift count overflow
> >   487 |    l2 := (*[1 << pallocChunksL2Bits]pallocData)(atomic.Loadp(unsafe.Pointer(&s.chunks[i.l1()])))
> >       |               ^
> > ../../../../libgo/go/runtime/mpagealloc.go:138:22: error: shift count overflow
> >   138 |   return uint(i) & (1<<pallocChunksL2Bits - 1)
> >       |                      ^
> > ../../../../libgo/go/runtime/mpagealloc.go:129:21: error: integer constant overflow
> >   129 |   return uint(i) >> pallocChunksL1Shift
> >       |                     ^
> > ../../../../libgo/go/runtime/mpagealloc_64bit.go:34:2: error: integer constant overflow
> >    34 |  summaryL0Bits,
> >       |  ^
>
> I'm not sure that gccgo ever fully worked with aarch64 -mabi=ilp32.
> In Go I think that will have to be represented with a new GOARCH
> value, arm64p32.
>
> Ian
From 14de07bd862051df38160da375fd286ce956785f Mon Sep 17 00:00:00 2001
From: Andrew Pinski <apinski@marvell.com>
Date: Wed, 5 Feb 2020 04:36:13 +0000
Subject: [PATCH] Add ilp32 ARM64 support to gccgo.

Change-Id: Ide52be45dd9fd5d2a5dfc7d138fc56d963d06632
Signed-off-by: Andrew Pinski <apinski@marvell.com>
---
 gcc/testsuite/go.test/go-test.exp             |  9 ++++++-
 libgo/configure                               | 27 ++++++++++++++-----
 libgo/configure.ac                            | 20 +++++++++-----
 libgo/go/cmd/cgo/main.go                      |  6 +++++
 libgo/go/cmd/go/go_test.go                    |  1 +
 libgo/go/cmd/go/internal/imports/build.go     |  2 ++
 libgo/go/cmd/internal/sys/arch.go             | 10 +++++++
 libgo/go/cmd/internal/sys/supported.go        | 10 ++++---
 libgo/go/crypto/aes/aes_gcm.go                |  2 +-
 libgo/go/crypto/aes/cipher_asm.go             |  2 +-
 libgo/go/crypto/aes/cipher_generic.go         |  2 +-
 libgo/go/golang.org/x/sys/cpu/byteorder.go    |  2 ++
 ...cpu_linux_arm64.go => cpu_linux_arm64x.go} |  2 ++
 .../golang.org/x/sys/cpu/cpu_linux_other.go   |  2 +-
 .../cpu/{cpu_arm64.go => cpu_arm64x.go}       |  2 ++
 libgo/go/internal/cpu/cpu_no_init.go          |  3 +++
 .../syscall/unix/getrandom_linux_generic.go   |  2 +-
 libgo/go/runtime/cputicks.go                  |  3 +++
 libgo/go/runtime/hash32.go                    |  2 +-
 libgo/go/runtime/lfstack_32bit.go             |  2 +-
 libgo/go/runtime/mpagealloc_32bit.go          |  2 +-
 .../{os_linux_arm64.go => os_linux_arm64x.go} |  2 +-
 libgo/go/runtime/os_linux_noauxv.go           |  2 +-
 libgo/go/syscall/endian_big.go                |  2 +-
 libgo/go/syscall/endian_little.go             |  2 +-
 libgo/goarch.sh                               |  7 ++++-
 libgo/match.sh                                |  4 +--
 libgo/testsuite/gotest                        |  4 +--
 28 files changed, 103 insertions(+), 33 deletions(-)
 rename libgo/go/golang.org/x/sys/cpu/{cpu_linux_arm64.go => cpu_linux_arm64x.go} (97%)
 rename libgo/go/internal/cpu/{cpu_arm64.go => cpu_arm64x.go} (98%)
 rename libgo/go/runtime/{os_linux_arm64.go => os_linux_arm64x.go} (94%)

diff --git a/gcc/testsuite/go.test/go-test.exp b/gcc/testsuite/go.test/go-test.exp
index 51f9b381d67..7afcba14b64 100644
--- a/gcc/testsuite/go.test/go-test.exp
+++ b/gcc/testsuite/go.test/go-test.exp
@@ -188,7 +188,14 @@ proc go-set-goarch { } {
 
     switch -glob $target_triplet {
 	"aarch64*-*-*" {
-	    set goarch "arm64"
+	    if [check_effective_target_lp64] {
+	        set goarch "arm64"
+	    } else {
+		set goarch "amd64p32"
+	    }
+	    if [check_effective_target_aarch64_big_endian] {
+		append goarch "be"
+	    }
 	}
 	"alpha*-*-*" {
 	    set goarch "alpha"
diff --git a/libgo/configure b/libgo/configure
index 2f787392abd..8eca900889f 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -14070,7 +14070,7 @@ esac
 #   - libgo/go/syscall/endian_XX.go
 #   - possibly others
 # - possibly update files in libgo/go/internal/syscall/unix
-ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"
+ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be arm64p32 arm64p32be ia64 m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"
 
 # All known GOARCH family values.
 ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 NIOS2 PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"
@@ -14080,11 +14080,26 @@ case ${host} in
   alpha*-*-*)
     GOARCH=alpha
     ;;
-  aarch64-*-*)
-    GOARCH=arm64
-    ;;
-  aarch64_be-*-*)
-    GOARCH=arm64be
+  aarch64-*-* | aarch64_be-*-*)
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef __ILP32__
+#error ilp32
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  GOARCH=arm64
+else
+  GOARCH=arm64p32
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    case "${host}" in
+    aarch64_be-*-*)
+        GOARCH="${GOARCH}be"
+        ;;
+    esac
     ;;
   arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
     GOARCH=arm
diff --git a/libgo/configure.ac b/libgo/configure.ac
index f800d44a0e9..8c9ad289f6c 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -236,7 +236,7 @@ AC_SUBST(USE_DEJAGNU)
 #   - libgo/go/syscall/endian_XX.go
 #   - possibly others
 # - possibly update files in libgo/go/internal/syscall/unix
-ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"
+ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be arm64p32 arm64p32be ia64 m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"
 
 # All known GOARCH family values.
 ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 NIOS2 PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"
@@ -246,11 +246,19 @@ case ${host} in
   alpha*-*-*)
     GOARCH=alpha
     ;;
-  aarch64-*-*)
-    GOARCH=arm64
-    ;;
-  aarch64_be-*-*)
-    GOARCH=arm64be
+  aarch64-*-* | aarch64_be-*-*)
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#ifdef __ILP32__
+#error ilp32
+#endif
+])],
+      [GOARCH=arm64],
+      [GOARCH=arm64p32])
+    case "${host}" in
+    aarch64_be-*-*)
+        GOARCH="${GOARCH}be"
+        ;;
+    esac
     ;;
   arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
     GOARCH=arm
diff --git a/libgo/go/cmd/cgo/main.go b/libgo/go/cmd/cgo/main.go
index 80f35681d75..c217a1c3ef7 100644
--- a/libgo/go/cmd/cgo/main.go
+++ b/libgo/go/cmd/cgo/main.go
@@ -173,6 +173,9 @@ var ptrSizeMap = map[string]int64{
 	"amd64":       8,
 	"arm":         4,
 	"arm64":       8,
+	"arm64be":     8,
+	"arm64p32":    4,
+	"arm64p32be":  4,
 	"m68k":        4,
 	"mips":        4,
 	"mipsle":      4,
@@ -199,6 +202,9 @@ var intSizeMap = map[string]int64{
 	"amd64":       8,
 	"arm":         4,
 	"arm64":       8,
+	"arm64be":     8,
+	"arm64p32":    8,
+	"arm64p32be":  8,
 	"m68k":        4,
 	"mips":        4,
 	"mipsle":      4,
diff --git a/libgo/go/cmd/go/go_test.go b/libgo/go/cmd/go/go_test.go
index ebd0c7ad0ad..9f8fbbe562e 100644
--- a/libgo/go/cmd/go/go_test.go
+++ b/libgo/go/cmd/go/go_test.go
@@ -4399,6 +4399,7 @@ func TestBuildmodePIE(t *testing.T) {
 	platform := fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
 	switch platform {
 	case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x",
+		"linux/arm64be", "linux/arm64p32", "linux/arm64p32be"
 		"android/amd64", "android/arm", "android/arm64", "android/386",
 		"freebsd/amd64":
 	case "darwin/amd64":
diff --git a/libgo/go/cmd/go/internal/imports/build.go b/libgo/go/cmd/go/internal/imports/build.go
index eb070eef4c1..f5285e7458d 100644
--- a/libgo/go/cmd/go/internal/imports/build.go
+++ b/libgo/go/cmd/go/internal/imports/build.go
@@ -227,6 +227,8 @@ var KnownArch = map[string]bool{
 	"armbe":       true,
 	"arm64":       true,
 	"arm64be":     true,
+	"arm64p32":    true,
+	"arm64p32be":  true,
 	"ppc64":       true,
 	"ppc64le":     true,
 	"mips":        true,
diff --git a/libgo/go/cmd/internal/sys/arch.go b/libgo/go/cmd/internal/sys/arch.go
index e8687363def..636e8e7bdfe 100644
--- a/libgo/go/cmd/internal/sys/arch.go
+++ b/libgo/go/cmd/internal/sys/arch.go
@@ -89,6 +89,15 @@ var ArchARM64 = &Arch{
 	MinLC:     4,
 }
 
+var ArchARM64BE = &Arch{
+	Name:      "arm64be",
+	Family:    ARM64,
+	ByteOrder: binary.BigEndian,
+	PtrSize:   8,
+	RegSize:   8,
+	MinLC:     4,
+}
+
 var ArchMIPS = &Arch{
 	Name:      "mips",
 	Family:    MIPS,
@@ -175,6 +184,7 @@ var Archs = [...]*Arch{
 	ArchAMD64,
 	ArchARM,
 	ArchARM64,
+	ArchARM64BE,
 	ArchMIPS,
 	ArchMIPSLE,
 	ArchMIPS64,
diff --git a/libgo/go/cmd/internal/sys/supported.go b/libgo/go/cmd/internal/sys/supported.go
index 02f833e945e..0a5873f77a0 100644
--- a/libgo/go/cmd/internal/sys/supported.go
+++ b/libgo/go/cmd/internal/sys/supported.go
@@ -12,7 +12,7 @@ package sys
 func RaceDetectorSupported(goos, goarch string) bool {
 	switch goos {
 	case "linux":
-		return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64"
+		return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64" || goarch == "arm64be"
 	case "darwin", "freebsd", "netbsd", "windows":
 		return goarch == "amd64"
 	default:
@@ -25,7 +25,7 @@ func RaceDetectorSupported(goos, goarch string) bool {
 func MSanSupported(goos, goarch string) bool {
 	switch goos {
 	case "linux":
-		return goarch == "amd64" || goarch == "arm64"
+		return goarch == "amd64" || goarch == "arm64" || goarch == "arm64be"
 	default:
 		return false
 	}
@@ -65,6 +65,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
 	case "c-shared":
 		switch platform {
 		case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/ppc64le", "linux/s390x",
+			"linux/arm64be", "linux/arm64p32", "linux/arm64p32be",
 			"android/amd64", "android/arm", "android/arm64", "android/386",
 			"freebsd/amd64",
 			"darwin/amd64", "darwin/386",
@@ -82,6 +83,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
 	case "pie":
 		switch platform {
 		case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x",
+			"linux/arm64be", "linux/arm64p32", "linux/arm64p32be",
 			"android/amd64", "android/arm", "android/arm64", "android/386",
 			"freebsd/amd64",
 			"darwin/amd64",
@@ -92,7 +94,8 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
 
 	case "shared":
 		switch platform {
-		case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
+		case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x",
+			"linux/arm64be", "linux/arm64p32", "linux/arm64p32be":
 			return true
 		}
 		return false
@@ -100,6 +103,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
 	case "plugin":
 		switch platform {
 		case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le",
+			"linux/arm64be", "linux/arm64p32", "linux/arm64p32be",
 			"android/amd64", "android/arm", "android/arm64", "android/386",
 			"darwin/amd64",
 			"freebsd/amd64":
diff --git a/libgo/go/crypto/aes/aes_gcm.go b/libgo/go/crypto/aes/aes_gcm.go
index 3888010025f..24f10dee648 100644
--- a/libgo/go/crypto/aes/aes_gcm.go
+++ b/libgo/go/crypto/aes/aes_gcm.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build ignore
-// -build amd64 arm64
+// -build amd64 arm64 arm64be arm64p32 arm64p32be
 
 package aes
 
diff --git a/libgo/go/crypto/aes/cipher_asm.go b/libgo/go/crypto/aes/cipher_asm.go
index dc4251acc3d..ff4bcab7e3d 100644
--- a/libgo/go/crypto/aes/cipher_asm.go
+++ b/libgo/go/crypto/aes/cipher_asm.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build ignore_for_gccgo
-// +build amd64 arm64
+// +build amd64 arm64 arm64be arm64p32 arm64p32be
 
 package aes
 
diff --git a/libgo/go/crypto/aes/cipher_generic.go b/libgo/go/crypto/aes/cipher_generic.go
index 19a930f09d8..f8d8f508d5e 100644
--- a/libgo/go/crypto/aes/cipher_generic.go
+++ b/libgo/go/crypto/aes/cipher_generic.go
@@ -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,!s390x,!ppc64le,!arm64
+// -build !amd64,!s390x,!ppc64le,!arm64,!arm64be,!arm64p32,!arm64p32be
 
 package aes
 
diff --git a/libgo/go/golang.org/x/sys/cpu/byteorder.go b/libgo/go/golang.org/x/sys/cpu/byteorder.go
index da6b9e4363d..8044131bb57 100644
--- a/libgo/go/golang.org/x/sys/cpu/byteorder.go
+++ b/libgo/go/golang.org/x/sys/cpu/byteorder.go
@@ -15,11 +15,13 @@ func hostByteOrder() binary.ByteOrder {
 	switch runtime.GOARCH {
 	case "386", "amd64", "amd64p32",
 		"arm", "arm64",
+		"arm64p32",
 		"mipsle", "mips64le", "mips64p32le",
 		"ppc64le",
 		"riscv", "riscv64":
 		return binary.LittleEndian
 	case "armbe", "arm64be",
+		"arm64p32be",
 		"mips", "mips64", "mips64p32",
 		"ppc", "ppc64",
 		"s390", "s390x",
diff --git a/libgo/go/golang.org/x/sys/cpu/cpu_linux_arm64.go b/libgo/go/golang.org/x/sys/cpu/cpu_linux_arm64x.go
similarity index 97%
rename from libgo/go/golang.org/x/sys/cpu/cpu_linux_arm64.go
rename to libgo/go/golang.org/x/sys/cpu/cpu_linux_arm64x.go
index 15a9b4a7cc7..b523a6c93ae 100644
--- a/libgo/go/golang.org/x/sys/cpu/cpu_linux_arm64.go
+++ b/libgo/go/golang.org/x/sys/cpu/cpu_linux_arm64x.go
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build arm64 arm64be arm64p32 arm64p32be
+
 package cpu
 
 // HWCAP/HWCAP2 bits. These are exposed by Linux.
diff --git a/libgo/go/golang.org/x/sys/cpu/cpu_linux_other.go b/libgo/go/golang.org/x/sys/cpu/cpu_linux_other.go
index 6e8f9fe1920..7ab839234e9 100644
--- a/libgo/go/golang.org/x/sys/cpu/cpu_linux_other.go
+++ b/libgo/go/golang.org/x/sys/cpu/cpu_linux_other.go
@@ -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,!amd64p32,!386,!arm64,!ppc64,!ppc64le,!s390x
+// +build !amd64,!amd64p32,!386,!arm64,!arm64be,!arm64p32,!arm64p32be,!ppc64,!ppc64le,!s390x
 
 package cpu
 
diff --git a/libgo/go/internal/cpu/cpu_arm64.go b/libgo/go/internal/cpu/cpu_arm64x.go
similarity index 98%
rename from libgo/go/internal/cpu/cpu_arm64.go
rename to libgo/go/internal/cpu/cpu_arm64x.go
index 99fa9918625..5b0f1c5f55f 100644
--- a/libgo/go/internal/cpu/cpu_arm64.go
+++ b/libgo/go/internal/cpu/cpu_arm64x.go
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build arm64 arm64be arm64p32 arm64p32be
+
 package cpu
 
 // arm64 doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
diff --git a/libgo/go/internal/cpu/cpu_no_init.go b/libgo/go/internal/cpu/cpu_no_init.go
index d4b2be8cf4f..50e839e3301 100644
--- a/libgo/go/internal/cpu/cpu_no_init.go
+++ b/libgo/go/internal/cpu/cpu_no_init.go
@@ -6,6 +6,9 @@
 // +build !amd64
 // +build !arm
 // +build !arm64
+// +build !arm64be
+// +build !arm64p32
+// +build !arm64p32be
 // +build !ppc64
 // +build !ppc64le
 // +build !s390x
diff --git a/libgo/go/internal/syscall/unix/getrandom_linux_generic.go b/libgo/go/internal/syscall/unix/getrandom_linux_generic.go
index 0c79ae54f4b..8b498077b27 100644
--- a/libgo/go/internal/syscall/unix/getrandom_linux_generic.go
+++ b/libgo/go/internal/syscall/unix/getrandom_linux_generic.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build linux
-// +build arm64 arm64be nios2 riscv64
+// +build arm64 arm64be arm64p32 arm64p32be nios2 riscv64
 
 package unix
 
diff --git a/libgo/go/runtime/cputicks.go b/libgo/go/runtime/cputicks.go
index c41a58bafd0..94c93b4c547 100644
--- a/libgo/go/runtime/cputicks.go
+++ b/libgo/go/runtime/cputicks.go
@@ -4,6 +4,9 @@
 
 // // +build !arm
 // // +build !arm64
+// // +build !arm64be
+// // +build !arm64p32
+// // +build !arm64p32be
 // // +build !mips64
 // // +build !mips64le
 // // +build !mips
diff --git a/libgo/go/runtime/hash32.go b/libgo/go/runtime/hash32.go
index fba6bc354b1..30254eefd84 100644
--- a/libgo/go/runtime/hash32.go
+++ b/libgo/go/runtime/hash32.go
@@ -6,7 +6,7 @@
 //   xxhash: https://code.google.com/p/xxhash/
 // cityhash: https://code.google.com/p/cityhash/
 
-// +build 386 arm armbe m68k mips mipsle nios2 ppc s390 sh shbe sparc
+// +build 386 arm armbe m68k mips mipsle nios2 ppc s390 sh shbe sparc arm64p32 arm64p32be
 
 package runtime
 
diff --git a/libgo/go/runtime/lfstack_32bit.go b/libgo/go/runtime/lfstack_32bit.go
index 6da037e3f36..7612f02f040 100644
--- a/libgo/go/runtime/lfstack_32bit.go
+++ b/libgo/go/runtime/lfstack_32bit.go
@@ -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 amd64p32 arm armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc
+// +build 386 amd64p32 arm64p32 arm64p32be arm armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc
 
 package runtime
 
diff --git a/libgo/go/runtime/mpagealloc_32bit.go b/libgo/go/runtime/mpagealloc_32bit.go
index d18970ca26c..2caf16fd321 100644
--- a/libgo/go/runtime/mpagealloc_32bit.go
+++ b/libgo/go/runtime/mpagealloc_32bit.go
@@ -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 mips mipsle wasm darwin,arm64 amd64p32 armbe m68k mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc
+// +build 386 arm mips mipsle wasm darwin,arm64 amd64p32 arm64p32 arm64p32be armbe m68k mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc
 
 // wasm is a treated as a 32-bit architecture for the purposes of the page
 // allocator, even though it has 64-bit pointers. This is because any wasm
diff --git a/libgo/go/runtime/os_linux_arm64.go b/libgo/go/runtime/os_linux_arm64x.go
similarity index 94%
rename from libgo/go/runtime/os_linux_arm64.go
rename to libgo/go/runtime/os_linux_arm64x.go
index a482d47acdd..e4cfa210548 100644
--- a/libgo/go/runtime/os_linux_arm64.go
+++ b/libgo/go/runtime/os_linux_arm64x.go
@@ -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 arm64
+// +build arm64 arm64be arm64p32 arm64p32be
 
 package runtime
 
diff --git a/libgo/go/runtime/os_linux_noauxv.go b/libgo/go/runtime/os_linux_noauxv.go
index 895b4cd5f44..bbef4250fa0 100644
--- a/libgo/go/runtime/os_linux_noauxv.go
+++ b/libgo/go/runtime/os_linux_noauxv.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build linux
-// +build !arm,!arm64,!mips,!mipsle,!mips64,!mips64le,!s390x,!ppc64,!ppc64le
+// +build !arm,!arm64,!arm64be,!arm64p32,!arm64p32be,!mips,!mipsle,!mips64,!mips64le,!s390x,!ppc64,!ppc64le
 
 package runtime
 
diff --git a/libgo/go/syscall/endian_big.go b/libgo/go/syscall/endian_big.go
index 24a4d1df240..a30e9827bcf 100644
--- a/libgo/go/syscall/endian_big.go
+++ b/libgo/go/syscall/endian_big.go
@@ -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 mips64p32 s390 shbe sparc sparc64
+// +build ppc64 s390x mips mips64 armbe arm64be arm64p32be m68k ppc mips64p32 s390 shbe sparc sparc64
 
 package syscall
 
diff --git a/libgo/go/syscall/endian_little.go b/libgo/go/syscall/endian_little.go
index 0cd2d7524c6..375aea85f0e 100644
--- a/libgo/go/syscall/endian_little.go
+++ b/libgo/go/syscall/endian_little.go
@@ -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 alpha amd64 amd64p32 arm arm64 ia64 mips64le mipsle mips64p32le nios2 ppc64le riscv64 sh wasm
+// +build 386 alpha amd64 amd64p32 arm arm64 arm64p32 ia64 mips64le mipsle mips64p32le nios2 ppc64le riscv64 sh wasm
 
 package syscall
 
diff --git a/libgo/goarch.sh b/libgo/goarch.sh
index a5b6217c931..bb71139ba4e 100755
--- a/libgo/goarch.sh
+++ b/libgo/goarch.sh
@@ -71,7 +71,7 @@ case $goarch in
 		;;
 	esac
 	;;
-    arm64 | arm64be)
+    arm64 | arm64be | arm64p32 | arm64p32be )
 	family=ARM64
 	cachelinesize=32
 	defaultphyspagesize=65536
@@ -82,6 +82,11 @@ case $goarch in
 		bigendian=true
 		;;
 	esac
+	case $goarch in
+	    *p32*)
+		ptrsize=4
+		;;
+	esac
 	;;
     ia64)
 	family=IA64
diff --git a/libgo/match.sh b/libgo/match.sh
index cd35942f8bc..36439e4d6a8 100755
--- a/libgo/match.sh
+++ b/libgo/match.sh
@@ -116,7 +116,7 @@ for f in $gofiles; do
 	aix | android | darwin | dragonfly | freebsd | illumos | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag1=nonmatchingtag
 	    ;;
-	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
+	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | arm64p32 | arm64p32be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
 	    tag1=nonmatchingtag
 	    ;;
     esac
@@ -128,7 +128,7 @@ for f in $gofiles; do
 	aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag2=nonmatchingtag
 	    ;;
-	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
+	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | arm64p32 | arm64p32be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
 	    tag2=nonmatchingtag
 	    ;;
     esac
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index 33f99d77a31..85bc932ad3b 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -308,7 +308,7 @@ x)
 	    aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 		tag1=nonmatchingtag
 		;;
-	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
+	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | arm64p32 | arm64p32be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
 		tag1=nonmatchingtag
 		;;
 	    esac
@@ -320,7 +320,7 @@ x)
 	    aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 		tag2=nonmatchingtag
 		;;
-	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
+	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | arm64p32 | arm64p32be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
 		tag2=nonmatchingtag
 		;;
 	    esac
diff mbox series

Patch

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a6127013783..dff5fb5bc70 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@ 
-a69ad9c7d1b45edcf8062a07d3a3c9b6838c04f8
+c2225a76d1e15f28056596807ebbbc526d4c58da
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 4b2dd58d40a..56d38f57e7d 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -262,7 +262,8 @@  toolexeclibgohash_DATA = \
 	hash/adler32.gox \
 	hash/crc32.gox \
 	hash/crc64.gox \
-	hash/fnv.gox
+	hash/fnv.gox \
+	hash/maphash.gox
 
 toolexeclibgohtmldir = $(toolexeclibgodir)/html
 
@@ -402,6 +403,7 @@  toolexeclibgounicode_DATA = \
 noinst_DATA = \
 	golang.org/x/net/nettest.gox \
 	internal/cfg.gox \
+	internal/obscuretestdata.gox \
 	internal/testenv.gox \
 	internal/trace.gox \
 	net/internal/socktest.gox \
diff --git a/libgo/configure.ac b/libgo/configure.ac
index d4ee59ca685..07c03bcdf26 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -10,7 +10,7 @@  AC_INIT(package-unused, version-unused,, libgo)
 AC_CONFIG_SRCDIR(Makefile.am)
 AC_CONFIG_HEADER(config.h)
 
-libtool_VERSION=15:0:0
+libtool_VERSION=16:0:0
 AC_SUBST(libtool_VERSION)
 
 AM_ENABLE_MULTILIB(, ..)
diff --git a/libgo/VERSION b/libgo/VERSION
index e0f726521a4..da5318592de 100644
--- a/libgo/VERSION
+++ b/libgo/VERSION
@@ -1 +1 @@ 
-go1.13
+go1.14beta1
diff --git a/libgo/check-packages.txt b/libgo/check-packages.txt
index 156a2bd4593..48c4dfdbc91 100644
--- a/libgo/check-packages.txt
+++ b/libgo/check-packages.txt
@@ -3,7 +3,6 @@  archive/zip
 bufio
 bytes
 cmd/go/internal/cache
-cmd/go/internal/dirhash
 cmd/go/internal/generate
 cmd/go/internal/get
 cmd/go/internal/imports
@@ -13,13 +12,10 @@  cmd/go/internal/lockedfile/internal/filelock
 cmd/go/internal/modconv
 cmd/go/internal/modfetch
 cmd/go/internal/modfetch/codehost
-cmd/go/internal/modfile
 cmd/go/internal/modload
-cmd/go/internal/module
 cmd/go/internal/mvs
 cmd/go/internal/par
 cmd/go/internal/search
-cmd/go/internal/semver
 cmd/go/internal/txtar
 cmd/go/internal/work
 cmd/internal/buildid
@@ -96,6 +92,7 @@  hash/adler32
 hash/crc32
 hash/crc64
 hash/fnv
+hash/maphash
 html
 html/template
 image
@@ -163,6 +160,8 @@  strings
 sync
 sync/atomic
 syscall
+testing
+testing/iotest
 testing/quick
 text/scanner
 text/tabwriter
diff --git a/libgo/gotool-packages.txt b/libgo/gotool-packages.txt
index b5a3bbda3b8..90521ae0b50 100644
--- a/libgo/gotool-packages.txt
+++ b/libgo/gotool-packages.txt
@@ -5,7 +5,6 @@  cmd/go/internal/cache
 cmd/go/internal/cfg
 cmd/go/internal/clean
 cmd/go/internal/cmdflag
-cmd/go/internal/dirhash
 cmd/go/internal/doc
 cmd/go/internal/envcmd
 cmd/go/internal/fix
@@ -22,23 +21,17 @@  cmd/go/internal/modcmd
 cmd/go/internal/modconv
 cmd/go/internal/modfetch
 cmd/go/internal/modfetch/codehost
-cmd/go/internal/modfile
 cmd/go/internal/modget
 cmd/go/internal/modinfo
 cmd/go/internal/modload
-cmd/go/internal/module
 cmd/go/internal/mvs
-cmd/go/internal/note
 cmd/go/internal/par
 cmd/go/internal/renameio
 cmd/go/internal/robustio
 cmd/go/internal/run
 cmd/go/internal/search
-cmd/go/internal/semver
 cmd/go/internal/str
-cmd/go/internal/sumweb
 cmd/go/internal/test
-cmd/go/internal/tlog
 cmd/go/internal/tool
 cmd/go/internal/txtar
 cmd/go/internal/version
@@ -47,10 +40,22 @@  cmd/go/internal/web
 cmd/go/internal/work
 cmd/internal/browser
 cmd/internal/buildid
+cmd/internal/diff
 cmd/internal/edit
 cmd/internal/objabi
 cmd/internal/sys
 cmd/internal/test2json
+golang.org/x/crypto/ed25519
+golang.org/x/crypto/ed25519/internal/edwards25519
+golang.org/x/mod/internal/lazyregexp
+golang.org/x/mod/modfile
+golang.org/x/mod/module
+golang.org/x/mod/semver
+golang.org/x/mod/sumdb
+golang.org/x/mod/sumdb/dirhash
+golang.org/x/mod/sumdb/note
+golang.org/x/mod/sumdb/tlog
+golang.org/x/mod/zip
 golang.org/x/tools/go/analysis
 golang.org/x/tools/go/analysis/internal/analysisflags
 golang.org/x/tools/go/analysis/internal/facts
@@ -86,3 +91,5 @@  golang.org/x/tools/go/ast/inspector
 golang.org/x/tools/go/cfg
 golang.org/x/tools/go/types/objectpath
 golang.org/x/tools/go/types/typeutil
+golang.org/x/xerrors
+golang.org/x/xerrors/internal
diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt
index b19747a05b9..2b5fba806c6 100644
--- a/libgo/libgo-packages.txt
+++ b/libgo/libgo-packages.txt
@@ -72,12 +72,12 @@  go/printer
 go/scanner
 go/token
 go/types
+golang.org/x/crypto/chacha20
 golang.org/x/crypto/chacha20poly1305
 golang.org/x/crypto/cryptobyte
 golang.org/x/crypto/cryptobyte/asn1
 golang.org/x/crypto/curve25519
 golang.org/x/crypto/hkdf
-golang.org/x/crypto/internal/chacha20
 golang.org/x/crypto/internal/subtle
 golang.org/x/crypto/poly1305
 golang.org/x/net/dns/dnsmessage
@@ -96,6 +96,7 @@  hash/adler32
 hash/crc32
 hash/crc64
 hash/fnv
+hash/maphash
 html
 html/template
 image
@@ -116,6 +117,7 @@  internal/goversion
 internal/lazyregexp
 internal/lazytemplate
 internal/nettrace
+internal/obscuretestdata
 internal/oserror
 internal/poll
 internal/race
diff --git a/libgo/runtime/go-caller.c b/libgo/runtime/go-caller.c
index 5e31f912e0a..a18787671d1 100644
--- a/libgo/runtime/go-caller.c
+++ b/libgo/runtime/go-caller.c
@@ -27,6 +27,7 @@  struct caller
   intgo line;
   intgo index;
   intgo frames;
+  bool more;
 };
 
 /* Collect file/line information for a PC value.  If this is called
@@ -40,7 +41,19 @@  callback (void *data, uintptr_t pc __attribute__ ((unused)),
 {
   struct caller *c = (struct caller *) data;
 
-  c->frames++;
+  /* We want to make sure we return at least one frame.  If we already
+     have at least one frame, see if we should skip this one.  */
+  if (c->frames > 0
+      && function != NULL
+      && runtime_skipInCallback (function, NULL))
+    return 0;
+
+  /* If we already have a frame, don't increment frames if we should
+     skip that one.  */
+  if (c->frames == 0
+      || c->fn.len == 0
+      || !runtime_skipInCallback ((const char *) c->fn.str, NULL))
+    c->frames++;
 
   /* The libbacktrace library says that these strings might disappear,
      but with the current implementation they won't.  We can't easily
@@ -51,7 +64,16 @@  callback (void *data, uintptr_t pc __attribute__ ((unused)),
   c->line = lineno;
 
   if (c->index == 0)
-    return 1;
+    {
+      /* If there are more frames after the indexed one, and we should
+	 skip this one, then skip it.  */
+      if (c->more
+	  && c->fn.len > 0
+	  && runtime_skipInCallback((const char *) c->fn.str, NULL))
+	return 0;
+
+      return 1;
+    }
 
   if (c->index > 0)
     --c->index;
@@ -129,18 +151,21 @@  __go_get_backtrace_state ()
   return back_state;
 }
 
-/* Return function/file/line/nframes information for PC.  The index parameter
-   is the entry on the stack of inlined functions; -1 means the last
-   one, with *nframes set to the count of inlined frames for this PC.  */
+/* Return function/file/line/nframes information for PC.  The index
+   parameter is the entry on the stack of inlined functions; -1 means
+   the last one, with *nframes set to the count of inlined frames for
+   this PC.  If index is not -1, more is whether there are more frames
+   after this one.  */
 
 static _Bool
-__go_file_line (uintptr pc, int index, String *fn, String *file, intgo *line, intgo *nframes)
+__go_file_line (uintptr pc, int index, bool more, String *fn, String *file, intgo *line, intgo *nframes)
 {
   struct caller c;
   struct backtrace_state *state;
 
   runtime_memclr (&c, sizeof c);
   c.index = index;
+  c.more = more;
   c.frames = 0;
   runtime_xadd (&__go_runtime_in_callers, 1);
   state = __go_get_backtrace_state ();
@@ -223,11 +248,11 @@  Caller (intgo skip)
 /* Look up the function name, file name, and line number for a PC.  */
 
 struct funcfileline_return
-runtime_funcfileline (uintptr targetpc, int32 index)
+runtime_funcfileline (uintptr targetpc, int32 index, bool more)
 {
   struct funcfileline_return ret;
 
-  if (!__go_file_line (targetpc, index, &ret.retfn, &ret.retfile,
+  if (!__go_file_line (targetpc, index, more, &ret.retfn, &ret.retfile,
 		       &ret.retline, &ret.retframes))
     runtime_memclr (&ret, sizeof ret);
   return ret;
diff --git a/libgo/runtime/go-callers.c b/libgo/runtime/go-callers.c
index e7d53a32a5f..33956ca4dfc 100644
--- a/libgo/runtime/go-callers.c
+++ b/libgo/runtime/go-callers.c
@@ -27,8 +27,59 @@  struct callers_data
   int index;
   int max;
   int keep_thunks;
+  int saw_sigtramp;
 };
 
+/* Whether to skip a particular function name in the traceback.  This
+   is mostly to keep the output similar to the gc output for
+   runtime.Caller(N).
+
+   See also similar code in runtime/mprof.go that strips out such
+   functions for block/mutex/memory profiles.  */
+
+bool
+runtime_skipInCallback(const char *function, struct callers_data *arg)
+{
+  const char *p;
+
+  /* Skip thunks and recover functions.  There is no equivalent to
+     these functions in the gc toolchain.  */
+
+  p = function + __builtin_strlen (function);
+  while (p > function && p[-1] >= '0' && p[-1] <= '9')
+    --p;
+  if (p - function > 7 && __builtin_strncmp (p - 7, "..thunk", 7) == 0)
+    return true;
+  if (p - function > 3 && __builtin_strcmp (p - 3, "..r") == 0)
+    return true;
+  if (p - function > 6 && __builtin_strncmp (p - 6, "..stub", 6) == 0)
+    return true;
+
+  /* Skip runtime.deferreturn and runtime.sighandler as the gc
+     compiler has no corresponding function.  */
+  if (p - function == sizeof ("runtime.deferreturn") - 1
+      && __builtin_strcmp (function, "runtime.deferreturn") == 0)
+    return true;
+  if (p - function == sizeof ("runtime.sighandler") - 1
+      && __builtin_strcmp (function, "runtime.sighandler") == 0)
+    return true;
+
+  /* Skip the signal handler functions that remain on the stack for us
+     but not for gc.  */
+  if ((p - function == sizeof ("runtime.sigtramp") - 1
+       && __builtin_strcmp (function, "runtime.sigtramp") == 0)
+      || (p - function == sizeof ("runtime.sigtrampgo") - 1
+	  && __builtin_strcmp (function, "runtime.sigtrampgo") == 0))
+    {
+      /* Also try to skip the signal handler function.  */
+      if (arg != NULL)
+	arg->saw_sigtramp = 1;
+      return true;
+    }
+
+  return false;
+}
+
 /* Callback function for backtrace_full.  Just collect the locations.
    Return zero to continue, non-zero to stop.  */
 
@@ -39,6 +90,15 @@  callback (void *data, uintptr_t pc, const char *filename, int lineno,
   struct callers_data *arg = (struct callers_data *) data;
   Location *loc;
 
+  /* Skip an unnamed function above sigtramp.  It is likely the signal
+     handler function.  */
+  if (arg->saw_sigtramp)
+    {
+      arg->saw_sigtramp = 0;
+      if (function == NULL)
+	return 0;
+    }
+
   /* Skip split stack functions.  */
   if (function != NULL)
     {
@@ -61,25 +121,10 @@  callback (void *data, uintptr_t pc, const char *filename, int lineno,
 	return 0;
     }
 
-  /* Skip thunks and recover functions.  There is no equivalent to
-     these functions in the gc toolchain, so returning them here means
-     significantly different results for runtime.Caller(N). See also
-     similar code in runtime/mprof.go that strips out such functions
-     for block/mutex/memory profiles.  */
-  if (function != NULL && !arg->keep_thunks)
-    {
-      const char *p;
-
-      p = function + __builtin_strlen (function);
-      while (p > function && p[-1] >= '0' && p[-1] <= '9')
-	--p;
-      if (p - function > 7 && __builtin_strncmp (p - 7, "..thunk", 7) == 0)
-	return 0;
-      if (p - function > 3 && __builtin_strcmp (p - 3, "..r") == 0)
-	return 0;
-      if (p - function > 6 && __builtin_strncmp (p - 6, "..stub", 6) == 0)
-	return 0;
-    }
+  if (function != NULL
+      && !arg->keep_thunks
+      && runtime_skipInCallback (function, arg))
+    return 0;
 
   if (arg->skip > 0)
     {
@@ -204,6 +249,7 @@  runtime_callers (int32 skip, Location *locbuf, int32 m, bool keep_thunks)
   data.index = 0;
   data.max = m;
   data.keep_thunks = keep_thunks;
+  data.saw_sigtramp = 0;
   runtime_xadd (&__go_runtime_in_callers, 1);
   state = __go_get_backtrace_state ();
   backtrace_full (state, 0, callback, error_callback, &data);
@@ -248,6 +294,9 @@  Callers (intgo skip, struct __go_open_array pc)
   int ret;
   int i;
 
+  if (pc.__count == 0)
+    return 0;
+
   /* Note that calling mallocgc here assumes that we are not going to
      store any allocated Go pointers in the slice.  */
   locbuf = (Location *) runtime_mallocgc (pc.__count * sizeof (Location),
diff --git a/libgo/runtime/go-nanotime.c b/libgo/runtime/go-nanotime.c
index d221847adac..c7adfffb4f5 100644
--- a/libgo/runtime/go-nanotime.c
+++ b/libgo/runtime/go-nanotime.c
@@ -8,11 +8,11 @@ 
 
 #include "runtime.h"
 
-int64 runtime_nanotime (void)
+int64 runtime_nanotime1 (void)
   __attribute__ ((no_split_stack));
 
 int64
-runtime_nanotime (void)
+runtime_nanotime1 (void)
 {
   struct timespec ts;
 
diff --git a/libgo/runtime/go-now.c b/libgo/runtime/go-now.c
index a45890bfd5a..1c02e5220e4 100644
--- a/libgo/runtime/go-now.c
+++ b/libgo/runtime/go-now.c
@@ -8,7 +8,7 @@ 
 
 #include "runtime.h"
 
-// Return current time.  This is the implementation of time.walltime().
+// Return current time.  This is the implementation of time.walltime1().
 
 struct walltime_ret
 {
@@ -16,7 +16,7 @@  struct walltime_ret
   int32_t nsec;
 };
 
-struct walltime_ret now(void) __asm__ (GOSYM_PREFIX "runtime.walltime")
+struct walltime_ret now(void) __asm__ (GOSYM_PREFIX "runtime.walltime1")
   __attribute__ ((no_split_stack));
 
 struct walltime_ret
diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h
index 89134c1d0e0..f46eaea07b9 100644
--- a/libgo/runtime/runtime.h
+++ b/libgo/runtime/runtime.h
@@ -283,8 +283,11 @@  void	runtime_entersyscallblock()
   __asm__ (GOSYM_PREFIX "runtime.entersyscallblock");
 G*	__go_go(uintptr, void*);
 int32	runtime_callers(int32, Location*, int32, bool keep_callers);
-int64	runtime_nanotime(void)	// monotonic time
-  __asm__(GOSYM_PREFIX "runtime.nanotime");
+struct callers_data;
+bool	runtime_skipInCallback(const char *, struct callers_data *)
+  __asm__ (GOSYM_PREFIX "runtime.skipInCallback");
+int64	runtime_nanotime1(void)	// monotonic time
+  __asm__(GOSYM_PREFIX "runtime.nanotime1");
 void	runtime_dopanic(int32) __attribute__ ((noreturn));
 void	runtime_startpanic(void)
   __asm__ (GOSYM_PREFIX "runtime.startpanic");
@@ -464,7 +467,7 @@  struct funcfileline_return
 };
 
 struct funcfileline_return
-runtime_funcfileline (uintptr targetpc, int32 index)
+runtime_funcfileline (uintptr targetpc, int32 index, bool more)
   __asm__ (GOSYM_PREFIX "runtime.funcfileline");
 
 /*
diff --git a/libgo/runtime/runtime_c.c b/libgo/runtime/runtime_c.c
index 7531431342c..e7951a051a6 100644
--- a/libgo/runtime/runtime_c.c
+++ b/libgo/runtime/runtime_c.c
@@ -134,16 +134,22 @@  int32 go_read(int32, void *, int32)
 int32
 go_read(int32 fd, void *p, int32 n)
 {
-  return runtime_read(fd, p, n);
+  ssize_t r = runtime_read(fd, p, n);
+  if (r < 0)
+    r = - errno;
+  return (int32)r;
 }
 
-int32 go_write(uintptr, void *, int32)
-  __asm__ (GOSYM_PREFIX "runtime.write");
+int32 go_write1(uintptr, void *, int32)
+  __asm__ (GOSYM_PREFIX "runtime.write1");
 
 int32
-go_write(uintptr fd, void *p, int32 n)
+go_write1(uintptr fd, void *p, int32 n)
 {
-  return runtime_write(fd, p, n);
+  ssize_t r = runtime_write(fd, p, n);
+  if (r < 0)
+    r = - errno;
+  return (int32)r;
 }
 
 int32 go_closefd(int32)
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index 6929de34ba0..de4a392b8cd 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -305,7 +305,7 @@  x)
 	    "") ;;
 	    $goarch) ;;
 	    $goos) ;;
-	    aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	    aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 		tag1=nonmatchingtag
 		;;
 	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
@@ -317,7 +317,7 @@  x)
 	    "") ;;
 	    $goarch) ;;
 	    $goos) ;;
-	    aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	    aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 		tag2=nonmatchingtag
 		;;
 	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
@@ -624,7 +624,9 @@  exampleoutput() {
 		echo 'import _ "./_xtest_"'
 	    fi
 	fi
-	echo 'import "testing"'
+	if test "$package" != "testing"; then
+		echo 'import "testing"'
+	fi
 	echo 'import "testing/internal/testdeps"'
 	if ! test -n "$testmain"; then
 		echo 'import __os__ "os"'
diff --git a/libgo/match.sh b/libgo/match.sh
index 281acf7ae13..cd35942f8bc 100755
--- a/libgo/match.sh
+++ b/libgo/match.sh
@@ -113,7 +113,7 @@  for f in $gofiles; do
 	"") ;;
 	$goarch) ;;
 	$goos) ;;
-	aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	aix | android | darwin | dragonfly | freebsd | illumos | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag1=nonmatchingtag
 	    ;;
 	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
@@ -125,7 +125,7 @@  for f in $gofiles; do
 	"") ;;
 	$goarch) ;;
 	$goos) ;;
-	aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag2=nonmatchingtag
 	    ;;
 	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
diff --git a/libgo/merge.sh b/libgo/merge.sh
index 7138891cd61..b15189e5c4a 100755
--- a/libgo/merge.sh
+++ b/libgo/merge.sh
@@ -128,7 +128,7 @@  echo ${rev} > VERSION
 (cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
   skip=false
   case "$f" in
-  ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/testjson/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/testj2on/* | ./cmd/internal/sys/* | ./cmd/vendor/golang.org/x/tools/* )
+  ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/testjson/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/testj2on/* | ./cmd/internal/sys/* | ./cmd/vendor/golang.org/x/tools/* | ./cmd/vendor/golang.org/x/mod/* | ./cmd/vendor/golang.org/x/xerrors/* | ./cmd/vendor/golang.org/x/crypto/ed25519)
     ;;
   ./cmd/*)
     skip=true
@@ -150,7 +150,7 @@  done
 (cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
   skip=false
   case "$d" in
-  ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/testjson/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/testj2on/* | ./cmd/internal/sys/* | ./cmd/vendor/golang.org/x/tools/* )
+  ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/testjson/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/diff/* | | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/testj2on/* | ./cmd/internal/sys/* | ./cmd/vendor/golang.org/x/tools/* )
     ;;
   ./cmd/*)
     skip=true
@@ -165,7 +165,7 @@  done
 
   oldtd=${OLDDIR}/src/$d
   newtd=${NEWDIR}/src/$d
-  libgofile=go/`echo $d | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
+  libgotd=go/`echo $d | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
   if ! test -d ${oldtd}; then
     echo "merge.sh: $d: NEWDIR"
     continue
diff --git a/gotools/Makefile.am b/gotools/Makefile.am
index d36b61ca88e..47adf9bafeb 100644
--- a/gotools/Makefile.am
+++ b/gotools/Makefile.am
@@ -116,7 +116,7 @@  man_MANS = go.1 gofmt.1
 go$(EXEEXT): $(go_cmd_go_files) $(LIBGOTOOL) $(LIBGODEP)
 	$(GOLINK) $(go_cmd_go_files) $(LIBGOTOOL) $(LIBS) $(NET_LIBS)
 gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
-	$(GOLINK) $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
+	$(GOLINK) $(go_cmd_gofmt_files) $(LIBGOTOOL) $(LIBS) $(NET_LIBS)
 cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGOTOOL) $(LIBGODEP)
 	$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(LIBGOTOOL) $(LIBS) $(NET_LIBS)
 vet$(EXEEXT): $(go_cmd_vet_files) $(LIBGOTOOL) $(LIBGODEP)
@@ -215,6 +215,10 @@  check-go-tool: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc
 	cp $(libgodir)/zdefaultcc.go check-go-dir/src/cmd/go/internal/cfg/
 	cp -r $(cmdsrcdir)/go/testdata check-go-dir/src/cmd/go/
 	cp -r $(cmdsrcdir)/internal check-go-dir/src/cmd/
+	$(MKDIR_P) check-go-dir/src/cmd/vendor/golang.org/x
+	cp -r $(libgosrcdir)/golang.org/x/mod check-go-dir/src/cmd/vendor/golang.org/x/
+	cp -r $(libgosrcdir)/golang.org/x/crypto check-go-dir/src/cmd/vendor/golang.org/x/
+	cp -r $(libgosrcdir)/golang.org/x/xerrors check-go-dir/src/cmd/vendor/golang.org/x/
 	cp $(libgodir)/objabi.go check-go-dir/src/cmd/internal/objabi/
 	@abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
 	abs_checkdir=`cd check-go-dir && $(PWD_COMMAND)`; \