diff mbox series

libgo patch committed: Update to 1.11 release

Message ID CAOyqgcUgXMYAkVQco8dcmEChazODizFkZwUiH01jPEpnWNvS3w@mail.gmail.com
State New
Headers show
Series libgo patch committed: Update to 1.11 release | expand

Commit Message

Ian Lance Taylor Sept. 24, 2018, 9:46 p.m. UTC
I've committed a patch to update libgo to the 1.11 release.  As usual
for these updates, the patch is too large to attach to this e-mail
message.  I've attached some of the more relevant directories.  This
update required some minor patches to the gotools directory and the Go
testsuite, also included here.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

2018-09-24  Ian Lance Taylor  <iant@golang.org>

* Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
make sure it is writable.
(check-go-tools): Likewise.
(check-vet): Copy internal/objabi to check-vet-dir.
* Makefile.in: Rebuild.

Comments

Andreas Schwab Sept. 25, 2018, 6:51 a.m. UTC | #1
This breaks aarch64/-mabi=ilp32.

../../../../libgo/go/internal/poll/splice_linux.go:165:45: error: reference to undefined identifier 'syscall.SYS_FCNTL'
165 |   if _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 {
    |                                             ^

Andreas.
Andreas Schwab Sept. 25, 2018, 7:43 a.m. UTC | #2
It also breaks ia64.

../../../libgo/go/internal/bytealg/indexbyte_native.go:10:1: error: redefinition of 'IndexByte'
10 | func IndexByte(b []byte, c byte) int
   | ^
../../../libgo/go/internal/bytealg/indexbyte_generic.go:12:1: note: previous definition of 'IndexByte' was here
12 | func IndexByte(b []byte, c byte) int {
   | ^
../../../libgo/go/internal/bytealg/indexbyte_native.go:13:1: error: redefinition of 'IndexByteString'
13 | func IndexByteString(s string, c byte) int
   | ^
../../../libgo/go/internal/bytealg/indexbyte_generic.go:21:1: note: previous definition of 'IndexByteString' was here
21 | func IndexByteString(s string, c byte) int {
   | ^

Andreas.
Andreas Schwab Sept. 25, 2018, 8:03 a.m. UTC | #3
../../../libgo/go/internal/cpu/cpu.go:21:16: error: reference to undefined name ‘CacheLineSize’
21 |  _            [CacheLineSize]byte
   |                ^
../../../libgo/go/internal/cpu/cpu.go:38:16: error: reference to undefined name ‘CacheLineSize’
38 |  _            [CacheLineSize]byte
   |                ^
../../../libgo/go/internal/cpu/cpu.go:51:14: error: reference to undefined name ‘CacheLineSize’
51 |  _          [CacheLineSize]byte
   |              ^
../../../libgo/go/internal/cpu/cpu.go:63:14: error: reference to undefined name ‘CacheLineSize’
63 |  _          [CacheLineSize]byte
   |              ^
../../../libgo/go/internal/cpu/cpu.go:71:15: error: reference to undefined name ‘CacheLineSize’
71 |  _           [CacheLineSize]byte
   |               ^
../../../libgo/go/internal/cpu/cpu.go:96:15: error: reference to undefined name ‘CacheLineSize’
96 |  _           [CacheLineSize]byte
   |               ^
../../../libgo/go/internal/cpu/cpu.go:102:19: error: reference to undefined name ‘CacheLineSize’
102 |  _               [CacheLineSize]byte
    |                   ^
../../../libgo/go/internal/cpu/cpu.go:119:19: error: reference to undefined name ‘CacheLineSize’
119 |  _               [CacheLineSize]byte
    |                   ^

Andreas.
Rainer Orth Sept. 25, 2018, 1:05 p.m. UTC | #4
Hi Ian,

> I've committed a patch to update libgo to the 1.11 release.  As usual
> for these updates, the patch is too large to attach to this e-mail
> message.  I've attached some of the more relevant directories.  This
> update required some minor patches to the gotools directory and the Go
> testsuite, also included here.  Bootstrapped and ran Go testsuite on
> x86_64-pc-linux-gnu.  Committed to mainline.

this patch broke Solaris badly, too.

On Solaris 11/SPARC:

*

/vol/gcc/src/hg/trunk/local/libgo/go/internal/cpu/cpu.go:21:16: error: reference to undefined name 'CacheLineSize'
21 |  _            [CacheLineSize]byte
   |                ^

  and many more.  I've introduced cpu_sparc.go and cpu_sparc64.go to
  define the constant.  However, the value is just an initial guess; I've
  not yet checked if it's correct for all SPARC implementations.

*

/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/indexbyte_native.go:10:1: error: redefinition of 'IndexByte'
10 | func IndexByte(b []byte, c byte) int
   | ^
/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/indexbyte_generic.go:12:1: note: previous definition of 'IndexByte' was here
12 | func IndexByte(b []byte, c byte) int {
   | ^
/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/indexbyte_native.go:13:1: error: redefinition of 'IndexByteString'
13 | func IndexByteString(s string, c byte) int
   | ^
/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/indexbyte_generic.go:21:1: note: previous definition of 'IndexByteString' was here
21 | func IndexByteString(s string, c byte) int {
   | ^

  Fixed by adding sparc build tags to indexbyte_{generic, native}.go.
  It seems +ignore_for_gccgo in the former is itself ignored.

On both Solaris 11/SPARC and x86:

* 

/vol/gcc/src/hg/trunk/local/libgo/go/runtime/runtime1.go:75:2: error: reference to undefined name 'sysargs'
75 |  sysargs(c, v)
   |  ^

  sysargs is defined in go/runtime/auxv_none.go, go/runtime/os_linux.go
  in the gcc tree.

  The former excluded on solaris.  I've removed the build tag in
  auxv_none.go as hack, but auxv exists on Solaris, too!  I happened to
  find an implementation in upstream src/runtime/os3_solaris.go.  But
  what the heck is os{,2,3}_solaris.go!?

*

/vol/gcc/src/hg/trunk/local/libgo/go/runtime/traceback_gccgo.go:151:14: error: reference to undefined name 'nanotime'
151 |   waitfor = (nanotime() - gp.waitsince) / 60e9
    |              ^

  and many many more instances.  Again, I found an implementation in
  upstream src/runtime/os3_solaris.go, but that isn't usable since it
  uses syscall directly.

So I'm currently stuck on the missing nanotime.

	Rainer
Rainer Orth Sept. 25, 2018, 1:26 p.m. UTC | #5
Hi Ian,

> /vol/gcc/src/hg/trunk/local/libgo/go/runtime/traceback_gccgo.go:151:14: error: reference to undefined name 'nanotime'
> 151 |   waitfor = (nanotime() - gp.waitsince) / 60e9
>     |              ^
>
>   and many many more instances.  Again, I found an implementation in
>   upstream src/runtime/os3_solaris.go, but that isn't usable since it
>   uses syscall directly.
>
> So I'm currently stuck on the missing nanotime.

I think I found it: if I enable building go/runtime/stubs3.go by
removing the !solaris build tag, the runtime_nanotime implementation in
runtime/go-nanotime.c is used.  At least the builds are going along
fine, it seems.  No test results yet.

	Rainer
Ian Lance Taylor Sept. 25, 2018, 2:32 p.m. UTC | #6
On Tue, Sep 25, 2018 at 1:03 AM, Andreas Schwab <schwab@suse.de> wrote:
> ../../../libgo/go/internal/cpu/cpu.go:21:16: error: reference to undefined name ‘CacheLineSize’
> 21 |  _            [CacheLineSize]byte
>    |                ^
> ../../../libgo/go/internal/cpu/cpu.go:38:16: error: reference to undefined name ‘CacheLineSize’
> 38 |  _            [CacheLineSize]byte
>    |                ^
> ../../../libgo/go/internal/cpu/cpu.go:51:14: error: reference to undefined name ‘CacheLineSize’
> 51 |  _          [CacheLineSize]byte
>    |              ^
> ../../../libgo/go/internal/cpu/cpu.go:63:14: error: reference to undefined name ‘CacheLineSize’
> 63 |  _          [CacheLineSize]byte
>    |              ^
> ../../../libgo/go/internal/cpu/cpu.go:71:15: error: reference to undefined name ‘CacheLineSize’
> 71 |  _           [CacheLineSize]byte
>    |               ^
> ../../../libgo/go/internal/cpu/cpu.go:96:15: error: reference to undefined name ‘CacheLineSize’
> 96 |  _           [CacheLineSize]byte
>    |               ^
> ../../../libgo/go/internal/cpu/cpu.go:102:19: error: reference to undefined name ‘CacheLineSize’
> 102 |  _               [CacheLineSize]byte
>     |                   ^
> ../../../libgo/go/internal/cpu/cpu.go:119:19: error: reference to undefined name ‘CacheLineSize’
> 119 |  _               [CacheLineSize]byte
>     |                   ^

Thanks for the various reports and sorry for the breakage.

I believe this patch will fix the three problems reported by Andreas.

In internal/bytealg correct a +build tag to never build
indexbyte_generic.go for gccgo, where we always use
indexbyte_native.go.

For internal/cpu let the Makefile define CacheLineSize using
goarch.sh, rather than trying to enumerate all the possibilities in
cpu_ARCH.go files.

In internal/poll call the C fcntl function rather than using
SYS_FCNTL.  Change mksysinfo.sh to ensure that F_GETPIPE_SZ is always
defined, and check that in internal/poll.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 264570)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-1dbc5b805a1665079008d1ce341991c3554c1eeb
+652fbfb7acfd81ceffe28e20984464aa7bb6024d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/Makefile.am
===================================================================
--- libgo/Makefile.am	(revision 264546)
+++ libgo/Makefile.am	(working copy)
@@ -532,6 +532,14 @@ s-version: Makefile
 	$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
 	$(STAMP) $@
 
+cpugen.go: s-cpu; @true
+s-cpu: Makefile
+	rm -f cpugen.go.tmp
+	echo "package cpu" > cpugen.go.tmp
+	echo "const CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp
+	$(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go
+	$(STAMP) $@
+
 objabi.go: s-objabi; @true
 s-objabi: Makefile
 	rm -f objabi.go.tmp
@@ -963,6 +971,9 @@ runtime_pprof_check_GOCFLAGS = -static-l
 extra_go_files_runtime_internal_sys = version.go
 runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys)
 
+extra_go_files_internal_cpu = cpugen.go
+internal/cpu.lo.dep: $(extra_go_files_internal_cpu)
+
 extra_go_files_internal_goroot = zstdpkglist.go
 internal/goroot.lo.dep: $(extra_go_files_internal_goroot)
 
Index: libgo/Makefile.in
===================================================================
--- libgo/Makefile.in	(revision 264546)
+++ libgo/Makefile.in	(working copy)
@@ -1002,6 +1002,7 @@ runtime_internal_sys_lo_check_GOCFLAGS =
 # Also use -fno-inline to get better results from the memory profiler.
 runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline
 extra_go_files_runtime_internal_sys = version.go
+extra_go_files_internal_cpu = cpugen.go
 extra_go_files_internal_goroot = zstdpkglist.go
 extra_go_files_go_types = gccgosizes.go
 extra_go_files_cmd_internal_objabi = objabi.go
@@ -2759,6 +2760,14 @@ s-version: Makefile
 	$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
 	$(STAMP) $@
 
+cpugen.go: s-cpu; @true
+s-cpu: Makefile
+	rm -f cpugen.go.tmp
+	echo "package cpu" > cpugen.go.tmp
+	echo "const CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp
+	$(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go
+	$(STAMP) $@
+
 objabi.go: s-objabi; @true
 s-objabi: Makefile
 	rm -f objabi.go.tmp
@@ -2957,6 +2966,7 @@ $(foreach package,$(GOTOOL_PACKAGES),$(e
 runtime.lo.dep: $(extra_go_files_runtime)
 syscall.lo.dep: $(extra_go_files_syscall)
 runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys)
+internal/cpu.lo.dep: $(extra_go_files_internal_cpu)
 internal/goroot.lo.dep: $(extra_go_files_internal_goroot)
 go/types.lo.dep: $(extra_go_files_go_types)
 cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi)
Index: libgo/go/internal/bytealg/indexbyte_generic.go
===================================================================
--- libgo/go/internal/bytealg/indexbyte_generic.go	(revision 264546)
+++ libgo/go/internal/bytealg/indexbyte_generic.go	(working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +ignore_for_gccgo
+// +build ignore_for_gccgo
 // +build !386,!amd64,!amd64p32,!s390x,!arm,!arm64,!ppc64,!ppc64le,!mips,!mipsle,!mips64,!mips64le,!wasm
 
 package bytealg
Index: libgo/go/internal/cpu/cpu_arm.go
===================================================================
--- libgo/go/internal/cpu/cpu_arm.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_arm.go	(nonexistent)
@@ -1,7 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const CacheLineSize = 32
Index: libgo/go/internal/cpu/cpu_arm64.go
===================================================================
--- libgo/go/internal/cpu/cpu_arm64.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_arm64.go	(working copy)
@@ -4,8 +4,6 @@
 
 package cpu
 
-const CacheLineSize = 64
-
 // arm64 doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
 // These are initialized by archauxv in runtime/os_linux_arm64.go.
 // These should not be changed after they are initialized.
Index: libgo/go/internal/cpu/cpu_mips.go
===================================================================
--- libgo/go/internal/cpu/cpu_mips.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_mips.go	(nonexistent)
@@ -1,7 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const CacheLineSize = 32
Index: libgo/go/internal/cpu/cpu_mips64.go
===================================================================
--- libgo/go/internal/cpu/cpu_mips64.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_mips64.go	(nonexistent)
@@ -1,7 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const CacheLineSize = 32
Index: libgo/go/internal/cpu/cpu_mips64le.go
===================================================================
--- libgo/go/internal/cpu/cpu_mips64le.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_mips64le.go	(nonexistent)
@@ -1,7 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const CacheLineSize = 32
Index: libgo/go/internal/cpu/cpu_mipsle.go
===================================================================
--- libgo/go/internal/cpu/cpu_mipsle.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_mipsle.go	(nonexistent)
@@ -1,7 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const CacheLineSize = 32
Index: libgo/go/internal/cpu/cpu_ppc64x.go
===================================================================
--- libgo/go/internal/cpu/cpu_ppc64x.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_ppc64x.go	(working copy)
@@ -6,8 +6,6 @@
 
 package cpu
 
-const CacheLineSize = 128
-
 // ppc64x doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
 // These are initialized by archauxv in runtime/os_linux_ppc64x.go.
 // These should not be changed after they are initialized.
Index: libgo/go/internal/cpu/cpu_s390x.go
===================================================================
--- libgo/go/internal/cpu/cpu_s390x.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_s390x.go	(working copy)
@@ -4,8 +4,6 @@
 
 package cpu
 
-const CacheLineSize = 256
-
 // bitIsSet reports whether the bit at index is set. The bit index
 // is in big endian order, so bit index 0 is the leftmost bit.
 func bitIsSet(bits []uint64, index uint) bool {
Index: libgo/go/internal/cpu/cpu_wasm.go
===================================================================
--- libgo/go/internal/cpu/cpu_wasm.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_wasm.go	(nonexistent)
@@ -1,7 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const CacheLineSize = 64
Index: libgo/go/internal/cpu/cpu_x86.go
===================================================================
--- libgo/go/internal/cpu/cpu_x86.go	(revision 264546)
+++ libgo/go/internal/cpu/cpu_x86.go	(working copy)
@@ -6,8 +6,6 @@
 
 package cpu
 
-const CacheLineSize = 64
-
 // cpuid is implemented in cpu_x86.s.
 func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
 
Index: libgo/go/internal/poll/splice_linux.go
===================================================================
--- libgo/go/internal/poll/splice_linux.go	(revision 264546)
+++ libgo/go/internal/poll/splice_linux.go	(working copy)
@@ -162,10 +162,15 @@ func newTempPipe() (prfd, pwfd int, sc s
 		defer atomic.StorePointer(&disableSplice, unsafe.Pointer(p))
 
 		// F_GETPIPE_SZ was added in 2.6.35, which does not have the -EAGAIN bug.
-		if _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 {
+		if syscall.F_GETPIPE_SZ == 0 {
 			*p = true
 			destroyTempPipe(fds[0], fds[1])
-			return -1, -1, "fcntl", errno
+			return -1, -1, "fcntl", syscall.EINVAL
+		}
+		if _, errno := fcntl(uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 {
+			*p = true
+			destroyTempPipe(fds[0], fds[1])
+			return -1, -1, "fcntl", syscall.Errno(errno)
 		}
 	}
 
Index: libgo/mksysinfo.sh
===================================================================
--- libgo/mksysinfo.sh	(revision 264546)
+++ libgo/mksysinfo.sh	(working copy)
@@ -73,6 +73,11 @@ if ! grep '^const F_DUPFD_CLOEXEC' ${OUT
   echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT}
 fi
 
+# The internal/poll package requires F_GETPIPE_SZ to be defined.
+if ! grep '^const F_GETPIPE_SZ' ${OUT} >/dev/null 2>&1; then
+  echo "const F_GETPIPE_SZ = 0" >> ${OUT}
+fi
+
 # AIX 7.1 is a 64 bits value for _FCLOEXEC (referenced by O_CLOEXEC)
 # which leads to a constant overflow when using O_CLOEXEC in some
 # go code. Issue wan not present in 6.1 (no O_CLOEXEC) and is no
Ian Lance Taylor Sept. 26, 2018, 3:30 a.m. UTC | #7
On Tue, Sep 25, 2018 at 6:26 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
>> /vol/gcc/src/hg/trunk/local/libgo/go/runtime/traceback_gccgo.go:151:14: error: reference to undefined name 'nanotime'
>> 151 |   waitfor = (nanotime() - gp.waitsince) / 60e9
>>     |              ^
>>
>>   and many many more instances.  Again, I found an implementation in
>>   upstream src/runtime/os3_solaris.go, but that isn't usable since it
>>   uses syscall directly.
>>
>> So I'm currently stuck on the missing nanotime.
>
> I think I found it: if I enable building go/runtime/stubs3.go by
> removing the !solaris build tag, the runtime_nanotime implementation in
> runtime/go-nanotime.c is used.  At least the builds are going along
> fine, it seems.  No test results yet.

Thanks for the report.  I've committed this patch to fix the build on
Solaris.  There are some test failures, though.  I haven't looked into
them.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 264572)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-652fbfb7acfd81ceffe28e20984464aa7bb6024d
+e7b98cf0a380eb45791cd5c52897224a686dcdec
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/os/executable_solaris.go
===================================================================
--- libgo/go/os/executable_solaris.go	(revision 264546)
+++ libgo/go/os/executable_solaris.go	(working copy)
@@ -4,14 +4,18 @@
 
 package os
 
-import "syscall"
+import (
+	"syscall"
+	_ "unsafe" // for go:linkname
+)
 
-var executablePath string // set by sysauxv in ../runtime/os3_solaris.go
+// solarisExecutablePath is defined in the runtime package.
+func solarisExecutablePath() string
 
 var initCwd, initCwdErr = Getwd()
 
 func executable() (string, error) {
-	path := executablePath
+	path := solarisExecutablePath()
 	if len(path) == 0 {
 		path, err := syscall.Getexecname()
 		if err != nil {
Index: libgo/go/runtime/os3_solaris.go
===================================================================
--- libgo/go/runtime/os3_solaris.go	(nonexistent)
+++ libgo/go/runtime/os3_solaris.go	(working copy)
@@ -0,0 +1,54 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package runtime
+
+import (
+	"runtime/internal/sys"
+	"unsafe"
+)
+
+var executablePath string
+
+func sysargs(argc int32, argv **byte) {
+	n := argc + 1
+
+	// skip over argv, envp to get to auxv
+	for argv_index(argv, n) != nil {
+		n++
+	}
+
+	// skip NULL separator
+	n++
+
+	// now argv+n is auxv
+	auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize))
+	sysauxv(auxv[:])
+}
+
+const (
+	_AT_NULL         = 0    // Terminates the vector
+	_AT_PAGESZ       = 6    // Page size in bytes
+	_AT_SUN_EXECNAME = 2014 // exec() path name
+)
+
+func sysauxv(auxv []uintptr) {
+	for i := 0; auxv[i] != _AT_NULL; i += 2 {
+		tag, val := auxv[i], auxv[i+1]
+		switch tag {
+		case _AT_PAGESZ:
+			physPageSize = val
+		case _AT_SUN_EXECNAME:
+			executablePath = gostringnocopy((*byte)(unsafe.Pointer(val)))
+		}
+	}
+}
+
+//go:linkname solarisExecutablePath os.solarisExecutablePath
+
+// solarisExecutablePath is called from the os package to fetch the
+// saved executable path.
+func solarisExecutablePath() string {
+	return executablePath
+}
Index: libgo/go/runtime/stubs3.go
===================================================================
--- libgo/go/runtime/stubs3.go	(revision 264546)
+++ libgo/go/runtime/stubs3.go	(working copy)
@@ -3,7 +3,6 @@
 // license that can be found in the LICENSE file.
 
 // +build !plan9
-// +build !solaris
 // +build !windows
 // +build !nacl
 // +build !freebsd
Andreas Schwab Sept. 26, 2018, 7:40 a.m. UTC | #8
On Sep 24 2018, Ian Lance Taylor <iant@golang.org> wrote:

> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
> make sure it is writable.
> (check-go-tools): Likewise.

$ make check-gotools
make[1]: Entering directory `/usr/local/gcc/gcc-20180926/Build/gotools'
chmod -R u+w check-go-dir
chmod: cannot access `check-go-dir': No such file or directory
make[1]: *** [check-go-tool] Error 1
make[1]: Leaving directory `/usr/local/gcc/gcc-20180926/Build/gotools'
make: *** [check-gotools] Error 2

Andreas.
Rainer Orth Sept. 26, 2018, 8:38 a.m. UTC | #9
Hi Andreas,

> On Sep 24 2018, Ian Lance Taylor <iant@golang.org> wrote:
>
>> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
>> make sure it is writable.
>> (check-go-tools): Likewise.
>
> $ make check-gotools
> make[1]: Entering directory `/usr/local/gcc/gcc-20180926/Build/gotools'
> chmod -R u+w check-go-dir
> chmod: cannot access `check-go-dir': No such file or directory
> make[1]: *** [check-go-tool] Error 1
> make[1]: Leaving directory `/usr/local/gcc/gcc-20180926/Build/gotools'
> make: *** [check-gotools] Error 2

I noticed the same when finding that gotools.{sum,log} hadn't been
generated.

The following patch fixed it for me.

	Rainer
Rainer Orth Sept. 26, 2018, 8:40 a.m. UTC | #10
Hi Ian,

> On Tue, Sep 25, 2018 at 6:26 AM, Rainer Orth
> <ro@cebitec.uni-bielefeld.de> wrote:
>>
>>> /vol/gcc/src/hg/trunk/local/libgo/go/runtime/traceback_gccgo.go:151:14: error: reference to undefined name 'nanotime'
>>> 151 |   waitfor = (nanotime() - gp.waitsince) / 60e9
>>>     |              ^
>>>
>>>   and many many more instances.  Again, I found an implementation in
>>>   upstream src/runtime/os3_solaris.go, but that isn't usable since it
>>>   uses syscall directly.
>>>
>>> So I'm currently stuck on the missing nanotime.
>>
>> I think I found it: if I enable building go/runtime/stubs3.go by
>> removing the !solaris build tag, the runtime_nanotime implementation in
>> runtime/go-nanotime.c is used.  At least the builds are going along
>> fine, it seems.  No test results yet.
>
> Thanks for the report.  I've committed this patch to fix the build on
> Solaris.  There are some test failures, though.  I haven't looked into
> them.

great, thanks for fixing this.  I do know about the failures; they are
(slowly) being looked at...

	Rainer
Andreas Schwab Sept. 26, 2018, 10:54 a.m. UTC | #11
All execution tests are now failing with "fatal error: impossible call
to aeshashbody".

Andreas.
Ian Lance Taylor Sept. 26, 2018, 12:49 p.m. UTC | #12
On Wed, Sep 26, 2018 at 3:54 AM, Andreas Schwab <schwab@suse.de> wrote:
>
> All execution tests are now failing with "fatal error: impossible call
> to aeshashbody".

Which target?

Ian
Ian Lance Taylor Sept. 26, 2018, 12:49 p.m. UTC | #13
On Wed, Sep 26, 2018 at 1:38 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
>> On Sep 24 2018, Ian Lance Taylor <iant@golang.org> wrote:
>>
>>> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
>>> make sure it is writable.
>>> (check-go-tools): Likewise.
>>
>> $ make check-gotools
>> make[1]: Entering directory `/usr/local/gcc/gcc-20180926/Build/gotools'
>> chmod -R u+w check-go-dir
>> chmod: cannot access `check-go-dir': No such file or directory
>> make[1]: *** [check-go-tool] Error 1
>> make[1]: Leaving directory `/usr/local/gcc/gcc-20180926/Build/gotools'
>> make: *** [check-gotools] Error 2
>
> I noticed the same when finding that gotools.{sum,log} hadn't been
> generated.
>
> The following patch fixed it for me.
>
>         Rainer
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
>
>
> 2018-09-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
>         * Makefile.am (mostlyclean-local): Ignore chmod errors.
>         (check-go-tool): Likewise.
>         * Makefile.in: Regenerate.

This is OK.  Thanks for writing it.  Please go ahead and commit.

Ian
H.J. Lu Sept. 26, 2018, 2:50 p.m. UTC | #14
On Mon, Sep 24, 2018 at 2:46 PM, Ian Lance Taylor <iant@golang.org> wrote:
> I've committed a patch to update libgo to the 1.11 release.  As usual
> for these updates, the patch is too large to attach to this e-mail
> message.  I've attached some of the more relevant directories.  This
> update required some minor patches to the gotools directory and the Go
> testsuite, also included here.  Bootstrapped and ran Go testsuite on
> x86_64-pc-linux-gnu.  Committed to mainline.
>
> Ian
>
> 2018-09-24  Ian Lance Taylor  <iant@golang.org>
>
> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
> make sure it is writable.
> (check-go-tools): Likewise.
> (check-vet): Copy internal/objabi to check-vet-dir.
> * Makefile.in: Rebuild.

When building with -mx32, I got

/export/gnu/import/git/sources/gcc/libgo/go/runtime/malloc.go:309:44:
error: integer constant overflow
309 |  arenaBaseOffset uintptr = sys.GoarchAmd64 * (1 << 47)
    |                                            ^
H.J. Lu Sept. 26, 2018, 3:10 p.m. UTC | #15
On Wed, Sep 26, 2018 at 7:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Sep 24, 2018 at 2:46 PM, Ian Lance Taylor <iant@golang.org> wrote:
>> I've committed a patch to update libgo to the 1.11 release.  As usual
>> for these updates, the patch is too large to attach to this e-mail
>> message.  I've attached some of the more relevant directories.  This
>> update required some minor patches to the gotools directory and the Go
>> testsuite, also included here.  Bootstrapped and ran Go testsuite on
>> x86_64-pc-linux-gnu.  Committed to mainline.
>>
>> Ian
>>
>> 2018-09-24  Ian Lance Taylor  <iant@golang.org>
>>
>> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
>> make sure it is writable.
>> (check-go-tools): Likewise.
>> (check-vet): Copy internal/objabi to check-vet-dir.
>> * Makefile.in: Rebuild.
>
> When building with -mx32, I got
>
> /export/gnu/import/git/sources/gcc/libgo/go/runtime/malloc.go:309:44:
> error: integer constant overflow
> 309 |  arenaBaseOffset uintptr = sys.GoarchAmd64 * (1 << 47)
>     |                                            ^
>

This seems to work:

diff --git a/libgo/go/runtime/malloc.go b/libgo/go/runtime/malloc.go
index ac4759ffbf1..c3445387057 100644
--- a/libgo/go/runtime/malloc.go
+++ b/libgo/go/runtime/malloc.go
@@ -306,7 +306,7 @@ const (
   //
   // On other platforms, the user address space is contiguous
   // and starts at 0, so no offset is necessary.
-  arenaBaseOffset uintptr = sys.GoarchAmd64 * (1 << 47)
+  arenaBaseOffset uintptr = _64bit * sys.GoarchAmd64 * (1 << 47)

   // Max number of threads to run garbage collection.
   // 2, 3, and 4 are all plausible maximums depending
Rainer Orth Sept. 28, 2018, 2:22 p.m. UTC | #16
Hi Ian,

> I've committed a patch to update libgo to the 1.11 release.  As usual
> for these updates, the patch is too large to attach to this e-mail
> message.  I've attached some of the more relevant directories.  This
> update required some minor patches to the gotools directory and the Go
> testsuite, also included here.  Bootstrapped and ran Go testsuite on
> x86_64-pc-linux-gnu.  Committed to mainline.

I just found another issue: unlike Solaris 11, Solaris 10 lacks memmem,
breaking the build:

/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c: In function 'Index':
/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c:96:6: error: implicit declaration of function 'memmem'; did you mean 'memset'? [-Werror=implicit-function-declaration]
96 |  p = memmem(a.__values, a.__count, b.__values, b.__count);
   |      ^~~~~~
   |      memset
/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c:96:4: error: assignment to 'const byte *' {aka 'const unsigned char *'} from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
96 |  p = memmem(a.__values, a.__count, b.__values, b.__count);
   |    ^
/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c: In function 'IndexString':
/vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c:111:4: error: assignment to 'const byte *' {aka 'const unsigned char *'} from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
111 |  p = memmem(a.str, a.len, b.str, b.len);
    |    ^

	Rainer
Ian Lance Taylor Oct. 1, 2018, 8:15 p.m. UTC | #17
On Wed, Sep 26, 2018 at 3:54 AM, Andreas Schwab <schwab@suse.de> wrote:
> All execution tests are now failing with "fatal error: impossible call
> to aeshashbody".

Thanks.  Fixed by this patch, which adds AES hash code for arm64 using
intrinsics.  Bootstrapped and tested on x86_64-pc-linux-gnu and
aarch4-unknown-linux-gnu.  Some other aarch64 tests failed; I'm not
sure if they failed before or not.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 264690)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-f4a224ec481957ca4f14d0e8cc4fe59cc95b3a49
+013a9e68c9a31f888733d46182d19f9e5d956f27
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/runtime/aeshash.c
===================================================================
--- libgo/runtime/aeshash.c	(revision 264648)
+++ libgo/runtime/aeshash.c	(working copy)
@@ -573,13 +573,412 @@ uintptr aeshashbody(void* p, uintptr see
 
 #endif // !defined(__x86_64__)
 
-#else // !defined(__i386__) && !defined(__x86_64__) || !defined(HAVE_AS_X86_AES)
+#elif defined(__aarch64__)
+
+// Undefine some identifiers that we pick up from the Go runtime package that
+// are used in arm_neon.h.
+
+#undef t1
+#undef tx
+#undef t2
+#undef t3
+#undef t4
+#undef t5
+
+#include <arm_neon.h>
+
+// Force appropriate CPU level.  We won't call here unless the CPU
+// supports it.
+
+#pragma GCC target("+crypto")
+
+// The arm64 version of aeshashbody.
+
+uintptr aeshashbody(void* p, uintptr seed, uintptr size, Slice aeskeysched) {
+	uint8x16_t *pseed;
+	uint32x4_t vinit32;
+	uint8x16_t vinit;
+	uint8x16_t vseed, vseed2, vseed3, vseed4;
+	uint8x16_t vseed5, vseed6, vseed7, vseed8;
+	uint8x16_t vval, vval2, vval3, vval4;
+	uint8x16_t vval5, vval6, vval7, vval8;
+	uint8x16_t vvalLoop, vvalLoop2, vvalLoop3, vvalLoop4;
+	uint8x16_t vvalLoop5, vvalLoop6, vvalLoop7, vvalLoop8;
+	uint8x16x2_t avval2;
+	uint8x16x3_t avseed3;
+
+	pseed = (uint8x16_t*)(aeskeysched.__values);
+
+	// Combined hash seed and length.
+	vinit32 = vdupq_n_u32(0);
+	vinit32[0] = (uint32)seed;
+	vinit32[1] = (uint32)size;
+	vinit = vreinterpretq_u8_u32(vinit32);
+
+	// Mix in per-process seed.
+	vseed = vaeseq_u8(*pseed, vinit);
+	++pseed;
+	// Scramble seed.
+	vseed = vaesmcq_u8(vseed);
+
+	if (size <= 16) {
+		if (size == 0) {
+			// Return 64 bits of scrambled input seed.
+			return vreinterpretq_u64_u8(vseed)[0];
+		} else if (size < 16) {
+			vval = vreinterpretq_u8_u32(vdupq_n_u32(0));
+			if ((size & 8) != 0) {
+				vval = vreinterpretq_u8_u64(vld1q_lane_u64((uint64_t*)(p), vreinterpretq_u64_u8(vval), 0));
+				p = (void*)((uint64_t*)(p) + 1);
+			}
+			if ((size & 4) != 0) {
+				vval = vreinterpretq_u8_u32(vld1q_lane_u32((uint32_t*)(p), vreinterpretq_u32_u8(vval), 2));
+				p = (void*)((uint32_t*)(p) + 1);
+			}
+			if ((size & 2) != 0) {
+				vval = vreinterpretq_u8_u16(vld1q_lane_u16((uint16_t*)(p), vreinterpretq_u16_u8(vval), 6));
+				p = (void*)((uint16_t*)(p) + 1);
+			}
+			if ((size & 1) != 0) {
+				vval = vld1q_lane_u8((uint8*)(p), vval, 14);
+			}
+		} else {
+			vval = *(uint8x16_t*)(p);
+		}
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval = vaeseq_u8(vval, vseed);
+		return vreinterpretq_u64_u8(vval)[0];
+	} else if (size <= 32) {
+		// Make a second seed.
+		vseed2 = vaeseq_u8(*pseed, vinit);
+		vseed2 = vaesmcq_u8(vseed2);
+		vval = *(uint8x16_t*)(p);
+		vval2 = *(uint8x16_t*)((char*)(p) + (size - 16));
+
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval2 = vaesmcq_u8(vval2);
+
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval2 = vaesmcq_u8(vval2);
+
+		vval = vaeseq_u8(vval, vseed);
+		vval2 = vaeseq_u8(vval2, vseed2);
+
+		vval ^= vval2;
+
+		return vreinterpretq_u64_u8(vval)[0];
+	} else if (size <= 64) {
+		avseed3 = vld1q_u8_x3((uint8*)(pseed));
+		vseed2 = avseed3.val[0];
+		vseed3 = avseed3.val[1];
+		vseed4 = avseed3.val[2];
+
+		vseed2 = vaeseq_u8(vseed2, vinit);
+		vseed2 = vaesmcq_u8(vseed2);
+		vseed3 = vaeseq_u8(vseed3, vinit);
+		vseed3 = vaesmcq_u8(vseed3);
+		vseed4 = vaeseq_u8(vseed4, vinit);
+		vseed4 = vaesmcq_u8(vseed4);
+
+		avval2 = vld1q_u8_x2((uint8*)(p));
+		vval = avval2.val[0];
+		vval2 = avval2.val[1];
+		avval2 = vld1q_u8_x2((uint8*)(p) + (size - 32));
+		vval3 = avval2.val[0];
+		vval4 = avval2.val[1];
+
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval2 = vaesmcq_u8(vval2);
+		vval3 = vaeseq_u8(vval3, vseed3);
+		vval3 = vaesmcq_u8(vval3);
+		vval4 = vaeseq_u8(vval4, vseed4);
+		vval4 = vaesmcq_u8(vval4);
+
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval2 = vaesmcq_u8(vval2);
+		vval3 = vaeseq_u8(vval3, vseed3);
+		vval3 = vaesmcq_u8(vval3);
+		vval4 = vaeseq_u8(vval4, vseed4);
+		vval4 = vaesmcq_u8(vval4);
+
+		vval = vaeseq_u8(vval, vseed);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval3 = vaeseq_u8(vval3, vseed3);
+		vval4 = vaeseq_u8(vval4, vseed4);
+
+		vval ^= vval3;
+		vval2 ^= vval4;
+		vval ^= vval2;
+
+		return vreinterpretq_u64_u8(vval)[0];
+	} else if (size <= 128) {
+		// For some reason vld1q_u8_x4 is missing.
+		avseed3 = vld1q_u8_x3((uint8*)(pseed));
+		vseed2 = avseed3.val[0];
+		vseed3 = avseed3.val[1];
+		vseed4 = avseed3.val[2];
+		avseed3 = vld1q_u8_x3((uint8*)(pseed + 3));
+		vseed5 = avseed3.val[0];
+		vseed6 = avseed3.val[1];
+		vseed7 = avseed3.val[2];
+		vseed8 = *(pseed + 6);
+
+		vseed2 = vaeseq_u8(vseed2, vinit);
+		vseed2 = vaesmcq_u8(vseed2);
+		vseed3 = vaeseq_u8(vseed3, vinit);
+		vseed3 = vaesmcq_u8(vseed3);
+		vseed4 = vaeseq_u8(vseed4, vinit);
+		vseed4 = vaesmcq_u8(vseed4);
+		vseed5 = vaeseq_u8(vseed5, vinit);
+		vseed5 = vaesmcq_u8(vseed5);
+		vseed6 = vaeseq_u8(vseed6, vinit);
+		vseed6 = vaesmcq_u8(vseed6);
+		vseed7 = vaeseq_u8(vseed7, vinit);
+		vseed7 = vaesmcq_u8(vseed7);
+		vseed8 = vaeseq_u8(vseed8, vinit);
+		vseed8 = vaesmcq_u8(vseed8);
+
+		avval2 = vld1q_u8_x2((uint8*)(p));
+		vval = avval2.val[0];
+		vval2 = avval2.val[1];
+		avval2 = vld1q_u8_x2((uint8*)(p) + 32);
+		vval3 = avval2.val[0];
+		vval4 = avval2.val[1];
+		avval2 = vld1q_u8_x2((uint8*)(p) + (size - 64));
+		vval5 = avval2.val[0];
+		vval6 = avval2.val[1];
+		avval2 = vld1q_u8_x2((uint8*)(p) + (size - 32));
+		vval7 = avval2.val[0];
+		vval8 = avval2.val[1];
+
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval2 = vaesmcq_u8(vval2);
+		vval3 = vaeseq_u8(vval3, vseed3);
+		vval3 = vaesmcq_u8(vval3);
+		vval4 = vaeseq_u8(vval4, vseed4);
+		vval4 = vaesmcq_u8(vval4);
+		vval5 = vaeseq_u8(vval5, vseed5);
+		vval5 = vaesmcq_u8(vval5);
+		vval6 = vaeseq_u8(vval6, vseed6);
+		vval6 = vaesmcq_u8(vval6);
+		vval7 = vaeseq_u8(vval7, vseed7);
+		vval7 = vaesmcq_u8(vval7);
+		vval8 = vaeseq_u8(vval8, vseed8);
+		vval8 = vaesmcq_u8(vval8);
+
+		vval = vaeseq_u8(vval, vseed);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval2 = vaesmcq_u8(vval2);
+		vval3 = vaeseq_u8(vval3, vseed3);
+		vval3 = vaesmcq_u8(vval3);
+		vval4 = vaeseq_u8(vval4, vseed4);
+		vval4 = vaesmcq_u8(vval4);
+		vval5 = vaeseq_u8(vval5, vseed5);
+		vval5 = vaesmcq_u8(vval5);
+		vval6 = vaeseq_u8(vval6, vseed6);
+		vval6 = vaesmcq_u8(vval6);
+		vval7 = vaeseq_u8(vval7, vseed7);
+		vval7 = vaesmcq_u8(vval7);
+		vval8 = vaeseq_u8(vval8, vseed8);
+		vval8 = vaesmcq_u8(vval8);
+
+		vval = vaeseq_u8(vval, vseed);
+		vval2 = vaeseq_u8(vval2, vseed2);
+		vval3 = vaeseq_u8(vval3, vseed3);
+		vval4 = vaeseq_u8(vval4, vseed4);
+		vval5 = vaeseq_u8(vval5, vseed5);
+		vval6 = vaeseq_u8(vval6, vseed6);
+		vval7 = vaeseq_u8(vval7, vseed7);
+		vval8 = vaeseq_u8(vval8, vseed8);
+
+		vval ^= vval5;
+		vval2 ^= vval6;
+		vval3 ^= vval7;
+		vval4 ^= vval8;
+		vval ^= vval3;
+		vval2 ^= vval4;
+		vval ^= vval2;
+
+		return vreinterpretq_u64_u8(vval)[0];
+	} else {
+		// For some reason vld1q_u8_x4 is missing.
+		avseed3 = vld1q_u8_x3((uint8*)(pseed));
+		vseed2 = avseed3.val[0];
+		vseed3 = avseed3.val[1];
+		vseed4 = avseed3.val[2];
+		avseed3 = vld1q_u8_x3((uint8*)(pseed + 3));
+		vseed5 = avseed3.val[0];
+		vseed6 = avseed3.val[1];
+		vseed7 = avseed3.val[2];
+		vseed8 = *(pseed + 6);
+
+		vseed2 = vaeseq_u8(vseed2, vinit);
+		vseed2 = vaesmcq_u8(vseed2);
+		vseed3 = vaeseq_u8(vseed3, vinit);
+		vseed3 = vaesmcq_u8(vseed3);
+		vseed4 = vaeseq_u8(vseed4, vinit);
+		vseed4 = vaesmcq_u8(vseed4);
+		vseed5 = vaeseq_u8(vseed5, vinit);
+		vseed5 = vaesmcq_u8(vseed5);
+		vseed6 = vaeseq_u8(vseed6, vinit);
+		vseed6 = vaesmcq_u8(vseed6);
+		vseed7 = vaeseq_u8(vseed7, vinit);
+		vseed7 = vaesmcq_u8(vseed7);
+		vseed8 = vaeseq_u8(vseed8, vinit);
+		vseed8 = vaesmcq_u8(vseed8);
+
+		avval2 = vld1q_u8_x2((uint8*)(p) + (size - 128));
+		vval = avval2.val[0];
+		vval2 = avval2.val[1];
+		avval2 = vld1q_u8_x2((uint8*)(p) + (size - 96));
+		vval3 = avval2.val[0];
+		vval4 = avval2.val[1];
+		avval2 = vld1q_u8_x2((uint8*)(p) + (size - 64));
+		vval5 = avval2.val[0];
+		vval6 = avval2.val[1];
+		avval2 = vld1q_u8_x2((uint8*)(p) + (size - 32));
+		vval7 = avval2.val[0];
+		vval8 = avval2.val[1];
+
+		vvalLoop = vseed;
+		vvalLoop2 = vseed2;
+		vvalLoop3 = vseed3;
+		vvalLoop4 = vseed4;
+		vvalLoop5 = vseed5;
+		vvalLoop6 = vseed6;
+		vvalLoop7 = vseed7;
+		vvalLoop8 = vseed8;
+
+		size--;
+		size >>= 7;
+		do {
+			vval = vaeseq_u8(vval, vvalLoop);
+			vval = vaesmcq_u8(vval);
+			vval2 = vaeseq_u8(vval2, vvalLoop2);
+			vval2 = vaesmcq_u8(vval2);
+			vval3 = vaeseq_u8(vval3, vvalLoop3);
+			vval3 = vaesmcq_u8(vval3);
+			vval4 = vaeseq_u8(vval4, vvalLoop4);
+			vval4 = vaesmcq_u8(vval4);
+			vval5 = vaeseq_u8(vval5, vvalLoop5);
+			vval5 = vaesmcq_u8(vval5);
+			vval6 = vaeseq_u8(vval6, vvalLoop6);
+			vval6 = vaesmcq_u8(vval6);
+			vval7 = vaeseq_u8(vval7, vvalLoop7);
+			vval7 = vaesmcq_u8(vval7);
+			vval8 = vaeseq_u8(vval8, vvalLoop8);
+			vval8 = vaesmcq_u8(vval8);
+
+			avval2 = vld1q_u8_x2((uint8*)(p));
+			vvalLoop = avval2.val[0];
+			vvalLoop2 = avval2.val[1];
+			avval2 = vld1q_u8_x2((uint8*)(p) + 32);
+			vvalLoop3 = avval2.val[0];
+			vvalLoop4 = avval2.val[1];
+			avval2 = vld1q_u8_x2((uint8*)(p) + 64);
+			vvalLoop5 = avval2.val[0];
+			vvalLoop6 = avval2.val[1];
+			avval2 = vld1q_u8_x2((uint8*)(p) + 96);
+			vvalLoop7 = avval2.val[0];
+			vvalLoop8 = avval2.val[1];
+
+			p = (void *)((uint8*)(p) + 128);
+
+			vval = vaeseq_u8(vval, vvalLoop);
+			vval = vaesmcq_u8(vval);
+			vval2 = vaeseq_u8(vval2, vvalLoop2);
+			vval2 = vaesmcq_u8(vval2);
+			vval3 = vaeseq_u8(vval3, vvalLoop3);
+			vval3 = vaesmcq_u8(vval3);
+			vval4 = vaeseq_u8(vval4, vvalLoop4);
+			vval4 = vaesmcq_u8(vval4);
+			vval5 = vaeseq_u8(vval5, vvalLoop5);
+			vval5 = vaesmcq_u8(vval5);
+			vval6 = vaeseq_u8(vval6, vvalLoop6);
+			vval6 = vaesmcq_u8(vval6);
+			vval7 = vaeseq_u8(vval7, vvalLoop7);
+			vval7 = vaesmcq_u8(vval7);
+			vval8 = vaeseq_u8(vval8, vvalLoop8);
+			vval8 = vaesmcq_u8(vval8);
+		} while (--size > 0);
+
+		vval = vaeseq_u8(vval, vvalLoop);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vvalLoop2);
+		vval2 = vaesmcq_u8(vval2);
+		vval3 = vaeseq_u8(vval3, vvalLoop3);
+		vval3 = vaesmcq_u8(vval3);
+		vval4 = vaeseq_u8(vval4, vvalLoop4);
+		vval4 = vaesmcq_u8(vval4);
+		vval5 = vaeseq_u8(vval5, vvalLoop5);
+		vval5 = vaesmcq_u8(vval5);
+		vval6 = vaeseq_u8(vval6, vvalLoop6);
+		vval6 = vaesmcq_u8(vval6);
+		vval7 = vaeseq_u8(vval7, vvalLoop7);
+		vval7 = vaesmcq_u8(vval7);
+		vval8 = vaeseq_u8(vval8, vvalLoop8);
+		vval8 = vaesmcq_u8(vval8);
+
+
+		vval = vaeseq_u8(vval, vvalLoop);
+		vval = vaesmcq_u8(vval);
+		vval2 = vaeseq_u8(vval2, vvalLoop2);
+		vval2 = vaesmcq_u8(vval2);
+		vval3 = vaeseq_u8(vval3, vvalLoop3);
+		vval3 = vaesmcq_u8(vval3);
+		vval4 = vaeseq_u8(vval4, vvalLoop4);
+		vval4 = vaesmcq_u8(vval4);
+		vval5 = vaeseq_u8(vval5, vvalLoop5);
+		vval5 = vaesmcq_u8(vval5);
+		vval6 = vaeseq_u8(vval6, vvalLoop6);
+		vval6 = vaesmcq_u8(vval6);
+		vval7 = vaeseq_u8(vval7, vvalLoop7);
+		vval7 = vaesmcq_u8(vval7);
+		vval8 = vaeseq_u8(vval8, vvalLoop8);
+		vval8 = vaesmcq_u8(vval8);
+
+		vval = vaeseq_u8(vval, vvalLoop);
+		vval2 = vaeseq_u8(vval2, vvalLoop2);
+		vval3 = vaeseq_u8(vval3, vvalLoop3);
+		vval4 = vaeseq_u8(vval4, vvalLoop4);
+		vval5 = vaeseq_u8(vval5, vvalLoop5);
+		vval6 = vaeseq_u8(vval6, vvalLoop6);
+		vval7 = vaeseq_u8(vval7, vvalLoop7);
+		vval8 = vaeseq_u8(vval8, vvalLoop8);
+
+		vval ^= vval5;
+		vval2 ^= vval6;
+		vval3 ^= vval7;
+		vval4 ^= vval8;
+		vval ^= vval3;
+		vval2 ^= vval4;
+		vval ^= vval2;
+
+		return vreinterpretq_u64_u8(vval)[0];
+	}
+}
+
+#else // (!defined(__i386__) && !defined(__x86_64__) || !defined(HAVE_AS_X86_AES)) && !defined(__aarch64__)
 
 uintptr aeshashbody(void* p __attribute__((unused)),
 		    uintptr seed __attribute__((unused)),
 		    uintptr size __attribute__((unused)),
 		    Slice aeskeysched __attribute__((unused))) {
-	// We should never get here on a non-x86 system.
+	// We should never get here on a non-x86, non-arm64 system.
 	runtime_throw("impossible call to aeshashbody");
 }
Ian Lance Taylor Oct. 1, 2018, 8:18 p.m. UTC | #18
On Wed, Sep 26, 2018 at 7:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Sep 24, 2018 at 2:46 PM, Ian Lance Taylor <iant@golang.org> wrote:
>> I've committed a patch to update libgo to the 1.11 release.  As usual
>> for these updates, the patch is too large to attach to this e-mail
>> message.  I've attached some of the more relevant directories.  This
>> update required some minor patches to the gotools directory and the Go
>> testsuite, also included here.  Bootstrapped and ran Go testsuite on
>> x86_64-pc-linux-gnu.  Committed to mainline.
>>
>> Ian
>>
>> 2018-09-24  Ian Lance Taylor  <iant@golang.org>
>>
>> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
>> make sure it is writable.
>> (check-go-tools): Likewise.
>> (check-vet): Copy internal/objabi to check-vet-dir.
>> * Makefile.in: Rebuild.
>
> When building with -mx32, I got
>
> /export/gnu/import/git/sources/gcc/libgo/go/runtime/malloc.go:309:44:
> error: integer constant overflow
> 309 |  arenaBaseOffset uintptr = sys.GoarchAmd64 * (1 << 47)
>     |                                            ^


Thanks.  I fixed this problem by switching to using amd64p32 on x32.
Bootstrapped and ran testsuite on x86_64-pc-linux-gnu using
--with-multilib-list=m64,m32,mx32.  However, I ran this on a kernel
without x32 support, so while building succeeds, I couldn't actually
run any tests.  Let me know how they do.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 264771)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-013a9e68c9a31f888733d46182d19f9e5d956f27
+2f56d51c6b3104242613c74b02fa6c63a2fe16c5
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/configure.ac
===================================================================
--- libgo/configure.ac	(revision 264648)
+++ libgo/configure.ac	(working copy)
@@ -252,8 +252,13 @@ changequote([,])dnl
 #ifdef __x86_64__
 #error 64-bit
 #endif],
-[GOARCH=386],
-[GOARCH=amd64])
+	[GOARCH=386],
+	AC_COMPILE_IFELSE([
+#ifdef __ILP32__
+#error x32
+#endif],
+	[GOARCH=amd64],
+	[GOARCH=amd64p32]))
     ;;
   ia64-*-*)
     GOARCH=ia64
Index: libgo/go/hash/crc32/crc32_amd64p32.go
===================================================================
--- libgo/go/hash/crc32/crc32_amd64p32.go	(revision 264648)
+++ libgo/go/hash/crc32/crc32_amd64p32.go	(working copy)
@@ -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 ignore
+
 package crc32
 
 import "internal/cpu"
Index: libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go
===================================================================
--- libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go	(nonexistent)
+++ libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go	(working copy)
@@ -0,0 +1,9 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+// Linux getrandom system call number.
+// See GetRandom in getrandom_linux.go.
+const randomTrap uintptr = 0x40000000 + 318
Index: libgo/go/runtime/lfstack_32bit.go
===================================================================
--- libgo/go/runtime/lfstack_32bit.go	(revision 264648)
+++ libgo/go/runtime/lfstack_32bit.go	(working copy)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build 386 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc
+// +build 386 amd64p32 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc
 
 package runtime
 
Index: libgo/goarch.sh
===================================================================
--- libgo/goarch.sh	(revision 264648)
+++ libgo/goarch.sh	(working copy)
@@ -57,10 +57,15 @@ case $goarch in
 	defaultphyspagesize=8192
 	pcquantum=4
 	;;
-    amd64 | amd64p32)
+    amd64)
 	family=AMD64
 	hugepagesize="1 << 21"
 	;;
+    amd64p32)
+	family=AMD64
+	hugepagesize="1 << 21"
+	ptrsize=4
+	;;
     arm | armbe)
 	family=ARM
 	cachelinesize=32
H.J. Lu Oct. 1, 2018, 8:27 p.m. UTC | #19
On Mon, Oct 1, 2018 at 1:18 PM, Ian Lance Taylor <iant@golang.org> wrote:
> On Wed, Sep 26, 2018 at 7:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Sep 24, 2018 at 2:46 PM, Ian Lance Taylor <iant@golang.org> wrote:
>>> I've committed a patch to update libgo to the 1.11 release.  As usual
>>> for these updates, the patch is too large to attach to this e-mail
>>> message.  I've attached some of the more relevant directories.  This
>>> update required some minor patches to the gotools directory and the Go
>>> testsuite, also included here.  Bootstrapped and ran Go testsuite on
>>> x86_64-pc-linux-gnu.  Committed to mainline.
>>>
>>> Ian
>>>
>>> 2018-09-24  Ian Lance Taylor  <iant@golang.org>
>>>
>>> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
>>> make sure it is writable.
>>> (check-go-tools): Likewise.
>>> (check-vet): Copy internal/objabi to check-vet-dir.
>>> * Makefile.in: Rebuild.
>>
>> When building with -mx32, I got
>>
>> /export/gnu/import/git/sources/gcc/libgo/go/runtime/malloc.go:309:44:
>> error: integer constant overflow
>> 309 |  arenaBaseOffset uintptr = sys.GoarchAmd64 * (1 << 47)
>>     |                                            ^
>
>
> Thanks.  I fixed this problem by switching to using amd64p32 on x32.
> Bootstrapped and ran testsuite on x86_64-pc-linux-gnu using
> --with-multilib-list=m64,m32,mx32.  However, I ran this on a kernel
> without x32 support, so while building succeeds, I couldn't actually
> run any tests.  Let me know how they do.
>
> Ian

I am giving it try.

Thanks.
H.J. Lu Oct. 1, 2018, 11:56 p.m. UTC | #20
On Mon, Oct 1, 2018 at 1:27 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Oct 1, 2018 at 1:18 PM, Ian Lance Taylor <iant@golang.org> wrote:
>> On Wed, Sep 26, 2018 at 7:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Mon, Sep 24, 2018 at 2:46 PM, Ian Lance Taylor <iant@golang.org> wrote:
>>>> I've committed a patch to update libgo to the 1.11 release.  As usual
>>>> for these updates, the patch is too large to attach to this e-mail
>>>> message.  I've attached some of the more relevant directories.  This
>>>> update required some minor patches to the gotools directory and the Go
>>>> testsuite, also included here.  Bootstrapped and ran Go testsuite on
>>>> x86_64-pc-linux-gnu.  Committed to mainline.
>>>>
>>>> Ian
>>>>
>>>> 2018-09-24  Ian Lance Taylor  <iant@golang.org>
>>>>
>>>> * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
>>>> make sure it is writable.
>>>> (check-go-tools): Likewise.
>>>> (check-vet): Copy internal/objabi to check-vet-dir.
>>>> * Makefile.in: Rebuild.
>>>
>>> When building with -mx32, I got
>>>
>>> /export/gnu/import/git/sources/gcc/libgo/go/runtime/malloc.go:309:44:
>>> error: integer constant overflow
>>> 309 |  arenaBaseOffset uintptr = sys.GoarchAmd64 * (1 << 47)
>>>     |                                            ^
>>
>>
>> Thanks.  I fixed this problem by switching to using amd64p32 on x32.
>> Bootstrapped and ran testsuite on x86_64-pc-linux-gnu using
>> --with-multilib-list=m64,m32,mx32.  However, I ran this on a kernel
>> without x32 support, so while building succeeds, I couldn't actually
>> run any tests.  Let me know how they do.
>>
>> Ian
>
> I am giving it try.
>

Compared with my patch, there are some new failures:

--- FAIL: TestAtomicStop (1.82s)
    signal_test.go:384: iteration 5: output lost signal on tries: 2
    signal_test.go:392: iteration 5: lost signal
FAIL
FAIL: os/signal

FAIL: go.test/test/env.go execution,  -O2 -g
FAIL: go.test/test/nilptr2.go execution,  -O2 -g
FAIL: go.test/test/nilptr2.go execution,  -O2 -g

FAIL: net/http

--- FAIL: TestExtraFiles (0.21s)
    exec_test.go:611: Run: exit status 1; stdout "leaked parent file.
fd = 6; want 4\n", stderr ""
FAIL
FAIL: os/exec

goroutine 4538 [runnable]:
created by net_http_test.TestConcurrentServerServe
        /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest51963/test/serve_test.go:5394
+310

goroutine 4539 [runnable]:
created by net_http_test.TestConcurrentServerServe
        /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest51963/test/serve_test.go:5395
+421

eax    0x0
ebx    0x2
ecx    0xa6cf6a5c
edx    0x0
edi    0x0
esi    0x8
ebp    0xa6cf6a5c
esp    0xa6cf6a40
eip    0xf7ed4069
eflags 0x282
cs     0x23
fs     0x0
gs     0x63
FAIL: net/http

goroutine 23819 [GC worker (idle)]:
runtime.mcall
        /export/gnu/import/git/sources/gcc/libgo/runtime/proc.c:342
runtime.gopark
        /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/proc.go:333
runtime.gcBgMarkWorker
        /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/mgc.go:1773
runtime.kickoff
        /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/proc.go:1214
created by runtime.gcBgMarkStartWorkers
        /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/mgc.go:1719
+92

eax    0x0
ebx    0x2
ecx    0xaa4ecaec
edx    0x0
edi    0x0
esi    0x8
ebp    0xaa4ecaec
esp    0xaa4ecad0
eip    0xf7f81069
eflags 0x286
cs     0x23
fs     0x0
gs     0x63
FAIL: runtime

FAIL: go.test/test/env.go execution,  -O2 -g
FAIL: go.test/test/nilptr2.go execution,  -O2 -g
FAIL: go.test/test/nilptr2.go execution,  -O2 -g
Ian Lance Taylor Oct. 2, 2018, 12:06 a.m. UTC | #21
On Mon, Oct 1, 2018 at 4:56 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Compared with my patch, there are some new failures:

Thanks.  We probably need a patch in gcc/testsuite/go.test/go-test.exp
to set goarch to amd64p32 when appropriate.

Other than that there seems to be some sort of signal handling
problem.  Hard to say what that might be.

Ian


> --- FAIL: TestAtomicStop (1.82s)
>     signal_test.go:384: iteration 5: output lost signal on tries: 2
>     signal_test.go:392: iteration 5: lost signal
> FAIL
> FAIL: os/signal
>
> FAIL: go.test/test/env.go execution,  -O2 -g
> FAIL: go.test/test/nilptr2.go execution,  -O2 -g
> FAIL: go.test/test/nilptr2.go execution,  -O2 -g
>
> FAIL: net/http
>
> --- FAIL: TestExtraFiles (0.21s)
>     exec_test.go:611: Run: exit status 1; stdout "leaked parent file.
> fd = 6; want 4\n", stderr ""
> FAIL
> FAIL: os/exec
>
> goroutine 4538 [runnable]:
> created by net_http_test.TestConcurrentServerServe
>         /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest51963/test/serve_test.go:5394
> +310
>
> goroutine 4539 [runnable]:
> created by net_http_test.TestConcurrentServerServe
>         /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest51963/test/serve_test.go:5395
> +421
>
> eax    0x0
> ebx    0x2
> ecx    0xa6cf6a5c
> edx    0x0
> edi    0x0
> esi    0x8
> ebp    0xa6cf6a5c
> esp    0xa6cf6a40
> eip    0xf7ed4069
> eflags 0x282
> cs     0x23
> fs     0x0
> gs     0x63
> FAIL: net/http
>
> goroutine 23819 [GC worker (idle)]:
> runtime.mcall
>         /export/gnu/import/git/sources/gcc/libgo/runtime/proc.c:342
> runtime.gopark
>         /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/proc.go:333
> runtime.gcBgMarkWorker
>         /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/mgc.go:1773
> runtime.kickoff
>         /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/proc.go:1214
> created by runtime.gcBgMarkStartWorkers
>         /export/build/gnu/tools-build/gcc-x32/build-x86_64-linux/x86_64-pc-linux-gnu/32/libgo/gotest93522/test/mgc.go:1719
> +92
>
> eax    0x0
> ebx    0x2
> ecx    0xaa4ecaec
> edx    0x0
> edi    0x0
> esi    0x8
> ebp    0xaa4ecaec
> esp    0xaa4ecad0
> eip    0xf7f81069
> eflags 0x286
> cs     0x23
> fs     0x0
> gs     0x63
> FAIL: runtime
>
> FAIL: go.test/test/env.go execution,  -O2 -g
> FAIL: go.test/test/nilptr2.go execution,  -O2 -g
> FAIL: go.test/test/nilptr2.go execution,  -O2 -g
>
> --
> H.J.
H.J. Lu Oct. 2, 2018, 1:57 a.m. UTC | #22
On Mon, Oct 1, 2018 at 5:06 PM Ian Lance Taylor <iant@golang.org> wrote:
>
> On Mon, Oct 1, 2018 at 4:56 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > Compared with my patch, there are some new failures:
>
> Thanks.  We probably need a patch in gcc/testsuite/go.test/go-test.exp
> to set goarch to amd64p32 when appropriate.
>
> Other than that there seems to be some sort of signal handling
> problem.  Hard to say what that might be.
>

Does amd64p32 disable any amd64 specific handling?
Ian Lance Taylor Oct. 2, 2018, 4:08 a.m. UTC | #23
On Mon, Oct 1, 2018 at 6:57 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Oct 1, 2018 at 5:06 PM Ian Lance Taylor <iant@golang.org> wrote:
>>
>> On Mon, Oct 1, 2018 at 4:56 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> >
>> > Compared with my patch, there are some new failures:
>>
>> Thanks.  We probably need a patch in gcc/testsuite/go.test/go-test.exp
>> to set goarch to amd64p32 when appropriate.
>>
>> Other than that there seems to be some sort of signal handling
>> problem.  Hard to say what that might be.
>>
>
> Does amd64p32 disable any amd64 specific handling?

Not as far as I can see.

Ian
Ian Lance Taylor Oct. 2, 2018, 4:45 p.m. UTC | #24
On Fri, Sep 28, 2018 at 7:22 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
>> I've committed a patch to update libgo to the 1.11 release.  As usual
>> for these updates, the patch is too large to attach to this e-mail
>> message.  I've attached some of the more relevant directories.  This
>> update required some minor patches to the gotools directory and the Go
>> testsuite, also included here.  Bootstrapped and ran Go testsuite on
>> x86_64-pc-linux-gnu.  Committed to mainline.
>
> I just found another issue: unlike Solaris 11, Solaris 10 lacks memmem,
> breaking the build:
>
> /vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c: In function 'Index':
> /vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c:96:6: error: implicit declaration of function 'memmem'; did you mean 'memset'? [-Werror=implicit-function-declaration]
> 96 |  p = memmem(a.__values, a.__count, b.__values, b.__count);
>    |      ^~~~~~
>    |      memset
> /vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c:96:4: error: assignment to 'const byte *' {aka 'const unsigned char *'} from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
> 96 |  p = memmem(a.__values, a.__count, b.__values, b.__count);
>    |    ^
> /vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c: In function 'IndexString':
> /vol/gcc/src/hg/trunk/local/libgo/go/internal/bytealg/bytealg.c:111:4: error: assignment to 'const byte *' {aka 'const unsigned char *'} from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
> 111 |  p = memmem(a.str, a.len, b.str, b.len);
>     |    ^

Thanks for the note.  This patch should fix the problem.  Bootstrapped
and ran Go tests on x86_64-pc-linux-gnu, both normally and pretending
that the system had no memmem.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 264793)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-098e36f4ddfcf50aeb34509b5f25b86d7050749c
+bde5ac90e0b4efdf3e9a4d72af4eb23250608611
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/configure.ac
===================================================================
--- libgo/configure.ac	(revision 264772)
+++ libgo/configure.ac	(working copy)
@@ -544,7 +544,7 @@ AC_CHECK_HEADERS([linux/filter.h linux/i
 
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 
-AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr)
+AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr memmem)
 AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
 AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
 
Index: libgo/go/internal/bytealg/bytealg.c
===================================================================
--- libgo/go/internal/bytealg/bytealg.c	(revision 264648)
+++ libgo/go/internal/bytealg/bytealg.c	(working copy)
@@ -10,6 +10,33 @@
 #include "runtime.h"
 #include "array.h"
 
+#ifndef HAVE_MEMMEM
+
+#define memmem goMemmem
+
+static const void *goMemmem(const void *in, size_t inl, const void *s, size_t sl) {
+	const char *p;
+	char first;
+	const char *stop;
+
+	if (sl == 0) {
+		return in;
+	}
+	if (inl < sl) {
+		return nil;
+	}
+	first = *(const char *)(s);
+	stop = (const char *)(in) + (inl - sl);
+	for (p = (const char *)(in); p <= stop; p++) {
+		if (*p == first && __builtin_memcmp(p + 1, (const char *)(s) + 1, sl - 1) == 0) {
+			return (const void *)(p);
+		}
+	}
+	return nil;
+}
+
+#endif
+
 intgo Compare(struct __go_open_array, struct __go_open_array)
   __asm__(GOSYM_PREFIX "internal_bytealg.Compare")
   __attribute__((no_split_stack));
H.J. Lu Oct. 3, 2018, 12:34 p.m. UTC | #25
On Mon, Oct 1, 2018 at 9:08 PM Ian Lance Taylor <iant@golang.org> wrote:
>
> On Mon, Oct 1, 2018 at 6:57 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > On Mon, Oct 1, 2018 at 5:06 PM Ian Lance Taylor <iant@golang.org> wrote:
> >>
> >> On Mon, Oct 1, 2018 at 4:56 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> >> >
> >> > Compared with my patch, there are some new failures:
> >>
> >> Thanks.  We probably need a patch in gcc/testsuite/go.test/go-test.exp
> >> to set goarch to amd64p32 when appropriate.
> >>
> >> Other than that there seems to be some sort of signal handling
> >> problem.  Hard to say what that might be.
> >>
> >
> > Does amd64p32 disable any amd64 specific handling?
>
> Not as far as I can see.
>

These tests aren't very reliable.  Let's go with your patch.  At least, it
builds for x32.

Thanks.
Ian Lance Taylor Oct. 3, 2018, 9:03 p.m. UTC | #26
On Mon, Oct 1, 2018 at 5:06 PM, Ian Lance Taylor <iant@golang.org> wrote:
> On Mon, Oct 1, 2018 at 4:56 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> Compared with my patch, there are some new failures:
>
> Thanks.  We probably need a patch in gcc/testsuite/go.test/go-test.exp
> to set goarch to amd64p32 when appropriate.

This is that patch.  I figured out how to run x32 binaries on my
system.  With this patch, everything passes except some code using
getpwuid_r, which also fails in plain C so I'm not going to worry
about it.  That said, I do not see some of the failures you mentioned.

In any case, this patch does pass bootstrap and testing on
x86_64-pc-linux-gnu both with and without -mx32.  Committed to
mainline.

Ian

2018-10-03  Ian Lance Taylor  <iant@google.com>

* go.test/go-test.exp (go-set-goarch): Use amd64p32 on x32.
Index: go.test/go-test.exp
===================================================================
--- go.test/go-test.exp	(revision 264816)
+++ go.test/go-test.exp	(working copy)
@@ -203,6 +203,8 @@
 	"x86_64-*-*" {
 	    if [check_effective_target_ia32] {
 		set goarch "386"
+	    } elseif [check_effective_target_x32] {
+		set goarch "amd64p32"
 	    } else {
 		set goarch "amd64"
 	    }
Rainer Orth Oct. 4, 2018, 11:34 a.m. UTC | #27
Hi Ian,

> Thanks for the note.  This patch should fix the problem.  Bootstrapped
> and ran Go tests on x86_64-pc-linux-gnu, both normally and pretending
> that the system had no memmem.  Committed to mainline.

I've now verified the patch on i386-pc-solaris2.10: bootstrap restored.

Thanks.
        Rainer
diff mbox series

Patch

Index: libgo/MERGE
===================================================================
--- libgo/MERGE	(revision 264542)
+++ libgo/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-fe8a0d12b14108cbe2408b417afcaab722b0727c
+41e62b8c49d21659b48a95216e3062032285250f
 
 The first line of this file holds the git revision number of the
 last merge done from the master library sources.
Index: libgo/VERSION
===================================================================
--- libgo/VERSION	(revision 264542)
+++ libgo/VERSION	(working copy)
@@ -1 +1 @@ 
-go1.10.3
+go1.11
Index: libgo/Makefile.am
===================================================================
--- libgo/Makefile.am	(revision 264542)
+++ libgo/Makefile.am	(working copy)
@@ -541,6 +541,7 @@  s-objabi: Makefile
 	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 defaultGOOS = runtime.GOOS' >> objabi.go.tmp
 	echo 'const defaultGOARCH = runtime.GOARCH' >> objabi.go.tmp
 	echo 'const defaultGO_EXTLINK_ENABLED = ``' >> objabi.go.tmp
@@ -608,7 +609,7 @@  noinst_DATA += zdefaultcc.go
 zstdpkglist.go: s-zstdpkglist; @true
 s-zstdpkglist: Makefile
 	rm -f zstdpkglist.go.tmp
-	echo 'package build' > zstdpkglist.go.tmp
+	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|\([a-z0-9_/]*\)\.lo|"\1": true,|g' >> zstdpkglist.go.tmp
@@ -707,6 +708,7 @@  PACKAGES = $(shell cat $(srcdir)/libgo-p
 libgo_go_objs = \
 	$(addsuffix .lo,$(PACKAGES)) \
 	bytes/index.lo \
+	internal/bytealg/bytealg.lo \
 	reflect/makefunc_ffi_c.lo \
 	strings/index.lo \
 	$(syscall_lib_clone_lo) \
@@ -718,7 +720,8 @@  libgo_go_objs = \
 	log/syslog/syslog_c.lo \
 	$(os_lib_inotify_lo) \
 	runtime/internal/atomic_c.lo \
-	sync/atomic_c.lo
+	sync/atomic_c.lo \
+	internal/cpu/cpu_gccgo.lo
 
 libgo_ldflags = \
 	-version-info $(libtool_VERSION) $(PTHREAD_CFLAGS) $(AM_LDFLAGS)
@@ -960,8 +963,8 @@  runtime_pprof_check_GOCFLAGS = -static-l
 extra_go_files_runtime_internal_sys = version.go
 runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys)
 
-extra_go_files_go_build = zstdpkglist.go
-go/build.lo.dep: $(extra_go_files_go_build)
+extra_go_files_internal_goroot = zstdpkglist.go
+internal/goroot.lo.dep: $(extra_go_files_internal_goroot)
 
 extra_go_files_go_types = gccgosizes.go
 go/types.lo.dep: $(extra_go_files_go_types)
@@ -976,6 +979,16 @@  extra_check_libs_cmd_go_internal_cache =
 extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_imports = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_modconv = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_modfetch = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_modfetch_codehost = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_modfile = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_modload = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_module = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_mvs = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_search = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_web2 = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a
 
 extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a
@@ -990,6 +1003,9 @@  bytes/index.lo: go/bytes/indexbyte.c run
 strings/index.lo: go/strings/indexbyte.c runtime.inc
 	@$(MKDIR_P) strings
 	$(LTCOMPILE) -c -o $@ $(srcdir)/go/strings/indexbyte.c
+internal/bytealg/bytealg.lo: go/internal/bytealg/bytealg.c runtime.inc
+	@$(MKDIR_P) internal/bytealg
+	$(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/bytealg/bytealg.c
 
 # Use a C function with a fixed number of arguments to call a C
 # varargs function.
@@ -1024,6 +1040,11 @@  syscall/wait.lo: go/syscall/wait.c runti
 	@$(MKDIR_P) syscall
 	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/wait.c
 
+# internal/cpu needs some C code.
+internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc
+	@$(MKDIR_P) internal/cpu
+	$(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/cpu/cpu_gccgo.c
+
 # Solaris 11.4 changed the type of fields in struct stat.
 # Use a build tag, based on a configure check, to cope.
 if LIBGO_IS_SOLARIS
Index: libgo/check-packages.txt
===================================================================
--- libgo/check-packages.txt	(revision 264542)
+++ libgo/check-packages.txt	(working copy)
@@ -3,9 +3,23 @@  archive/zip
 bufio
 bytes
 cmd/go/internal/cache
+cmd/go/internal/dirhash
 cmd/go/internal/generate
 cmd/go/internal/get
+cmd/go/internal/imports
 cmd/go/internal/load
+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/web2
 cmd/go/internal/work
 cmd/internal/buildid
 cmd/internal/edit
@@ -29,6 +43,7 @@  crypto/dsa
 crypto/ecdsa
 crypto/elliptic
 crypto/hmac
+crypto/internal/subtle
 crypto/md5
 crypto/rand
 crypto/rc4
@@ -76,11 +91,15 @@  go/printer
 go/scanner
 go/token
 go/types
+golang_org/x/crypto/internal/chacha20
 golang_org/x/crypto/chacha20poly1305
 golang_org/x/crypto/chacha20poly1305/internal/chacha20
 golang_org/x/crypto/cryptobyte
 golang_org/x/crypto/curve25519
 golang_org/x/crypto/poly1305
+golang_org/x/net/dns/dnsmessage
+golang_org/x/net/http/httpguts
+golang_org/x/net/http/httpproxy
 golang_org/x/net/http2/hpack
 golang_org/x/net/idna
 golang_org/x/net/lex/httplex
@@ -98,6 +117,7 @@  image/draw
 image/jpeg
 image/png
 index/suffixarray
+internal/cpu
 internal/poll
 internal/singleflight
 internal/trace
Index: libgo/gotool-packages.txt
===================================================================
--- libgo/gotool-packages.txt	(revision 264542)
+++ libgo/gotool-packages.txt	(working copy)
@@ -4,6 +4,7 @@  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
@@ -11,15 +12,32 @@  cmd/go/internal/fmtcmd
 cmd/go/internal/generate
 cmd/go/internal/get
 cmd/go/internal/help
+cmd/go/internal/imports
 cmd/go/internal/list
 cmd/go/internal/load
+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/par
 cmd/go/internal/run
+cmd/go/internal/search
+cmd/go/internal/semver
 cmd/go/internal/str
 cmd/go/internal/test
 cmd/go/internal/tool
+cmd/go/internal/txtar
 cmd/go/internal/version
 cmd/go/internal/vet
 cmd/go/internal/web
+cmd/go/internal/web2
+cmd/go/internal/webtest
 cmd/go/internal/work
 cmd/internal/browser
 cmd/internal/buildid
Index: libgo/libgo-packages.txt
===================================================================
--- libgo/libgo-packages.txt	(revision 264542)
+++ libgo/libgo-packages.txt	(working copy)
@@ -19,7 +19,8 @@  crypto/dsa
 crypto/ecdsa
 crypto/elliptic
 crypto/hmac
-crypto/internal/cipherhw
+crypto/internal/randutil
+crypto/internal/subtle
 crypto/md5
 crypto/rand
 crypto/rc4
@@ -70,12 +71,16 @@  go/printer
 go/scanner
 go/token
 go/types
+golang_org/x/crypto/internal/chacha20
 golang_org/x/crypto/chacha20poly1305
 golang_org/x/crypto/chacha20poly1305/internal/chacha20
 golang_org/x/crypto/cryptobyte
 golang_org/x/crypto/cryptobyte/asn1
 golang_org/x/crypto/curve25519
 golang_org/x/crypto/poly1305
+golang_org/x/net/dns/dnsmessage
+golang_org/x/net/http/httpguts
+golang_org/x/net/http/httpproxy
 golang_org/x/net/http2/hpack
 golang_org/x/net/idna
 golang_org/x/net/internal/nettest
@@ -103,6 +108,9 @@  image/internal/imageutil
 image/jpeg
 image/png
 index/suffixarray
+internal/bytealg
+internal/cpu
+internal/goroot
 internal/nettrace
 internal/poll
 internal/race
Index: libgo/match.sh
===================================================================
--- libgo/match.sh	(revision 264542)
+++ libgo/match.sh	(working copy)
@@ -116,7 +116,7 @@  for f in $gofiles; do
 	aix | android | darwin | dragonfly | freebsd | 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)
+	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)
 	    tag1=nonmatchingtag
 	    ;;
     esac
@@ -128,7 +128,7 @@  for f in $gofiles; do
 	aix | android | darwin | dragonfly | freebsd | 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)
+	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)
 	    tag2=nonmatchingtag
 	    ;;
     esac
Index: libgo/merge.sh
===================================================================
--- libgo/merge.sh	(revision 264542)
+++ libgo/merge.sh	(working copy)
@@ -128,7 +128,7 @@  echo ${rev} > VERSION
 (cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
   skip=false
   case "$f" in
-  ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/internal/browser/* | ./cmd/internal/objabi/* | ./cmd/internal/buildid/*)
+  ./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/*)
     skip=true
Index: libgo/runtime/go-caller.c
===================================================================
--- libgo/runtime/go-caller.c	(revision 264542)
+++ libgo/runtime/go-caller.c	(working copy)
@@ -210,17 +210,6 @@  Caller (int skip)
 /* Look up the function name, file name, and line number for a PC.  */
 
 struct funcfileline_return
-{
-  String retfn;
-  String retfile;
-  intgo retline;
-};
-
-struct funcfileline_return
-runtime_funcfileline (uintptr targetpc, int32 index)
-  __asm__ (GOSYM_PREFIX "runtime.funcfileline");
-
-struct funcfileline_return
 runtime_funcfileline (uintptr targetpc, int32 index)
 {
   struct funcfileline_return ret;
Index: libgo/runtime/go-runtime-error.c
===================================================================
--- libgo/runtime/go-runtime-error.c	(revision 264542)
+++ libgo/runtime/go-runtime-error.c	(working copy)
@@ -60,16 +60,29 @@  extern void __go_runtime_error (int32) _
 void
 __go_runtime_error (int32 i)
 {
+  struct funcfileline_return fileline;
+  bool in_runtime;
+
+  fileline = runtime_funcfileline ((uintptr) runtime_getcallerpc(), 0);
+  in_runtime = (fileline.retfn.len > 0
+		&& (__builtin_strncmp ((const char *) fileline.retfn.str,
+				      "runtime.", 8)
+		    == 0));
+
   switch (i)
     {
     case SLICE_INDEX_OUT_OF_BOUNDS:
     case ARRAY_INDEX_OUT_OF_BOUNDS:
     case STRING_INDEX_OUT_OF_BOUNDS:
+      if (in_runtime)
+	runtime_throw ("index out of range");
       runtime_panicstring ("index out of range");
 
     case SLICE_SLICE_OUT_OF_BOUNDS:
     case ARRAY_SLICE_OUT_OF_BOUNDS:
     case STRING_SLICE_OUT_OF_BOUNDS:
+      if (in_runtime)
+	runtime_throw ("slice bounds out of range");
       runtime_panicstring ("slice bounds out of range");
 
     case NIL_DEREFERENCE:
Index: libgo/runtime/panic.c
===================================================================
--- libgo/runtime/panic.c	(revision 264542)
+++ libgo/runtime/panic.c	(working copy)
@@ -37,3 +37,11 @@  runtime_panicstring(const char *s)
 	runtime_newErrorCString(s, &err);
 	runtime_panic(err);
 }
+
+extern void runtime_abort(void) __asm__(GOSYM_PREFIX "runtime.abort");
+
+void
+runtime_abort()
+{
+	abort();
+}
Index: libgo/runtime/runtime.h
===================================================================
--- libgo/runtime/runtime.h	(revision 264542)
+++ libgo/runtime/runtime.h	(working copy)
@@ -403,8 +403,6 @@  void runtime_panic(Eface)
 /*
  * runtime c-called (but written in Go)
  */
-void	runtime_newTypeAssertionError(const String*, const String*, const String*, const String*, Eface*)
-     __asm__ (GOSYM_PREFIX "runtime.NewTypeAssertionError");
 void	runtime_newErrorCString(const char*, Eface*)
      __asm__ (GOSYM_PREFIX "runtime.NewErrorCString");
 
@@ -479,10 +477,10 @@  extern void *getitab(const struct __go_t
   __asm__ (GOSYM_PREFIX "runtime.getitab");
 
 extern void runtime_cpuinit(void);
+extern void setRandomNumber(uint32)
+  __asm__ (GOSYM_PREFIX "runtime.setRandomNumber");
 extern void setIsCgo(void)
   __asm__ (GOSYM_PREFIX "runtime.setIsCgo");
-extern void setCpuidECX(uint32)
-  __asm__ (GOSYM_PREFIX "runtime.setCpuidECX");
 extern void setSupportAES(bool)
   __asm__ (GOSYM_PREFIX "runtime.setSupportAES");
 extern void typedmemmove(const Type *, void *, const void *)
@@ -493,3 +491,14 @@  extern Sched* runtime_getsched(void)
   __asm__ (GOSYM_PREFIX "runtime.getsched");
 extern void setpagesize(uintptr_t)
   __asm__(GOSYM_PREFIX "runtime.setpagesize");
+
+struct funcfileline_return
+{
+  String retfn;
+  String retfile;
+  intgo retline;
+};
+
+struct funcfileline_return
+runtime_funcfileline (uintptr targetpc, int32 index)
+  __asm__ (GOSYM_PREFIX "runtime.funcfileline");
Index: libgo/runtime/runtime_c.c
===================================================================
--- libgo/runtime/runtime_c.c	(revision 264542)
+++ libgo/runtime/runtime_c.c	(working copy)
@@ -33,6 +33,17 @@  runtime_atoi(const byte *p, intgo len)
 	return n;
 }
 
+// A random number from the GNU/Linux auxv array.
+static uint32 randomNumber;
+
+// Set the random number from Go code.
+
+void
+setRandomNumber(uint32 r)
+{
+	randomNumber = r;
+}
+
 #if defined(__i386__) || defined(__x86_64__) || defined (__s390__) || defined (__s390x__)
 
 // When cputicks is just asm instructions, skip the split stack
@@ -85,8 +96,8 @@  runtime_cputicks(void)
 #else
   // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
   // runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
-  // TODO: need more entropy to better seed fastrand.
-  return runtime_nanotime();
+  // randomNumber provides better seeding of fastrand.
+  return runtime_nanotime() + randomNumber;
 #endif
 }
 
@@ -193,7 +204,6 @@  runtime_cpuinit()
 		}
 	}
 	if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) {
-		setCpuidECX(ecx);
 #if defined(__i386__)
 		if ((edx & bit_SSE2) != 0) {
 			hasSSE2 = true;
Index: libgo/testsuite/gotest
===================================================================
--- libgo/testsuite/gotest	(revision 264542)
+++ libgo/testsuite/gotest	(working copy)
@@ -314,7 +314,7 @@  x)
 	    aix | android | darwin | dragonfly | freebsd | 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)
+	    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)
 		tag1=nonmatchingtag
 		;;
 	    esac
@@ -326,7 +326,7 @@  x)
 	    aix | android | darwin | dragonfly | freebsd | 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)
+	    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)
 		tag2=nonmatchingtag
 		;;
 	    esac