libgo: add hppa as known target

Message ID e072e22428810ff407f96ce3d9e062b8@matoro.tk
State Unresolved
Headers
Series libgo: add hppa as known target |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

matoro Dec. 14, 2022, 1:04 a.m. UTC
  Test results:  This is sufficient to get a build that can compile
trivial hello world programs.  Nontrivial operations (like "go install")
crash in the runtime.  However, GOGC=off completely avoids these crashes
and is able to compile more complex libraries, so likely a GC issue.
Support needs to be added to /x/sys/unix package for any real-world
programs to function.

The values in goarch.sh are taken from the recommendations in this
linux-parisc thread:
https://lore.kernel.org/linux-parisc/7013a3e7d6c9c77c5010bc1c72971758@matoro.tk/t/#u

Additionally it's suggested that the GC issues may be related to the
stack implementation in libgo/runtime/stack.c, because the stack grows
upwards on hppa.

ChangeLog:

	* libgo/configure: Regenerate.
	* libgo/configure.ac: Add hppa.
	* libgo/go/cmd/cgo/main.go: Likewise.
	* libgo/go/go/build/syslist.go: Likewise.
	* libgo/go/runtime/hash32.go: Build for hppa.
	* libgo/go/runtime/lfstack_32bit.go: Likewise.
	* libgo/go/runtime/mpagealloc_32bit.go: Likewise.
	* libgo/go/runtime/panic32.go: Likewise.
	* libgo/go/syscall/endian_big.go: Likewise.
	* libgo/goarch.sh: Provide definitions for hppa.
	* libgo/match.sh: Add hppa.
	* libgo/testsuite/gotest: Likewise.
	* libgo/go/internal/syscall/unix/sysnum_linux_hppa.go: New file.

gcc/testsuite/ChangeLog:

	* go.test/go-test.exp: Add hppa.
---
  gcc/testsuite/go.test/go-test.exp                   |  3 +++
  libgo/configure                                     |  7 +++++--
  libgo/configure.ac                                  |  7 +++++--
  libgo/go/cmd/cgo/main.go                            |  2 ++
  libgo/go/go/build/syslist.go                        |  2 +-
  libgo/go/internal/syscall/unix/sysnum_linux_hppa.go | 10 ++++++++++
  libgo/go/runtime/hash32.go                          |  2 +-
  libgo/go/runtime/lfstack_32bit.go                   |  4 ++--
  libgo/go/runtime/mpagealloc_32bit.go                |  2 +-
  libgo/go/runtime/panic32.go                         |  2 +-
  libgo/go/syscall/endian_big.go                      |  2 +-
  libgo/goarch.sh                                     | 10 ++++++++++
  libgo/match.sh                                      |  4 ++--
  libgo/testsuite/gotest                              |  4 ++--
  14 files changed, 46 insertions(+), 15 deletions(-)
  create mode 100644 libgo/go/internal/syscall/unix/sysnum_linux_hppa.go

s390x | sh | shbe | sparc | sparc64 | wasm)
+	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
hppa | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | 
s390x | sh | shbe | sparc | sparc64 | wasm)
  		tag1=nonmatchingtag
  		;;
  	    *)
@@ -341,7 +341,7 @@ x)
  	    aix | android | darwin | dragonfly | freebsd | hurd | ios | 
illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | 
windows | zos)
  		tag2=nonmatchingtag
  		;;
-	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | 
s390x | sh | shbe | sparc | sparc64 | wasm)
+	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
hppa | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | 
s390x | sh | shbe | sparc | sparc64 | wasm)
  		tag2=nonmatchingtag
  		;;
  	    esac
  

Patch

diff --git a/gcc/testsuite/go.test/go-test.exp 
b/gcc/testsuite/go.test/go-test.exp
index 11c178ad7..fb28b785b 100644
--- a/gcc/testsuite/go.test/go-test.exp
+++ b/gcc/testsuite/go.test/go-test.exp
@@ -180,6 +180,9 @@  proc go-set-goarch { } {
  	"xscale-*-*" {
  	    set goarch "arm"
  	}
+	"hppa*-*-*" {
+	    set goarch "hppa"
+	}
  	"i?86-*-*" -
  	"x86_64-*-*" {
  	    if [check_effective_target_ia32] {
diff --git a/libgo/configure b/libgo/configure
index 460fdad70..9bffd2a32 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -14124,10 +14124,10 @@  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 hppa ia64 
m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 
ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"

  # All known GOARCH family values.
-ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 NIOS2 
PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"
+ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 HPPA IA64 M68K MIPS MIPS64 
NIOS2 PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"

  GOARCH=unknown
  case ${host} in
@@ -14148,6 +14148,9 @@  case ${host} in
  	;;
      esac
      ;;
+  hppa*-*-*)
+    GOARCH=hppa
+    ;;
    i[34567]86-*-* | x86_64-*-*)
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  /* end confdefs.h.  */
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 09554a37a..97e26d216 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -239,10 +239,10 @@  AC_SUBST(USE_DEJAGNU)
  #   - libgo/go/syscall/endian_XX.go
  #   - possibly others
  # - possibly update files in libgo/go/internal/syscall/unix
-ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k 
mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 
ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"
+ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be hppa ia64 
m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 
ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"

  # All known GOARCH family values.
-ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 NIOS2 
PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"
+ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 HPPA IA64 M68K MIPS MIPS64 
NIOS2 PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"

  GOARCH=unknown
  case ${host} in
@@ -263,6 +263,9 @@  case ${host} in
  	;;
      esac
      ;;
+  hppa*-*-*)
+    GOARCH=hppa
+    ;;
  changequote(,)dnl
    i[34567]86-*-* | x86_64-*-*)
  changequote([,])dnl
