diff mbox series

libgo patch committed: Update to Go1.17rc2 release

Message ID CAOyqgcXvCFTFKVKv43+RGk7V_AhQNxUKwhkmEAdXw-UMZm1-tA@mail.gmail.com
State New
Headers show
Series libgo patch committed: Update to Go1.17rc2 release | expand

Commit Message

Ian Lance Taylor Aug. 13, 2021, 3:23 a.m. UTC
This patch updates libgo from the Go1.16.5 release to the Go 1.17rc2
release.  As usual with these version updates, the patch itself is too
large to attach to this e-mail message.  I've attached the changes to
files that are specific to gccgo.  Bootstraped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
5fe441d33024fe33b9835c3e8d6b9f6cf24715f1

Comments

Rainer Orth Aug. 13, 2021, 12:43 p.m. UTC | #1
Hi Ian,

> This patch updates libgo from the Go1.16.5 release to the Go 1.17rc2
> release.  As usual with these version updates, the patch itself is too
> large to attach to this e-mail message.  I've attached the changes to
> files that are specific to gccgo.  Bootstraped and ran Go testsuite on
> x86_64-pc-linux-gnu.  Committed to mainline.

this patch broke Solaris bootstrap:

/vol/gcc/src/hg/master/local/libgo/runtime/stack.c: In function 'onCurrentStack':
/vol/gcc/src/hg/master/local/libgo/runtime/stack.c:177:21: error: expected expression before 'uintptr'
  177 |                 if (uintptr(initialsp2) < uintptr(nextsp2)) {
      |                     ^~~~~~~

Fixed by turning those into proper casts.

	Rainer
Ian Lance Taylor Aug. 13, 2021, 5:39 p.m. UTC | #2
On Fri, Aug 13, 2021 at 5:43 AM Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>
> Hi Ian,
>
> > This patch updates libgo from the Go1.16.5 release to the Go 1.17rc2
> > release.  As usual with these version updates, the patch itself is too
> > large to attach to this e-mail message.  I've attached the changes to
> > files that are specific to gccgo.  Bootstraped and ran Go testsuite on
> > x86_64-pc-linux-gnu.  Committed to mainline.
>
> this patch broke Solaris bootstrap:
>
> /vol/gcc/src/hg/master/local/libgo/runtime/stack.c: In function 'onCurrentStack':
> /vol/gcc/src/hg/master/local/libgo/runtime/stack.c:177:21: error: expected expression before 'uintptr'
>   177 |                 if (uintptr(initialsp2) < uintptr(nextsp2)) {
>       |                     ^~~~~~~
>
> Fixed by turning those into proper casts.

Sorry about that.  I've committed this patch.

Ian
a91ca5ff5fa56b54cfc03f43891ff613d714b722
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index bcbe1d93018..3000285fbf0 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-33f65dce43bd01c1fa38cd90a78c9aea6ca6dd59
+f2b7a2ce94127ad444a772bd1631516c5c67fb73
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/runtime/stack.c b/libgo/runtime/stack.c
index 0c0c30e46ac..65e8fa30077 100644
--- a/libgo/runtime/stack.c
+++ b/libgo/runtime/stack.c
@@ -174,7 +174,7 @@ bool onCurrentStack(uintptr p)
 	nextsp2 = secondary_stack_pointer();
 	if (nextsp2 != nil) {
 		initialsp2 = (byte*)(void*)(gp->gcinitialsp2);
-		if (uintptr(initialsp2) < uintptr(nextsp2)) {
+		if ((uintptr)(initialsp2) < (uintptr)(nextsp2)) {
 			temp = initialsp2;
 			initialsp2 = nextsp2;
 			nextsp2 = temp;
Rainer Orth Aug. 13, 2021, 9:08 p.m. UTC | #3
Hi Ian,

> Sorry about that.  I've committed this patch.

thanks.

unfortunately, things are considerably worse: syscall.lo fails to build
and go1 even ICEs:

/vol/gcc/src/hg/master/local/libgo/go/syscall/libcall_posix_utimesnano.go:13:1: error: redefinition of ‘UtimesNano’
   13 | func UtimesNano(path string, ts []Timespec) error {
      | ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/libcall_linux_utimesnano.go:13:1: note: previous definition of ‘UtimesNano’ was here
   13 | func UtimesNano(path string, ts []Timespec) (err error) {
      | ^

The second file is Linux-only and needs a corresponding build guard.

/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:193:16: error: use of undefined type ‘SysProcAttr’
  193 |         Sys   *SysProcAttr
      |                ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:235:15: error: reference to field ‘Chroot’ in object which has no fields or methods
  235 |         if sys.Chroot != "" {
      |               ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:236:52: error: reference to field ‘Chroot’ in object which has no fields or methods
  236 |                 chroot, err = BytePtrFromString(sys.Chroot)
      |                                                    ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:251:15: error: reference to field ‘Setctty’ in object which has no fields or methods
  251 |         if sys.Setctty && sys.Foreground {
      |               ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:251:30: error: reference to field ‘Foreground’ in object which has no fields or methods
  251 |         if sys.Setctty && sys.Foreground {
      |                              ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:254:15: error: reference to field ‘Setctty’ in object which has no fields or methods
  254 |         if sys.Setctty && sys.Ctty >= len(attr.Files) {
      |               ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:254:30: error: reference to field ‘Ctty’ in object which has no fields or methods
  254 |         if sys.Setctty && sys.Ctty >= len(attr.Files) {
      |                              ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:269:21: error: reference to undefined name ‘forkAndExecInChild’
  269 |         pid, err1 = forkAndExecInChild(argv0p, argvp, envvp, chroot, dir, attr, sys, p[1])
      |                     ^

I found that upstream has exec_libc.go for AIX and Solaris with the
missing SysProcAttr and forkAndExecInChild definitions.  It doesn't work
out of the box, though:

/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:63:9: error: reference to undefined name ‘execveLibc’
   63 |         execveLibc = execve
      |         ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:137:25: error: reference to undefined name ‘_Pid_t’
  137 |                 pgrp := _Pid_t(sys.Pgid)
      |                         ^
/vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:144:32: error: reference to undefined name ‘_Pid_t’
  144 |                         pgrp = _Pid_t(r1)
      |                                ^

For one, switching to Pid_t is needed:
Besides, support for execveLibc has been dropped in exec_unix.go
compared to upstream.

terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 1) >= this->size() (which is 1)
go1: internal compiler error: Abort
0xce1abf crash_signal
	/vol/gcc/src/hg/master/local/gcc/toplev.c:328

This went away after the fixes above.

Next, I get

/vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:10:15: error: imported and not used: unsafe
   10 |         "unsafe"
      |               ^
/vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:32:30: error: reference to undefined name 'getrandomUnsupported'
   32 |         if atomic.LoadInt32(&getrandomUnsupported) != 0 {
      |                              ^
/vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:41:44: error: reference to undefined name 'getrandomUnsupported'
   41 |                         atomic.StoreInt32(&getrandomUnsupported, 1)
      |                                            ^
make[4]: *** [Makefile:3008: internal/syscall/unix.lo] Error 1

The definition dropped compared to upstream.

/vol/gcc/src/hg/master/local/libgo/go/os/user/listgroups_unix.go:39:15: error: reference to undefined name ‘libc_getgrouplist’
   39 |         rv := libc_getgrouplist(nameC, userGID, &gidsC[0], &n)
      |               ^
/vol/gcc/src/hg/master/local/libgo/go/os/user/listgroups_unix.go:49:23: error: reference to undefined name ‘libc_getgrouplist’
   49 |                 rv := libc_getgrouplist(nameC, userGID, &gidsC[0], &n)
      |                       ^
make[6]: *** [Makefile:3008: os/user.lo] Error 1

I've added it to decls_solaris.go.

With those changes, libgo compiles and links.  Unfortunately, every
executable fails to link now:

Undefined                       first referenced
 symbol                             in file
syscall.setpgid                     ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.chroot1                     ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.getpid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.fcntl1                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.execve                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.setgid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.setsid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.setuid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.exit                        ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.write1                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.chdir                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.close                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.forkx                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.ioctl                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.dup2child                   ../i386-pc-solaris2.11/libgo/.libs/libgo.so
syscall.setgroups1                  ../i386-pc-solaris2.11/libgo/.libs/libgo.so
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status

They are declared in go/syscall/exec_libc.go, but I don't see the best
way to handle this.  I'm calling it a night now.

	Rainer
Ian Lance Taylor Aug. 15, 2021, 12:35 a.m. UTC | #4
On Fri, Aug 13, 2021 at 2:08 PM Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>
> unfortunately, things are considerably worse: syscall.lo fails to build
> and go1 even ICEs:
>
> /vol/gcc/src/hg/master/local/libgo/go/syscall/libcall_posix_utimesnano.go:13:1: error: redefinition of ‘UtimesNano’
>    13 | func UtimesNano(path string, ts []Timespec) error {
>       | ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/libcall_linux_utimesnano.go:13:1: note: previous definition of ‘UtimesNano’ was here
>    13 | func UtimesNano(path string, ts []Timespec) (err error) {
>       | ^
>
> The second file is Linux-only and needs a corresponding build guard.
>
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:193:16: error: use of undefined type ‘SysProcAttr’
>   193 |         Sys   *SysProcAttr
>       |                ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:235:15: error: reference to field ‘Chroot’ in object which has no fields or methods
>   235 |         if sys.Chroot != "" {
>       |               ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:236:52: error: reference to field ‘Chroot’ in object which has no fields or methods
>   236 |                 chroot, err = BytePtrFromString(sys.Chroot)
>       |                                                    ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:251:15: error: reference to field ‘Setctty’ in object which has no fields or methods
>   251 |         if sys.Setctty && sys.Foreground {
>       |               ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:251:30: error: reference to field ‘Foreground’ in object which has no fields or methods
>   251 |         if sys.Setctty && sys.Foreground {
>       |                              ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:254:15: error: reference to field ‘Setctty’ in object which has no fields or methods
>   254 |         if sys.Setctty && sys.Ctty >= len(attr.Files) {
>       |               ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:254:30: error: reference to field ‘Ctty’ in object which has no fields or methods
>   254 |         if sys.Setctty && sys.Ctty >= len(attr.Files) {
>       |                              ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:269:21: error: reference to undefined name ‘forkAndExecInChild’
>   269 |         pid, err1 = forkAndExecInChild(argv0p, argvp, envvp, chroot, dir, attr, sys, p[1])
>       |                     ^
>
> I found that upstream has exec_libc.go for AIX and Solaris with the
> missing SysProcAttr and forkAndExecInChild definitions.  It doesn't work
> out of the box, though:
>
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:63:9: error: reference to undefined name ‘execveLibc’
>    63 |         execveLibc = execve
>       |         ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:137:25: error: reference to undefined name ‘_Pid_t’
>   137 |                 pgrp := _Pid_t(sys.Pgid)
>       |                         ^
> /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:144:32: error: reference to undefined name ‘_Pid_t’
>   144 |                         pgrp = _Pid_t(r1)
>       |                                ^
>
> For one, switching to Pid_t is needed:
>
>
> Besides, support for execveLibc has been dropped in exec_unix.go
> compared to upstream.
>
> terminate called after throwing an instance of 'std::out_of_range'
>   what():  vector::_M_range_check: __n (which is 1) >= this->size() (which is 1)
> go1: internal compiler error: Abort
> 0xce1abf crash_signal
>         /vol/gcc/src/hg/master/local/gcc/toplev.c:328
>
> This went away after the fixes above.
>
> Next, I get
>
> /vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:10:15: error: imported and not used: unsafe
>    10 |         "unsafe"
>       |               ^
> /vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:32:30: error: reference to undefined name 'getrandomUnsupported'
>    32 |         if atomic.LoadInt32(&getrandomUnsupported) != 0 {
>       |                              ^
> /vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:41:44: error: reference to undefined name 'getrandomUnsupported'
>    41 |                         atomic.StoreInt32(&getrandomUnsupported, 1)
>       |                                            ^
> make[4]: *** [Makefile:3008: internal/syscall/unix.lo] Error 1
>
> The definition dropped compared to upstream.
>
> /vol/gcc/src/hg/master/local/libgo/go/os/user/listgroups_unix.go:39:15: error: reference to undefined name ‘libc_getgrouplist’
>    39 |         rv := libc_getgrouplist(nameC, userGID, &gidsC[0], &n)
>       |               ^
> /vol/gcc/src/hg/master/local/libgo/go/os/user/listgroups_unix.go:49:23: error: reference to undefined name ‘libc_getgrouplist’
>    49 |                 rv := libc_getgrouplist(nameC, userGID, &gidsC[0], &n)
>       |                       ^
> make[6]: *** [Makefile:3008: os/user.lo] Error 1
>
> I've added it to decls_solaris.go.
>
> With those changes, libgo compiles and links.  Unfortunately, every
> executable fails to link now:
>
> Undefined                       first referenced
>  symbol                             in file
> syscall.setpgid                     ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.chroot1                     ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.getpid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.fcntl1                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.execve                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.setgid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.setsid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.setuid                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.exit                        ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.write1                      ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.chdir                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.close                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.forkx                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.ioctl                       ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.dup2child                   ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> syscall.setgroups1                  ../i386-pc-solaris2.11/libgo/.libs/libgo.so
> ld: fatal: symbol referencing errors
> collect2: error: ld returned 1 exit status
>
> They are declared in go/syscall/exec_libc.go, but I don't see the best
> way to handle this.  I'm calling it a night now.

I committed this path that should fix these problems.

Ian
a9cc8b18a7ebe76592f0db69d2c30a73a57c2cf5
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 3000285fbf0..950f1797b55 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-f2b7a2ce94127ad444a772bd1631516c5c67fb73
+77bc32767b61feb6499ca7921e96b356603517dc
 
 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/syscall/unix/getrandom_solaris.go b/libgo/go/internal/syscall/unix/getrandom_solaris.go
index caf9b60d036..9d0f0944e18 100644
--- a/libgo/go/internal/syscall/unix/getrandom_solaris.go
+++ b/libgo/go/internal/syscall/unix/getrandom_solaris.go
@@ -7,12 +7,13 @@ package unix
 import (
 	"sync/atomic"
 	"syscall"
-	"unsafe"
 )
 
 //extern getrandom
 func libc_getrandom(*byte, uintptr, uint32) uintptr
 
+var getrandomUnsupported int32 // atomic
+
 // GetRandomFlag is a flag supported by the getrandom system call.
 type GetRandomFlag uintptr
 
diff --git a/libgo/go/os/user/decls_solaris.go b/libgo/go/os/user/decls_solaris.go
index ccdf36b13d6..43b6a044047 100644
--- a/libgo/go/os/user/decls_solaris.go
+++ b/libgo/go/os/user/decls_solaris.go
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build solaris
-// +build cgo
+//go:build solaris && cgo
+// +build solaris,cgo
 
 package user
 
@@ -22,3 +22,6 @@ func libc_getgrnam_r(name *byte, grp *syscall.Group, buf *byte, buflen syscall.S
 
 //extern __posix_getgrgid_r
 func libc_getgrgid_r(gid syscall.Gid_t, grp *syscall.Group, buf *byte, buflen syscall.Size_t, result **syscall.Group) int
+
+//extern getgrouplist
+func libc_getgrouplist(user *byte, group syscall.Gid_t, groups *syscall.Gid_t, ngroups *int32) int
diff --git a/libgo/go/runtime/crash_test.go b/libgo/go/runtime/crash_test.go
index 15c60008dbf..e3633af7ccf 100644
--- a/libgo/go/runtime/crash_test.go
+++ b/libgo/go/runtime/crash_test.go
@@ -744,6 +744,10 @@ func TestTimePprof(t *testing.T) {
 
 // Test that runtime.abort does so.
 func TestAbort(t *testing.T) {
+	if runtime.Compiler == "gccgo" && runtime.GOOS == "solaris" {
+		t.Skip("not supported by gofrontend on Solaris")
+	}
+
 	// Pass GOTRACEBACK to ensure we get runtime frames.
 	output := runTestProg(t, "testprog", "Abort", "GOTRACEBACK=system")
 	if want := "runtime.abort"; !strings.Contains(output, want) {
@@ -805,6 +809,10 @@ func TestRuntimePanic(t *testing.T) {
 
 // Test that g0 stack overflows are handled gracefully.
 func TestG0StackOverflow(t *testing.T) {
+	if runtime.Compiler == "gccgo" {
+		t.Skip("g0 stack overflow not supported by gofrontend")
+	}
+
 	testenv.MustHaveExec(t)
 
 	switch runtime.GOOS {
diff --git a/libgo/go/syscall/exec_bsd.go b/libgo/go/syscall/exec_bsd.go
index a081c096fea..ad65f63c57b 100644
--- a/libgo/go/syscall/exec_bsd.go
+++ b/libgo/go/syscall/exec_bsd.go
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build dragonfly || freebsd || hurd || netbsd || (openbsd && mips64)
-// +build dragonfly freebsd hurd netbsd openbsd,mips64
+//go:build aix || darwin || dragonfly || freebsd || hurd || netbsd || openbsd || solaris
+// +build aix darwin dragonfly freebsd hurd netbsd openbsd solaris
 
 package syscall
 
diff --git a/libgo/go/syscall/exec_unix_test.go b/libgo/go/syscall/exec_unix_test.go
index 85957225692..3b78d20db99 100644
--- a/libgo/go/syscall/exec_unix_test.go
+++ b/libgo/go/syscall/exec_unix_test.go
@@ -180,7 +180,7 @@ func TestForeground(t *testing.T) {
 
 	fpgrp := syscall.Pid_t(0)
 
-	errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp)))
+	errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, unsafe.Pointer(&fpgrp))
 	if errno != 0 {
 		t.Fatalf("TIOCGPGRP failed with error code: %s", errno)
 	}
@@ -217,7 +217,7 @@ func TestForeground(t *testing.T) {
 
 	// This call fails on darwin/arm64. The failure doesn't matter, though.
 	// This is just best effort.
-	syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp)))
+	syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, unsafe.Pointer(&fpgrp))
 }
 
 func TestForegroundSignal(t *testing.T) {
@@ -231,7 +231,7 @@ func TestForegroundSignal(t *testing.T) {
 	// equivalent.
 	fpgrp := int32(0)
 
-	errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp)))
+	errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, unsafe.Pointer(&fpgrp))
 	if errno != 0 {
 		t.Fatalf("TIOCGPGRP failed with error code: %s", errno)
 	}
@@ -242,7 +242,7 @@ func TestForegroundSignal(t *testing.T) {
 
 	defer func() {
 		signal.Ignore(syscall.SIGTTIN, syscall.SIGTTOU)
-		syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp)))
+		syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, unsafe.Pointer(&fpgrp))
 		signal.Reset()
 	}()
 
diff --git a/libgo/go/syscall/export_aix_test.go b/libgo/go/syscall/export_aix_test.go
index 044337b9993..7ea5864a66d 100644
--- a/libgo/go/syscall/export_aix_test.go
+++ b/libgo/go/syscall/export_aix_test.go
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build aix
 // +build aix
 
 package syscall
@@ -10,7 +11,7 @@ import (
 	"unsafe"
 )
 
-func Ioctl(fd, req, arg uintptr) (err Errno) {
-	_, err = raw_ioctl_ptr(int(fd), req, unsafe.Pointer(arg))
+func Ioctl(fd, req uintptr, arg unsafe.Pointer) (err Errno) {
+	_, err = raw_ioctl_ptr(int(fd), req, arg)
 	return err
 }
diff --git a/libgo/go/syscall/export_unix_test.go b/libgo/go/syscall/export_unix_test.go
index b051e368d4f..f32118b519d 100644
--- a/libgo/go/syscall/export_unix_test.go
+++ b/libgo/go/syscall/export_unix_test.go
@@ -2,12 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build dragonfly || freebsd || hurd || linux || netbsd || openbsd
-// +build dragonfly freebsd hurd linux netbsd openbsd
+//go:build dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris
+// +build dragonfly freebsd hurd linux netbsd openbsd solaris
 
 package syscall
 
-func Ioctl(fd, req, arg uintptr) (err Errno) {
-	_, _, err = Syscall(SYS_IOCTL, fd, req, arg)
+import "unsafe"
+
+func Ioctl(fd, req uintptr, arg unsafe.Pointer) (err Errno) {
+	_, err = raw_ioctl_ptr(int(fd), req, arg)
 	return err
 }
diff --git a/libgo/go/syscall/libcall_linux_utimesnano.go b/libgo/go/syscall/libcall_linux_utimesnano.go
index 90da2ae04e5..582833812f6 100644
--- a/libgo/go/syscall/libcall_linux_utimesnano.go
+++ b/libgo/go/syscall/libcall_linux_utimesnano.go
@@ -2,6 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build linux
+// +build linux
+
 // GNU/Linux version of UtimesNano.
 
 package syscall
diff --git a/libgo/mkruntimeinc.sh b/libgo/mkruntimeinc.sh
index dbe44d99175..61d830af876 100755
--- a/libgo/mkruntimeinc.sh
+++ b/libgo/mkruntimeinc.sh
@@ -19,7 +19,7 @@ rm -f runtime.inc.tmp2 runtime.inc.tmp3
 # boundsError has a field name that is a C keyword, and we don't need it.
 # mSpanInuse is both a constant and a field name, and we don't need it.
 
-grep -v "#define _" ${IN} | grep -v "#define [cm][01234] " | grep -v "#define empty " | grep -v "#define \\$" | grep -v "#define mSpanInUse " > runtime.inc.tmp2
+grep -v "#define _" ${IN} | grep -v "#define [cm][012345] " | grep -v "#define empty " | grep -v "#define \\$" | grep -v "#define mSpanInUse " > runtime.inc.tmp2
 for pattern in '_[GP][a-z]' _Max _Lock _Sig _Trace _MHeap _Num
 do
   grep "#define $pattern" ${IN} >> runtime.inc.tmp2
H.J. Lu Aug. 31, 2021, 1:24 p.m. UTC | #5
On Thu, Aug 12, 2021 at 8:24 PM Ian Lance Taylor via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This patch updates libgo from the Go1.16.5 release to the Go 1.17rc2
> release.  As usual with these version updates, the patch itself is too
> large to attach to this e-mail message.  I've attached the changes to
> files that are specific to gccgo.  Bootstraped and ran Go testsuite on
> x86_64-pc-linux-gnu.  Committed to mainline.
>
> Ian

This breaks build with x32:

/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:35:30:
error: integer constant overflow
   35 |         seed ^= hashkey[0] ^ m1
      |                              ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:61:50:
error: integer constant overflow
   61 |                                 seed = mix(r8(p)^m2, r8(add(p, 8))^seed)
      |                                                  ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:62:60:
error: integer constant overflow
   62 |                                 seed1 = mix(r8(add(p, 16))^m3,
r8(add(p, 24))^seed1)
      |                                                            ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:63:60:
error: integer constant overflow
   63 |                                 seed2 = mix(r8(add(p, 32))^m4,
r8(add(p, 40))^seed2)
      |                                                            ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:69:42:
error: integer constant overflow
   69 |                         seed = mix(r8(p)^m2, r8(add(p, 8))^seed)
      |                                          ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:76:20:
error: integer constant overflow
   76 |         return mix(m5^s, mix(a^m2, b^seed))
      |                    ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:76:32:
error: integer constant overflow
   76 |         return mix(m5^s, mix(a^m2, b^seed))
      |                                ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:81:22:
error: integer constant overflow
   81 |         return mix(m5^4, mix(a^m2, a^seed^hashkey[0]^m1))
      |                      ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:81:32:
error: integer constant overflow
   81 |         return mix(m5^4, mix(a^m2, a^seed^hashkey[0]^m1))
      |                                ^
/export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/hash64.go:81:54:
error: integer constant overflow
   81 |         return mix(m5^4, mix(a^m2, a^seed^hashkey[0]^m1))

The problem is that hashkey is an array of uintptr, but hash64.go is enabled for
many targets with 32-bit uintptr:

commit c5b21c3f4c17b0649155035d2f9aa97b2da8a813
Author: Ian Lance Taylor <iant@golang.org>
Date:   Fri Jul 30 14:28:58 2021 -0700

    libgo: update to Go1.17rc2

    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341629

diff --git a/libgo/go/runtime/hash64.go b/libgo/go/runtime/hash64.go
index 704bbe6f62b..4b32d515c4b 100644
--- a/libgo/go/runtime/hash64.go
+++ b/libgo/go/runtime/hash64.go
@@ -3,113 +3,98 @@
 // license that can be found in the LICENSE file.

 // Hashing algorithm inspired by
-//   xxhash: https://code.google.com/p/xxhash/
-// cityhash: https://code.google.com/p/cityhash/
+// wyhash: https://github.com/wangyi-fudan/wyhash

+//go:build amd64 || arm64 || mips64 || mips64le || ppc64 || ppc64le
|| riscv64 || s390x || wasm || alpha || amd64p32 || arm64be || ia64 ||
mips64p32 || mips64p32le || sparc64
 // +build amd64 arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x
wasm alpha amd64p32 arm64be ia64 mips64p32 mips64p32le sparc64
Matthias Klose Sept. 3, 2021, 9 a.m. UTC | #6
On 8/31/21 3:24 PM, H.J. Lu via Gcc-patches wrote:
> On Thu, Aug 12, 2021 at 8:24 PM Ian Lance Taylor via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> This patch updates libgo from the Go1.16.5 release to the Go 1.17rc2
>> release.  As usual with these version updates, the patch itself is too
>> large to attach to this e-mail message.  I've attached the changes to
>> files that are specific to gccgo.  Bootstraped and ran Go testsuite on
>> x86_64-pc-linux-gnu.  Committed to mainline.
>>
>> Ian
> 
> This breaks build with x32:

This is PR/102102

Also seen on x86_64-linux-gnu, when configuring with
--with-multilib-list=m32,m64,mx32

Matthias
Ian Lance Taylor Sept. 7, 2021, 10:23 p.m. UTC | #7
On Fri, Sep 3, 2021 at 2:00 AM Matthias Klose <doko@ubuntu.com> wrote:
>
> On 8/31/21 3:24 PM, H.J. Lu via Gcc-patches wrote:
> > On Thu, Aug 12, 2021 at 8:24 PM Ian Lance Taylor via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >> This patch updates libgo from the Go1.16.5 release to the Go 1.17rc2
> >> release.  As usual with these version updates, the patch itself is too
> >> large to attach to this e-mail message.  I've attached the changes to
> >> files that are specific to gccgo.  Bootstraped and ran Go testsuite on
> >> x86_64-pc-linux-gnu.  Committed to mainline.
> >>
> >> Ian
> >
> > This breaks build with x32:
>
> This is PR/102102
>
> Also seen on x86_64-linux-gnu, when configuring with
> --with-multilib-list=m32,m64,mx32

Should be fixed now, I hope.

I don't know how to test this, as my desktop does not support x32 mode.

Ian
diff mbox series

Patch

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 539d886b08f..bcbe1d93018 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@ 
-5edbb624b2595d644eb6842c952a292c41f7d6fa
+33f65dce43bd01c1fa38cd90a78c9aea6ca6dd59
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/MERGE b/libgo/MERGE
index ac842716022..4286d5c5433 100644
--- a/libgo/MERGE
+++ b/libgo/MERGE
@@ -1,4 +1,4 @@ 
-7677616a263e8ded606cc8297cb67ddc667a876e
+72ab3ff68b1ec894fe5599ec82b8849f3baa9d94
 
 The first line of this file holds the git revision number of the
 last merge done from the master library sources.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index dec98756673..92fedcf6eb8 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -366,6 +366,7 @@  toolexeclibgoregexp_DATA = \
 toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
 
 toolexeclibgoruntime_DATA = \
+	runtime/cgo.gox \
 	runtime/debug.gox \
 	runtime/metrics.gox \
 	runtime/pprof.gox \
@@ -428,7 +429,9 @@  noinst_DATA = \
 	internal/testenv.gox \
 	internal/trace.gox \
 	net/internal/socktest.gox \
-	os/signal/internal/pty.gox
+	os/signal/internal/pty.gox \
+	reflect/internal/example1.gox \
+	reflect/internal/example2.gox
 
 if LIBGO_IS_RTEMS
 rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
@@ -480,14 +483,10 @@  version.go: s-version; @true
 s-version: Makefile
 	rm -f version.go.tmp
 	echo "package sys" > version.go.tmp
-	echo 'func init() { DefaultGoroot = "$(prefix)" }' >> version.go.tmp
-	echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp
-	echo 'const Goexperiment = ``' >> version.go.tmp
 	echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp
 	echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp
 	echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
-	echo >> version.go.tmp
-	echo "type ArchFamilyType int" >> version.go.tmp
+	echo 'const StackGuardMultiplierDefault = 1' >> version.go.tmp
 	echo >> version.go.tmp
 	echo "const (" >> version.go.tmp
 	echo "	UNKNOWN ArchFamilyType = iota" >> version.go.tmp
@@ -507,13 +506,13 @@  s-version: Makefile
 	done
 	echo >> version.go.tmp
 	echo "const (" >> version.go.tmp
-	echo "  ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" >> version.go.tmp
-	echo "  BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) bigendian`" >> version.go.tmp
-	echo "  CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> version.go.tmp
-	echo "  DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) defaultphyspagesize`" >> version.go.tmp
-	echo "  Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) int64align`" >> version.go.tmp
-	echo "  MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) minframesize`" >> version.go.tmp
-	echo "  PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) pcquantum`" >> version.go.tmp
+	echo "  _ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" >> version.go.tmp
+	echo "  _BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) bigendian`" >> version.go.tmp
+	echo "  _DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) defaultphyspagesize`" >> version.go.tmp
+	echo "  _Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) int64align`" >> version.go.tmp
+	echo "  _MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) minframesize`" >> version.go.tmp
+	echo "  _PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) pcquantum`" >> version.go.tmp
+	echo "  _StackAlign = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) stackalign`" >> version.go.tmp
 	echo ")" >> version.go.tmp
 	echo >> version.go.tmp
 	for a in $(ALLGOOS); do \
@@ -526,7 +525,6 @@  s-version: Makefile
 	  fi; \
 	done
 	echo >> version.go.tmp
-	echo "type Uintreg uintptr" >> version.go.tmp
 	$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
 	$(STAMP) $@
 
@@ -547,24 +545,31 @@  s-gcpu: Makefile
 	$(SHELL) $(srcdir)/mvifdiff.sh gcpugen.go.tmp gcpugen.go
 	$(STAMP) $@
 
+buildcfg.go: s-buildcfg; @true
+s-buildcfg: Makefile
+	rm -f buildcfg.go.tmp
+	echo "package buildcfg" > buildcfg.go.tmp
+	echo "import \"runtime\"" >> buildcfg.go.tmp
+	echo 'func defaultGOROOTValue() string { return `$(prefix)` }' >> buildcfg.go.tmp
+	echo 'const defaultGO386 = `sse2`' >> buildcfg.go.tmp
+	echo 'const defaultGOARM = `5`' >> buildcfg.go.tmp
+	echo 'const defaultGOMIPS = `hardfloat`' >> buildcfg.go.tmp
+	echo 'const defaultGOMIPS64 = `hardfloat`' >> buildcfg.go.tmp
+	echo 'const defaultGOPPC64 = `power8`' >> buildcfg.go.tmp
+	echo 'const defaultGOEXPERIMENT = `fieldtrack`' >> buildcfg.go.tmp
+	echo 'const defaultGO_EXTLINK_ENABLED = ``' >> buildcfg.go.tmp
+	echo 'const defaultGO_LDSO = ``' >> buildcfg.go.tmp
+	echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> buildcfg.go.tmp
+	echo 'const defaultGOOS = runtime.GOOS' >> buildcfg.go.tmp
+	echo 'const defaultGOARCH = runtime.GOARCH' >> buildcfg.go.tmp
+	$(SHELL) $(srcdir)/mvifdiff.sh buildcfg.go.tmp buildcfg.go
+	$(STAMP) $@
+
 objabi.go: s-objabi; @true
 s-objabi: Makefile
 	rm -f objabi.go.tmp
 	echo "package objabi" > objabi.go.tmp
-	echo "import \"runtime\"" >> objabi.go.tmp
-	echo 'func defaultGOROOTValue() string { return `$(prefix)` }' >> objabi.go.tmp
-	echo 'const defaultGO386 = `sse2`' >> objabi.go.tmp
-	echo 'const defaultGOARM = `5`' >> objabi.go.tmp
-	echo 'const defaultGOMIPS = `hardfloat`' >> objabi.go.tmp
-	echo 'const defaultGOMIPS64 = `hardfloat`' >> objabi.go.tmp
-	echo 'const defaultGOPPC64 = `power8`' >> objabi.go.tmp
-	echo 'const defaultGOOS = runtime.GOOS' >> objabi.go.tmp
-	echo 'const defaultGOARCH = runtime.GOARCH' >> objabi.go.tmp
-	echo 'const defaultGO_EXTLINK_ENABLED = ``' >> objabi.go.tmp
-	echo 'const defaultGO_LDSO = ``' >> objabi.go.tmp
-	echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> objabi.go.tmp
 	echo 'const stackGuardMultiplierDefault = 1' >> objabi.go.tmp
-	echo 'const goexperiment = ``' >> objabi.go.tmp
 	$(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go
 	$(STAMP) $@
 
@@ -671,7 +676,7 @@  s-zstdpkglist: Makefile libgo-packages.txt
 	echo 'package goroot' > zstdpkglist.go.tmp
 	echo "" >> zstdpkglist.go.tmp
 	echo 'var stdpkg = map[string]bool{' >> zstdpkglist.go.tmp
-	echo $(libgo_go_objs) 'unsafe.lo' 'runtime/cgo.lo' | sed 's|[a-z0-9_./]*_c\.lo||g' | sed 's|golang\.org/[a-z0-9_./]*\.lo||g' | sed 's|\([a-z0-9_./]*\)\.lo|"\1": true,|g' >> zstdpkglist.go.tmp
+	echo $(libgo_go_objs) 'unsafe.lo' | sed 's|[a-z0-9_./]*_c\.lo||g' | sed 's|golang\.org/[a-z0-9_./]*\.lo||g' | sed 's|\([a-z0-9_./]*\)\.lo|"\1": true,|g' >> zstdpkglist.go.tmp
 	echo '}' >> zstdpkglist.go.tmp
 	$(SHELL) $(srcdir)/mvifdiff.sh zstdpkglist.go.tmp zstdpkglist.go
 	$(STAMP) $@
@@ -1054,6 +1059,9 @@  internal/cpu.lo.dep: $(extra_go_files_internal_cpu)
 extra_go_files_golang_org_x_sys_cpu = gcpugen.go
 golang.org/x/sys/cpu.lo.dep: $(extra_go_files_golang_org_x_sys_cpu)
 
+extra_go_files_internal_buildcfg = buildcfg.go
+cmd/internal/buildcfg.lo.dep: $(extra_go_files_internal_buildcfg)
+
 extra_go_files_internal_goroot = zstdpkglist.go
 internal/goroot.lo.dep: $(extra_go_files_internal_goroot)
 
diff --git a/libgo/VERSION b/libgo/VERSION
index e336ec201bf..904eb73bd5c 100644
--- a/libgo/VERSION
+++ b/libgo/VERSION
@@ -1 +1 @@ 
-go1.16.5
+go1.17rc2
diff --git a/libgo/check-packages.txt b/libgo/check-packages.txt
index 1e549cae4b0..dd8990f10e2 100644
--- a/libgo/check-packages.txt
+++ b/libgo/check-packages.txt
@@ -43,7 +43,10 @@  crypto/des
 crypto/dsa
 crypto/ecdsa
 crypto/ed25519
+crypto/ed25519/internal/edwards25519
+crypto/ed25519/internal/edwards25519/field
 crypto/elliptic
+crypto/elliptic/internal/fiat
 crypto/hmac
 crypto/internal/subtle
 crypto/md5
@@ -110,6 +113,7 @@  index/suffixarray
 internal/cpu
 internal/execabs
 internal/fmtsort
+internal/itoa
 internal/poll
 internal/profile
 internal/reflectlite
@@ -139,6 +143,7 @@  net/http/httptest
 net/http/httptrace
 net/http/httputil
 net/http/internal
+net/http/internal/ascii
 net/http/pprof
 net/internal/socktest
 net/mail
@@ -157,6 +162,7 @@  reflect
 regexp
 regexp/syntax
 runtime
+runtime/cgo
 runtime/debug
 runtime/internal/atomic
 runtime/internal/math
diff --git a/libgo/configure.ac b/libgo/configure.ac
index ebab9d9de3e..1f4f32dae2b 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=19:0:0
+libtool_VERSION=20:0:0
 AC_SUBST(libtool_VERSION)
 
 AM_ENABLE_MULTILIB(, ..)
diff --git a/libgo/go/runtime/os_gccgo.go b/libgo/go/runtime/os_gccgo.go
index 65d7aef165a..da12c35d26c 100644
--- a/libgo/go/runtime/os_gccgo.go
+++ b/libgo/go/runtime/os_gccgo.go
@@ -97,3 +97,11 @@  func setNonblock(fd int32) {
 		fcntlUintptr(uintptr(fd), _F_SETFL, flags|_O_NONBLOCK)
 	}
 }
+
+// For gccgo this is in the C code.
+func osyield()
+
+//go:nosplit
+func osyield_no_g() {
+	osyield()
+}
diff --git a/libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go b/libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go
index 83357fdd5d9..2d07c2db8a4 100644
--- a/libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go
+++ b/libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go
@@ -2,6 +2,7 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build gccgo
 // +build gccgo
 
 package main
diff --git a/libgo/gotool-packages.txt b/libgo/gotool-packages.txt
index f28ad6977aa..15c928ff7fb 100644
--- a/libgo/gotool-packages.txt
+++ b/libgo/gotool-packages.txt
@@ -27,7 +27,6 @@  cmd/go/internal/modinfo
 cmd/go/internal/modload
 cmd/go/internal/mvs
 cmd/go/internal/par
-cmd/go/internal/renameio
 cmd/go/internal/robustio
 cmd/go/internal/run
 cmd/go/internal/search
@@ -86,6 +85,7 @@  golang.org/x/tools/go/analysis/passes/nilfunc
 golang.org/x/tools/go/analysis/passes/pkgfact
 golang.org/x/tools/go/analysis/passes/printf
 golang.org/x/tools/go/analysis/passes/shift
+golang.org/x/tools/go/analysis/passes/sigchanyzer
 golang.org/x/tools/go/analysis/passes/stdmethods
 golang.org/x/tools/go/analysis/passes/stringintconv
 golang.org/x/tools/go/analysis/passes/structtag
diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt
index 707def56de7..4fc8c843f02 100644
--- a/libgo/libgo-packages.txt
+++ b/libgo/libgo-packages.txt
@@ -19,7 +19,9 @@  crypto/dsa
 crypto/ecdsa
 crypto/ed25519
 crypto/ed25519/internal/edwards25519
+crypto/ed25519/internal/edwards25519/field
 crypto/elliptic
+crypto/elliptic/internal/fiat
 crypto/hmac
 crypto/internal/randutil
 crypto/internal/subtle
@@ -69,6 +71,7 @@  go/importer
 go/internal/gccgoimporter
 go/internal/gcimporter
 go/internal/srcimporter
+go/internal/typeparams
 go/parser
 go/printer
 go/scanner
@@ -110,13 +113,16 @@  image/internal/imageutil
 image/jpeg
 image/png
 index/suffixarray
+internal/buildcfg
 internal/bytealg
 internal/cfg
 internal/cpu
 internal/execabs
 internal/fmtsort
+internal/goexperiment
 internal/goroot
 internal/goversion
+internal/itoa
 internal/lazyregexp
 internal/lazytemplate
 internal/nettrace
@@ -157,6 +163,8 @@  net/http/httptest
 net/http/httptrace
 net/http/httputil
 net/http/internal
+net/http/internal/ascii
+net/http/internal/testcert
 net/http/pprof
 net/internal/socktest
 net/mail
@@ -173,9 +181,12 @@  os/user
 path
 path/filepath
 reflect
+reflect/internal/example1
+reflect/internal/example2
 regexp
 regexp/syntax
 runtime
+runtime/cgo
 runtime/debug
 runtime/internal/atomic
 runtime/internal/math
diff --git a/libgo/match.sh b/libgo/match.sh
index cc15a12c674..bf4f141e04a 100755
--- a/libgo/match.sh
+++ b/libgo/match.sh
@@ -119,6 +119,11 @@  for f in $gofiles; do
 	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
 	    tag1=nonmatchingtag
 	    ;;
+	*)
+	    # File name like x_amd64_random.go, where tag1=random.
+	    # Don't match based on tag2.
+	    tag2=
+	    ;;
     esac
 
     case "$tag2" in
@@ -151,18 +156,18 @@  for f in $gofiles; do
 		    fi
 		    match=false
 		    ;;
-		$goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | go1.[0-9] | go1.[0-9][0-9])
+		$goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | "goexperiment.fieldtrack" | go1.[0-9] | go1.[0-9][0-9])
 		    match=true
 		    ;;
-		"!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6])
+		"!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
 		    ;;
 		*,*)
 		    cmatch=true
 		    for ctag in `echo $tag | sed -e 's/,/ /g'`; do
 			case $ctag in
-			    $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | go1.[0-9] | go1.[0-9][0-9])
+			    $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | "goexperiment.fieldtrack" | go1.[0-9] | go1.[0-9][0-9])
 				;;
-			    "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6])
+			    "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
 				cmatch=false
 				;;
 			    "!"*)
diff --git a/libgo/runtime/go-now.c b/libgo/runtime/go-now.c
index 1c02e5220e4..e1dcd180860 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.walltime1().
+// Return current time.  This is the implementation of runtime.walltime().
 
 struct walltime_ret
 {
@@ -16,7 +16,7 @@  struct walltime_ret
   int32_t nsec;
 };
 
-struct walltime_ret now(void) __asm__ (GOSYM_PREFIX "runtime.walltime1")
+struct walltime_ret now(void) __asm__ (GOSYM_PREFIX "runtime.walltime")
   __attribute__ ((no_split_stack));
 
 struct walltime_ret
diff --git a/libgo/runtime/runtime_c.c b/libgo/runtime/runtime_c.c
index bc920a5d406..f92bdd43bc9 100644
--- a/libgo/runtime/runtime_c.c
+++ b/libgo/runtime/runtime_c.c
@@ -199,10 +199,13 @@  getEnd()
 uintptr getText(void)
   __asm__ (GOSYM_PREFIX "runtime.getText");
 
+extern void main_main(void*)
+  __asm__(GOSYM_PREFIX "main.main");
+
 uintptr
 getText(void)
 {
-  return (uintptr)(const void *)(getText);
+  return (uintptr)(const void *)(main_main);
 }
 
 // Return the end of the text segment, assumed to come after the
@@ -224,6 +227,24 @@  getEtext(void)
   return (uintptr)(p);
 }
 
+// Return the start of the BSS section.
+
+uintptr getBSS(void)
+  __asm__ (GOSYM_PREFIX "runtime.getBSS");
+
+uintptr
+getBSS(void)
+{
+  const void *p;
+
+  p = __edata;
+  if (p == NULL)
+    p = _edata;
+  if (p == NULL)
+    p = __bss_start;
+  return (uintptr)(p);
+}
+
 // CPU-specific initialization.
 // Fetch CPUID info on x86.
 
diff --git a/libgo/runtime/stack.c b/libgo/runtime/stack.c
index c78f0c4595b..0c0c30e46ac 100644
--- a/libgo/runtime/stack.c
+++ b/libgo/runtime/stack.c
@@ -23,7 +23,7 @@  bool runtime_usestackmaps;
 #pragma GCC optimize ("-fno-optimize-sibling-calls")
 
 extern void scanstackblock(uintptr addr, uintptr size, void *gcw)
-  __asm__("runtime.scanstackblock");
+  __asm__(GOSYM_PREFIX "runtime.scanstackblock");
 
 static bool doscanstack1(G*, void*)
   __attribute__ ((noinline));
@@ -125,3 +125,66 @@  static bool doscanstack1(G *gp, void *gcw) {
 #endif
 	return true;
 }
+
+extern bool onCurrentStack(uintptr p)
+  __asm__(GOSYM_PREFIX "runtime.onCurrentStack");
+
+bool onCurrentStack(uintptr p)
+{
+#ifdef USING_SPLIT_STACK
+
+	void* sp;
+	size_t spsize;
+	void* next_segment;
+	void* next_sp;
+	void* initial_sp;
+
+	sp = __splitstack_find(nil, nil, &spsize, &next_segment, &next_sp,
+			       &initial_sp);
+	while (sp != nil) {
+		if (p >= (uintptr)(sp) && p < (uintptr)(sp) + spsize) {
+			return true;
+		}
+		sp = __splitstack_find(next_segment, next_sp, &spsize,
+				       &next_segment, &next_sp, &initial_sp);
+	}
+	return false;
+
+#else
+
+	G* gp;
+	byte* bottom;
+	byte* top;
+	byte* temp;
+	byte* nextsp2;
+	byte* initialsp2;
+
+	gp = runtime_g();
+	bottom = (byte*)(&p);
+	top = (byte*)(void*)(gp->gcinitialsp) + gp->gcstacksize;
+	if ((uintptr)(top) < (uintptr)(bottom)) {
+		temp = top;
+		top = bottom;
+		bottom = temp;
+	}
+	if (p >= (uintptr)(bottom) && p < (uintptr)(top)) {
+		return true;
+	}
+
+	nextsp2 = secondary_stack_pointer();
+	if (nextsp2 != nil) {
+		initialsp2 = (byte*)(void*)(gp->gcinitialsp2);
+		if (uintptr(initialsp2) < uintptr(nextsp2)) {
+			temp = initialsp2;
+			initialsp2 = nextsp2;
+			nextsp2 = temp;
+		}
+		if (p >= (uintptr)(nextsp2) && p < (uintptr)(initialsp2)) {
+			return true;
+		}
+	}
+
+	return false;
+
+#endif
+}
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index 9eda2ccc70d..e0dd16610db 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -311,6 +311,11 @@  x)
 	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm)
 		tag1=nonmatchingtag
 		;;
+	    *)
+		# File name like x_amd64_random.go, where tag1=random.
+		# Don't match based on tag2.
+		tag2=
+		;;
 	    esac
 
 	    case "$tag2" in
@@ -342,18 +347,18 @@  x)
 			fi
 			match=false
 			;;
-		    $goos | $goarch | cgo | gccgo | go1.[0-9] | go1.[0-9][0-9])
+		    $goos | $goarch | cgo | gccgo | goexperiment.fieldtrack | go1.[0-9] | go1.[0-9][0-9])
 			match=true
 			;;
-		    "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6])
+		    "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
 			;;
 		    *,*)
 			cmatch=true
 			for ctag in `echo $tag | sed -e 's/,/ /g'`; do
 			    case $ctag in
-			    $goos | $goarch | cgo | gccgo | go1.[0-9] | go1.[0-9][0-9])
+			    $goos | $goarch | cgo | gccgo | goexperiment.fieldtrack | go1.[0-9] | go1.[0-9][0-9])
 				;;
-			    "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6])
+			    "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
 				cmatch=false
 				;;
 			    "!"*)