This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libgo: Add support for sh


Hello!

The attached patch adds the necessary definitions to enable libgo
to build on sh (Hitachi SuperH).

Two remarks:

1.

I'm not sure whether all the definitions in libgo/configure.ac are
correct for SuperH. I made the assumptions that the values are similar
for ARM 32-bit and SuperH as these architectures are comparable, except
that SH has always 16-bit instructions.

2.

In order for the build to succeed, I had to adjust the signature of
ioctl() in libgo/go/exp/terminal/util.go to make the second parameter
"uint" instead of "int", see [1]. With this change, the signature also
matches the signature used on Linux [2] and FreeBSD [3].

Without the change, the build fails with an integer overflow:

./libtool: line 1143: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
 ../../../src/libgo/go/exp/terminal/util.go:70:23: error: integer constant overflow
   if ioctl(fd, syscall.TIOCGWINSZ, unsafe.Pointer(&dimensions)) < 0 {
                        ^
 Makefile:3342: recipe for target 'exp/terminal.lo' failed

Thanks,
Adrian

> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83308#c10
> [2] http://man7.org/linux/man-pages/man2/ioctl.2.html
> [3] https://www.freebsd.org/cgi/man.cgi?query=ioctl&sektion=2

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
>From a20d0d921734a94da1e72beff862091323534ce0 Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Sat, 16 Dec 2017 10:05:20 +0100
Subject: [PATCH] 2017-12-16  John Paul Adrian Glaubitz
 <glaubitz@physik.fu-berlin.de>

        PR go/83308
        * libgo/configure.ac: Add autoconf definitions for sh.
        * libgo/go/cmd/cgo/main.go: Enable build on sh.
        * libgo/go/go/build/syslist.go: Likewise.
        * libgo/go/runtime/hash32.go: Likewise.
        * libgo/go/runtime/lfstack_32bit.go: Likewise.
        * libgo/go/runtime/unaligned2.go: Likewise.
        * libgo/go/syscall/endian_little.go: Likewise.
        * libgo/testsuite/gotest: Likewise.
        * libgo/match.sh: Add architecture matching for sh.
---
 ChangeLog                         | 13 +++++++++++++
 libgo/configure.ac                |  7 +++++++
 libgo/go/cmd/cgo/main.go          |  2 ++
 libgo/go/go/build/syslist.go      |  2 +-
 libgo/go/runtime/hash32.go        |  2 +-
 libgo/go/runtime/lfstack_32bit.go |  2 +-
 libgo/go/runtime/unaligned2.go    |  2 +-
 libgo/go/syscall/endian_little.go |  2 +-
 libgo/match.sh                    |  4 ++--
 libgo/testsuite/gotest            |  4 ++--
 10 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 275a340f6a8..f6efeb3e809 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2017-12-16  John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+
+        PR go/83308
+        * libgo/configure.ac: Add autoconf definitions for sh.
+        * libgo/go/cmd/cgo/main.go: Enable build on sh.
+        * libgo/go/go/build/syslist.go: Likewise.
+        * libgo/go/runtime/hash32.go: Likewise.
+        * libgo/go/runtime/lfstack_32bit.go: Likewise.
+        * libgo/go/runtime/unaligned2.go: Likewise.
+        * libgo/go/syscall/endian_little.go: Likewise.
+        * libgo/testsuite/gotest: Likewise.
+        * libgo/match.sh: Add architecture matching for sh.
+
 2017-12-12  Stafford Horne  <shorne@gmail.com>
 
 	* configure.ac: Remove logic adding gdb to noconfigsdirs for or1k.
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 7b0c629653f..65a9fb9c54e 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -360,6 +360,13 @@ GOARCH_MINFRAMESIZE=8
     GOARCH_CACHELINESIZE=256
     GOARCH_PCQUANTUM=2
     ;;
+  sh*-*-*)
+    GOARCH=sh
+    GOARCH_FAMILY=SH
+    GOARCH_CACHELINESIZE=32
+    GOARCH_PCQUANTUM=2
+    GOARCH_MINFRAMESIZE=4
+    ;;
   sparc*-*-*)
     AC_COMPILE_IFELSE([
 #if defined(__sparcv9) || defined(__arch64__)
diff --git a/libgo/go/cmd/cgo/main.go b/libgo/go/cmd/cgo/main.go
index c9a44fdd166..9c821db2d90 100644
--- a/libgo/go/cmd/cgo/main.go
+++ b/libgo/go/cmd/cgo/main.go
@@ -161,6 +161,7 @@ var ptrSizeMap = map[string]int64{
 	"ppc64le":     8,
 	"s390":        4,
 	"s390x":       8,
+	"sh":          4,
 	"sparc":       4,
 	"sparc64":     8,
 }
@@ -183,6 +184,7 @@ var intSizeMap = map[string]int64{
 	"ppc64le":     8,
 	"s390":        4,
 	"s390x":       8,
+	"sh":          4,
 	"sparc":       4,
 	"sparc64":     8,
 }
diff --git a/libgo/go/go/build/syslist.go b/libgo/go/go/build/syslist.go
index 290ba9efa0c..395dc8cd15a 100644
--- a/libgo/go/go/build/syslist.go
+++ b/libgo/go/go/build/syslist.go
@@ -5,4 +5,4 @@
 package build
 
 const goosList = "aix android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows zos "
-const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be alpha m68k ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc s390 s390x sparc sparc64 "
+const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be alpha m68k ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc s390 s390x sh sparc sparc64 "
diff --git a/libgo/go/runtime/hash32.go b/libgo/go/runtime/hash32.go
index dd2e657fe3f..628a3455736 100644
--- a/libgo/go/runtime/hash32.go
+++ b/libgo/go/runtime/hash32.go
@@ -6,7 +6,7 @@
 //   xxhash: https://code.google.com/p/xxhash/
 // cityhash: https://code.google.com/p/cityhash/
 
-// +build 386 arm armbe m68k mips mipsle ppc s390 sparc
+// +build 386 arm armbe m68k mips mipsle ppc s390 sh sparc
 
 package runtime
 
diff --git a/libgo/go/runtime/lfstack_32bit.go b/libgo/go/runtime/lfstack_32bit.go
index ab0edab68f5..66d749af67a 100644
--- a/libgo/go/runtime/lfstack_32bit.go
+++ b/libgo/go/runtime/lfstack_32bit.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build 386 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le ppc s390 sparc
+// +build 386 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le ppc s390 sh sparc
 
 package runtime
 
diff --git a/libgo/go/runtime/unaligned2.go b/libgo/go/runtime/unaligned2.go
index a33c87acd56..db5d78d4b70 100644
--- a/libgo/go/runtime/unaligned2.go
+++ b/libgo/go/runtime/unaligned2.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build arm mips mipsle mips64 mips64le armbe m68k sparc alpha ia64 mips64p32 mips64p32le sparc64
+// +build arm mips mipsle mips64 mips64le armbe m68k sparc alpha ia64 mips64p32 mips64p32le sh sparc64
 
 package runtime
 
diff --git a/libgo/go/syscall/endian_little.go b/libgo/go/syscall/endian_little.go
index b6c9ed0f9f7..b91d4bb72de 100644
--- a/libgo/go/syscall/endian_little.go
+++ b/libgo/go/syscall/endian_little.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 //
-// +build 386 amd64 amd64p32 arm arm64 ppc64le mips64le mipsle alpha ia64 mips64p32le
+// +build 386 amd64 amd64p32 arm arm64 ppc64le mips64le mipsle alpha ia64 mips64p32le sh
 
 package syscall
 
diff --git a/libgo/match.sh b/libgo/match.sh
index fac75eabec6..a3adfb63c31 100755
--- a/libgo/match.sh
+++ b/libgo/match.sh
@@ -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 | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
+	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sh | sparc | sparc64)
 	    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 | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
+	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sh | sparc | sparc64)
 	    tag2=nonmatchingtag
 	    ;;
     esac
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index 83f78d4d9b9..fd7ac68cb35 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -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 | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
+	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sh | sparc | sparc64)
 		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 | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
+	    386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sh | sparc | sparc64)
 		tag2=nonmatchingtag
 		;;
 	    esac
-- 
2.15.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]