diff --git a/libgo/go/cmd/cgo/main.go b/libgo/go/cmd/cgo/main.go
index 186aef06c..269ac3d12 100644
--- a/libgo/go/cmd/cgo/main.go
+++ b/libgo/go/cmd/cgo/main.go
@@ -174,6 +174,7 @@  var ptrSizeMap = map[string]int64{
  	"amd64":       8,
  	"arm":         4,
  	"arm64":       8,
+	"hppa":        4,
  	"m68k":        4,
  	"mips":        4,
  	"mipsle":      4,
@@ -201,6 +202,7 @@  var intSizeMap = map[string]int64{
  	"amd64":       8,
  	"arm":         4,
  	"arm64":       8,
+	"hppa":        4,
  	"m68k":        4,
  	"mips":        4,
  	"mipsle":      4,
diff --git a/libgo/go/go/build/syslist.go b/libgo/go/go/build/syslist.go
index 1b11365f5..31f31b5fe 100644
--- a/libgo/go/go/build/syslist.go
+++ b/libgo/go/go/build/syslist.go
@@ -8,4 +8,4 @@  package build
  // Do not remove from this list, as these are used for go/build 
filename matching.

  const goosList = "aix android darwin dragonfly freebsd hurd illumos ios 
js linux nacl netbsd openbsd plan9 solaris windows zos "
-const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be loong64 
mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv riscv64 s390 s390x 
sparc sparc64 wasm alpha m68k nios2 sh shbe "
+const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be loong64 
mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv riscv64 s390 s390x 
sparc sparc64 wasm alpha hppa m68k nios2 sh shbe "
diff --git a/libgo/go/internal/syscall/unix/sysnum_linux_hppa.go 
b/libgo/go/internal/syscall/unix/sysnum_linux_hppa.go
new file mode 100644
index 000000000..2b6b2b30c
--- /dev/null
+++ b/libgo/go/internal/syscall/unix/sysnum_linux_hppa.go
@@ -0,0 +1,10 @@ 
+// Copyright 2022 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
+
+const (
+	getrandomTrap     uintptr = 339
+	copyFileRangeTrap uintptr = 346
+)
diff --git a/libgo/go/runtime/hash32.go b/libgo/go/runtime/hash32.go
index 52977ee3c..cb4180c92 100644
--- a/libgo/go/runtime/hash32.go
+++ b/libgo/go/runtime/hash32.go
@@ -5,7 +5,7 @@ 
  // Hashing algorithm inspired by
  // wyhash: 
https://github.com/wangyi-fudan/wyhash/blob/ceb019b530e2c1c14d70b79bfa2bc49de7d95bc1/Modern%20Non-Cryptographic%20Hash%20Function%20and%20Pseudorandom%20Number%20Generator.pdf

-//go:build 386 || arm || mips || mipsle || amd64p32 || armbe || m68k || 
mips64p32 || mips64p32le || nios2 || ppc || riscv || s390 || sh || shbe 
|| sparc
+//go:build 386 || arm || mips || mipsle || amd64p32 || armbe || hppa || 
m68k || mips64p32 || mips64p32le || nios2 || ppc || riscv || s390 || sh 
|| shbe || sparc

  package runtime

diff --git a/libgo/go/runtime/lfstack_32bit.go 
b/libgo/go/runtime/lfstack_32bit.go
index c0eb665dd..89e559404 100644
--- a/libgo/go/runtime/lfstack_32bit.go
+++ b/libgo/go/runtime/lfstack_32bit.go
@@ -2,8 +2,8 @@ 
  // Use of this source code is governed by a BSD-style
  // license that can be found in the LICENSE file.

-//go:build 386 || arm || mips || mipsle || amd64p32 || armbe || m68k || 
mips64p32 || mips64p32le || nios2 || ppc || riscv || s390 || sh || shbe 
|| sparc
-// +build 386 arm mips mipsle amd64p32 armbe m68k mips64p32 mips64p32le 
nios2 ppc riscv s390 sh shbe sparc
+//go:build 386 || arm || mips || mipsle || amd64p32 || armbe || hppa || 
m68k || mips64p32 || mips64p32le || nios2 || ppc || riscv || s390 || sh 
|| shbe || sparc
+// +build 386 arm mips mipsle amd64p32 armbe hppa m68k mips64p32 
mips64p32le nios2 ppc riscv s390 sh shbe sparc

  package runtime

diff --git a/libgo/go/runtime/mpagealloc_32bit.go 
b/libgo/go/runtime/mpagealloc_32bit.go
index 0979e0024..ae8df34e7 100644
--- a/libgo/go/runtime/mpagealloc_32bit.go
+++ b/libgo/go/runtime/mpagealloc_32bit.go
@@ -2,7 +2,7 @@ 
  // Use of this source code is governed by a BSD-style
  // license that can be found in the LICENSE file.

-//go:build 386 || arm || mips || mipsle || wasm || (ios && arm64) || 
amd64p32 || armbe || m68k || mips64p32 || mips64p32le || nios2 || ppc || 
riscv || s390 || sh || shbe || sparc
+//go:build 386 || arm || mips || mipsle || wasm || (ios && arm64) || 
amd64p32 || armbe || hppa || m68k || mips64p32 || mips64p32le || nios2 
|| ppc || riscv || s390 || sh || shbe || sparc

  // wasm is a treated as a 32-bit architecture for the purposes of the 
page
  // allocator, even though it has 64-bit pointers. This is because any 
wasm
diff --git a/libgo/go/runtime/panic32.go b/libgo/go/runtime/panic32.go
index df4afae4b..4127f8360 100644
--- a/libgo/go/runtime/panic32.go
+++ b/libgo/go/runtime/panic32.go
@@ -2,7 +2,7 @@ 
  // Use of this source code is governed by a BSD-style
  // license that can be found in the LICENSE file.

-//go:build 386 || amd64p32 || arm || mips || mipsle || armbe || m68k || 
nios2 || ppc || riscv || s390 || sh || shbe || sparc
+//go:build 386 || amd64p32 || arm || mips || mipsle || armbe || hppa || 
m68k || nios2 || ppc || riscv || s390 || sh || shbe || sparc

  package runtime

diff --git a/libgo/go/syscall/endian_big.go 
b/libgo/go/syscall/endian_big.go
index e6b1163ba..50aef3dd9 100644
--- a/libgo/go/syscall/endian_big.go
+++ b/libgo/go/syscall/endian_big.go
@@ -2,7 +2,7 @@ 
  // Use of this source code is governed by a BSD-style
  // license that can be found in the LICENSE file.

-//go:build ppc64 || s390x || mips || mips64 || armbe || arm64be || m68k 
|| ppc || mips64p32 || s390 || shbe || sparc || sparc64
+//go:build ppc64 || s390x || mips || mips64 || armbe || arm64be || hppa 
|| m68k || ppc || mips64p32 || s390 || shbe || sparc || sparc64

  package syscall

diff --git a/libgo/goarch.sh b/libgo/goarch.sh
index 977f318b3..e0d6a3ad8 100755
--- a/libgo/goarch.sh
+++ b/libgo/goarch.sh
@@ -88,6 +88,16 @@  case $goarch in
  		;;
  	esac
  	;;
+    hppa)
+	bigendian=true
+	defaultphyspagesize=4096
+	family=HPPA
+	int64align=8
+	minframesize=64
+	pcquantum=4
+	ptrsize=4
+	stackalign=64
+	;;
      ia64)
  	family=IA64
  	cachelinesize=128
