Re: libgo patch committed: Update to Go1.14beta1

2020-02-04 Thread Andrew Pinski
Something like attached.
I will clean it up next week and submit it then.
It should also fix some arm64be related issues too.

Thanks,
Andrew Pinski

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

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

diff --git a/gcc/testsuite/go.test/go-test.exp 
b/gcc/testsuite/go.test/go-test.exp
index 51f9b381d67..7afcba14b64 100644
--- a/gcc/testsuite/go.test/go-test.exp
+++ b/gcc/testsuite/go.test/go-test.exp
@@ -188,7 +188,14 @@ proc go-set-goarch { } {
 
 switch -glob $target_triplet {
"aarch64*-*-*" {
-   set goarch "arm64"
+   if [check_effective_target_lp64] {
+   set goarch "arm64"
+   } else {
+   set goarch "amd64p32"
+   }
+   if [check_effective_target_aarch64_big_endian] {
+   append goarch "be"
+   }
}
"alpha*-*-*" {
set goarch "alpha"
diff --git a/libgo/configure b/libgo/configure
index 2f787392abd..8eca900889f 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -14070,7 +14070,7 @@ esac
 #   - libgo/go/syscall/endian_XX.go
 #   - possibly others
 # - possibly update files in libgo/go/internal/syscall/unix
-ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mips 
mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 ppc64le riscv 
riscv64 s390 s390x sh shbe sparc sparc64 wasm"
+ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be arm64p32 
arm64p32be ia64 m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 
ppc ppc64 ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"
 
 # All known GOARCH family values.
 ALLGOARCHFAMILY="

Re: libgo patch committed: Update to Go1.14beta1

2020-02-03 Thread Ian Lance Taylor
On Sun, Feb 2, 2020 at 2:27 AM Andreas Schwab  wrote:
>
> I'm getting these errors on aarch64 with -mabi=ilp32:
>
> ../../../../libgo/go/runtime/mpagealloc.go:226:38: error: shift count overflow
>   226 |  chunks [1 << pallocChunksL1Bits]*[1 << pallocChunksL2Bits]pallocData
>   |  ^
> ../../../../libgo/go/runtime/mgcscavenge.go:487:15: error: shift count 
> overflow
>   487 |l2 := (*[1 << 
> pallocChunksL2Bits]pallocData)(atomic.Loadp(unsafe.Pointer(&s.chunks[i.l1()])))
>   |   ^
> ../../../../libgo/go/runtime/mpagealloc.go:138:22: error: shift count overflow
>   138 |   return uint(i) & (1<   |  ^
> ../../../../libgo/go/runtime/mpagealloc.go:129:21: error: integer constant 
> overflow
>   129 |   return uint(i) >> pallocChunksL1Shift
>   | ^
> ../../../../libgo/go/runtime/mpagealloc_64bit.go:34:2: error: integer 
> constant overflow
>34 |  summaryL0Bits,
>   |  ^

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

Ian


Re: libgo patch committed: Update to Go1.14beta1

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


Thanks.  Fixed like so.  Committed to mainline.

Ian
79530f94e9c53153c4fae3b50a8c938f89db0c32
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 40529518b26..27f4ce342e5 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d796680b5a78f686ed118578e81d5b1adf48508d
+c94637ad6fd38d4814fb02d094a1a73f19323d71
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/syscall/syscall_linux_riscv64.go 
b/libgo/go/syscall/syscall_linux_riscv64.go
index e9aab94e3a1..16d8709708d 100644
--- a/libgo/go/syscall/syscall_linux_riscv64.go
+++ b/libgo/go/syscall/syscall_linux_riscv64.go
@@ -4,20 +4,6 @@
 
 package syscall
 
-import "unsafe"
-
 func (r *PtraceRegs) PC() uint64 { return r.Pc }
 
 func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
-
-func (iov *Iovec) SetLen(length int) {
-   iov.Len = uint64(length)
-}
-
-func (msghdr *Msghdr) SetControllen(length int) {
-   msghdr.Controllen = uint64(length)
-}
-
-func (cmsg *Cmsghdr) SetLen(length int) {
-   cmsg.Len = uint64(length)
-}


Re: libgo patch committed: Update to Go1.14beta1

2020-02-03 Thread David Abdurachmanov
On Sat, Feb 1, 2020 at 2:38 PM Andreas Schwab  wrote:

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


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

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

david


Re: libgo patch committed: Update to Go1.14beta1

2020-02-02 Thread Andreas Schwab
I'm getting these errors on aarch64 with -mabi=ilp32:

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

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: libgo patch committed: Update to Go1.14beta1

2020-02-01 Thread Andreas Schwab
../../../libgo/go/syscall/syscall_linux_riscv64.go:7:14: error: imported and 
not used: unsafe
7 | import "unsafe"
  |  ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:13:1: error: redefinition of 
'SetLen'
   13 | func (iov *Iovec) SetLen(length int) {
  | ^
../../../libgo/go/syscall/socket.go:437:1: note: previous definition of 
'SetLen' was here
  437 | func (iov *Iovec) SetLen(length int) {
  | ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:17:1: error: redefinition of 
'SetControllen'
   17 | func (msghdr *Msghdr) SetControllen(length int) {
  | ^
../../../libgo/go/syscall/socket.go:441:1: note: previous definition of 
'SetControllen' was here
  441 | func (msghdr *Msghdr) SetControllen(length int) {
  | ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:21:1: error: redefinition of 
'SetLen'
   21 | func (cmsg *Cmsghdr) SetLen(length int) {
  | ^
../../../libgo/go/syscall/socket.go:445:1: note: previous definition of 
'SetLen' was here
  445 | func (cmsg *Cmsghdr) SetLen(length int) {
  | ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:14:10: error: incompatible 
types in assignment (cannot use type uint64 as type Iovec_len_t)
   14 |  iov.Len = uint64(length)
  |  ^
../../../libgo/go/syscall/syscall_linux_riscv64.go:18:20: error: incompatible 
types in assignment (cannot use type uint64 as type Msghdr_controllen_t)
   18 |  msghdr.Controllen = uint64(length)
  |^
../../../libgo/go/syscall/syscall_linux_riscv64.go:22:11: error: incompatible 
types in assignment (cannot use type uint64 as type Cmsghdr_len_t)
   22 |  cmsg.Len = uint64(length)
  |   ^

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: libgo patch committed: Update to Go1.14beta1

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

Thanks.  Fixed like so.  Committed to mainline.

Ian
b83c78fe8fd12ce6c14fe2ca234edbbdac22cd79
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a8ba3afe86e..fc1dbaca8b9 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-7d3081ce69dda123d77e35e8b9d282e40e9465e2
+10a8dbfc9945c672d59af8edb9790e2019cdeb27
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/internal/cpu/cpu_riscv64.go 
b/libgo/go/internal/cpu/cpu_riscv64.go
index c49cab79fdc..d920fcf7a6d 100644
--- a/libgo/go/internal/cpu/cpu_riscv64.go
+++ b/libgo/go/internal/cpu/cpu_riscv64.go
@@ -3,5 +3,3 @@
 // license that can be found in the LICENSE file.
 
 package cpu
-
-const CacheLinePadSize = 32


Re: libgo patch committed: Update to Go1.14beta1

2020-01-23 Thread Rainer Orth
Hi Ian,

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

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

Thanks.
Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: libgo patch committed: Update to Go1.14beta1

2020-01-23 Thread Maciej W. Rozycki
On Tue, 21 Jan 2020, Ian Lance Taylor wrote:

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

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

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

  Maciej


Re: libgo patch committed: Update to Go1.14beta1

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

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

Ian


Re: libgo patch committed: Update to Go1.14beta1

2020-01-22 Thread Rainer Orth
Hi Ian,

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

the patch broke Solaris bootstrap:

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

There are 3 definitions in the Solaris/Illumos space:

* os_only_solaris.go is guarded by !illumos

* os3_solaris.go has no explicit guard

* illumos hat its own one in os_illumos.go

so the os3_solaris.go one can go.

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

Upstream has a definition in os3_solaris.go.

The following patch allows compilation to succeed.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


diff --git a/libgo/go/runtime/os3_solaris.go b/libgo/go/runtime/os3_solaris.go
--- a/libgo/go/runtime/os3_solaris.go
+++ b/libgo/go/runtime/os3_solaris.go
@@ -17,12 +17,11 @@ func getPageSize() int32
 //extern sysconf
 func sysconf(int32) _C_long
 
-func getncpu() int32 {
-	n := int32(sysconf(__SC_NPROCESSORS_ONLN))
-	if n < 1 {
-		return 1
+func osinit() {
+	ncpu = getncpu()
+	if physPageSize == 0 {
+		physPageSize = uintptr(getPageSize())
 	}
-	return n
 }
 
 func sysargs(argc int32, argv **byte) {