diff --git a/libgo/match.sh b/libgo/match.sh
index e5ed98de4..153ed9da7 100755
--- a/libgo/match.sh
+++ b/libgo/match.sh
@@ -132,7 +132,7 @@  for f in $gofiles; do
  	aix | android | darwin | dragonfly | freebsd | illumos | hurd | ios | 
js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows | zos)
  	    tag1=nonmatchingtag
  	    ;;
-	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 
| m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | 
nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | 
shbe | sparc | sparc64 | wasm)
+	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | hppa 
| ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | 
s390x | sh | shbe | sparc | sparc64 | wasm)
  	    tag1=nonmatchingtag
  	    ;;
  	*)
@@ -149,7 +149,7 @@  for f in $gofiles; do
  	aix | android | darwin | dragonfly | freebsd | hurd | ios | illumos | 
js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows | zos)
  	    tag2=nonmatchingtag
  	    ;;
-	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 
| m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | 
nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | 
shbe | sparc | sparc64 | wasm)
+	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | hppa 
| ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | 
s390x | sh | shbe | sparc | sparc64 | wasm)
  	    tag2=nonmatchingtag
  	    ;;
      esac
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index 0a0a7e14d..cd62a77cd 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -324,7 +324,7 @@  x)
  	    aix | android | darwin | dragonfly | freebsd | hurd | ios | 
illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | 
windows | zos)
  		tag1=nonmatchingtag
  		;;
-	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | 
ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | 
mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 |