Hi Ian,

> I've committed a patch to update libgo to the Go 1.13beta1 release.
> As is usual with these updates, the patch is too large to include
> here; I've included the diffs of the various GCC-specific configury
> and other files.  Bootstrapped and ran Go testsuite on
> x86_64-pc-linux-gnu.  Committed to mainline.

this patch caused quite some fallout on Solaris, both SPARC and x86:

* The golang.org/x/net/lif package won't build:

make[4]: *** No rule to make target 'golang.org/x/net/lif.gox', needed by 
'net.lo'.  Stop.

  It moved from go/internal/x/net/lif/lif.go to
  go/golang.org/x/net/lif/lif.go, but neither was Makefile.am adapted to
  reflect this nor the Solaris fixes in the old version carried over to
  the new location.

* go/runtime/os_solaris.go doesn't compile:

/vol/gcc/src/hg/trunk/local/libgo/go/runtime/os_solaris.go:34:7: error: 
reference to undefined field or method ‘mos’
   34 |  if mp.mos.waitsema != 0 {
      |       ^

  and several more instances.  Caused by losing the explict mos member
  of m in go/runtime/runtime2.go, fixed by dropping it here, to.

* As Bernd mentioned, go/golang.org/x/sys/cpu/cpu_gccgo.{c, go} don't
  compile on non-x86 systems due to lack of <cpuid.h>.  Fixed by
  restricting to 386 or amd64 and wrapping the C code in __i386__ ||
  __x86_64__.

* The go/golang.org/x/sys/cpu package doesn't compile on SPARC:

/vol/gcc/src/hg/trunk/local/libgo/go/golang.org/x/sys/cpu/cpu.go:17:30: error: 
reference to undefined name 'cacheLineSize'
   17 | type CacheLinePad struct{ _ [cacheLineSize]byte }
      |                              ^
make[8]: *** [Makefile:2826: golang.org/x/sys/cpu.lo] Error 1

  For the moment, I've worked around this by introducing cpu_sparcx.go
  with appropriate build tags.  However, I'm uncertain what do do about
  the actual value of cacheLineSize: the L1 D$ size is 16 on
  UltraSPARC-T2, but 32 on SPARC-S7.

With the attached patch, I can now bootstrap mainline on both
i386-pc-solaris2.11 and sparc-sun-solaris2.11.  Test results are similar
to pre-1.13, but I'll have to check further.  One thing that's new on
both sparc and x86 is an ICE compiling internal/poll:

go1: internal compiler error: in bind_field_or_method, at 
go/gofrontend/types.cc:11878
0x56d3df Type::bind_field_or_method(Gogo*, Type const*, Expression*, 
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const&, Location)
        /vol/gcc/src/hg/trunk/local/gcc/go/gofrontend/types.cc:11878
0x4d2dcf Selector_expression::do_lower(Gogo*, Named_object*, 
Statement_inserter*, int)
        /vol/gcc/src/hg/trunk/local/gcc/go/gofrontend/expressions.cc:14403
[...]

        Rainer

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


# HG changeset patch
# Parent  cc2b98a3fc293d157b70a090c69a78d264801762
Fix libgo 1.13beta1 compilation on Solaris

diff --git a/libgo/Makefile.am b/libgo/Makefile.am
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -1055,9 +1055,9 @@ endif
 
 if LIBGO_IS_SOLARIS
 
-# Build internal/x/net/lif only on Solaris systems.
+# Build golang.org/x/net/lif only on Solaris systems.
 
-$(eval $(call PACKAGE_template,internal/x/net/lif))
+$(eval $(call PACKAGE_template,golang.org/x/net/lif))
 
 golangorg_x_net_lif_lo = \
 	golang.org/x/net/lif.lo
diff --git a/libgo/go/golang.org/x/net/lif/address_test.go b/libgo/go/golang.org/x/net/lif/address_test.go
new file mode 100644
--- /dev/null
+++ b/libgo/go/golang.org/x/net/lif/address_test.go
@@ -0,0 +1,123 @@
+// Copyright 2016 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.
+
+// +build solaris
+
+package lif
+
+import (
+	"fmt"
+	"testing"
+)
+
+type addrFamily int
+
+func (af addrFamily) String() string {
+	switch af {
+	case sysAF_UNSPEC:
+		return "unspec"
+	case sysAF_INET:
+		return "inet4"
+	case sysAF_INET6:
+		return "inet6"
+	default:
+		return fmt.Sprintf("%d", af)
+	}
+}
+
+const hexDigit = "0123456789abcdef"
+
+type llAddr []byte
+
+func (a llAddr) String() string {
+	if len(a) == 0 {
+		return ""
+	}
+	buf := make([]byte, 0, len(a)*3-1)
+	for i, b := range a {
+		if i > 0 {
+			buf = append(buf, ':')
+		}
+		buf = append(buf, hexDigit[b>>4])
+		buf = append(buf, hexDigit[b&0xF])
+	}
+	return string(buf)
+}
+
+type ipAddr []byte
+
+func (a ipAddr) String() string {
+	if len(a) == 0 {
+		return "<nil>"
+	}
+	if len(a) == 4 {
+		return fmt.Sprintf("%d.%d.%d.%d", a[0], a[1], a[2], a[3])
+	}
+	if len(a) == 16 {
+		return fmt.Sprintf("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15])
+	}
+	s := make([]byte, len(a)*2)
+	for i, tn := range a {
+		s[i*2], s[i*2+1] = hexDigit[tn>>4], hexDigit[tn&0xf]
+	}
+	return string(s)
+}
+
+func (a *Inet4Addr) String() string {
+	return fmt.Sprintf("(%s %s %d)", addrFamily(a.Family()), ipAddr(a.IP[:]), a.PrefixLen)
+}
+
+func (a *Inet6Addr) String() string {
+	return fmt.Sprintf("(%s %s %d %d)", addrFamily(a.Family()), ipAddr(a.IP[:]), a.PrefixLen, a.ZoneID)
+}
+
+type addrPack struct {
+	af int
+	as []Addr
+}
+
+func addrPacks() ([]addrPack, error) {
+	var lastErr error
+	var aps []addrPack
+	for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
+		as, err := Addrs(af, "")
+		if err != nil {
+			lastErr = err
+			continue
+		}
+		aps = append(aps, addrPack{af: af, as: as})
+	}
+	return aps, lastErr
+}
+
+func TestAddrs(t *testing.T) {
+	aps, err := addrPacks()
+	if len(aps) == 0 && err != nil {
+		t.Fatal(err)
+	}
+	lps, err := linkPacks()
+	if len(lps) == 0 && err != nil {
+		t.Fatal(err)
+	}
+	for _, lp := range lps {
+		n := 0
+		for _, ll := range lp.lls {
+			as, err := Addrs(lp.af, ll.Name)
+			if err != nil {
+				t.Fatal(lp.af, ll.Name, err)
+			}
+			t.Logf("af=%s name=%s %v", addrFamily(lp.af), ll.Name, as)
+			n += len(as)
+		}
+		for _, ap := range aps {
+			if ap.af != lp.af {
+				continue
+			}
+			if n != len(ap.as) {
+				t.Errorf("af=%s got %d; want %d", addrFamily(lp.af), n, len(ap.as))
+				continue
+			}
+		}
+	}
+}
diff --git a/libgo/go/golang.org/x/net/lif/link_test.go b/libgo/go/golang.org/x/net/lif/link_test.go
new file mode 100644
--- /dev/null
+++ b/libgo/go/golang.org/x/net/lif/link_test.go
@@ -0,0 +1,63 @@
+// Copyright 2016 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.
+
+// +build solaris
+
+package lif
+
+import (
+	"fmt"
+	"testing"
+)
+
+func (ll *Link) String() string {
+	return fmt.Sprintf("name=%s index=%d type=%d flags=%#x mtu=%d addr=%v", ll.Name, ll.Index, ll.Type, ll.Flags, ll.MTU, llAddr(ll.Addr))
+}
+
+type linkPack struct {
+	af  int
+	lls []Link
+}
+
+func linkPacks() ([]linkPack, error) {
+	var lastErr error
+	var lps []linkPack
+	for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
+		lls, err := Links(af, "")
+		if err != nil {
+			lastErr = err
+			continue
+		}
+		lps = append(lps, linkPack{af: af, lls: lls})
+	}
+	return lps, lastErr
+}
+
+func TestLinks(t *testing.T) {
+	lps, err := linkPacks()
+	if len(lps) == 0 && err != nil {
+		t.Fatal(err)
+	}
+	for _, lp := range lps {
+		n := 0
+		for _, sll := range lp.lls {
+			lls, err := Links(lp.af, sll.Name)
+			if err != nil {
+				t.Fatal(lp.af, sll.Name, err)
+			}
+			for _, ll := range lls {
+				if ll.Name != sll.Name || ll.Index != sll.Index {
+					t.Errorf("af=%s got %v; want %v", addrFamily(lp.af), &ll, &sll)
+					continue
+				}
+				t.Logf("af=%s name=%s %v", addrFamily(lp.af), sll.Name, &ll)
+				n++
+			}
+		}
+		if n != len(lp.lls) {
+			t.Errorf("af=%s got %d; want %d", addrFamily(lp.af), n, len(lp.lls))
+			continue
+		}
+	}
+}
diff --git a/libgo/go/golang.org/x/net/lif/syscall.go b/libgo/go/golang.org/x/net/lif/syscall.go
--- a/libgo/go/golang.org/x/net/lif/syscall.go
+++ b/libgo/go/golang.org/x/net/lif/syscall.go
@@ -11,18 +11,12 @@ import (
 	"unsafe"
 )
 
-//go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
-
-//go:linkname procIoctl libc_ioctl
-
-var procIoctl uintptr
-
-func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno)
+//extern __go_ioctl_ptr
+func libc_ioctl(int32, int32, unsafe.Pointer) int32
 
 func ioctl(s, ioc uintptr, arg unsafe.Pointer) error {
-	_, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procIoctl)), 3, s, ioc, uintptr(arg), 0, 0, 0)
-	if errno != 0 {
-		return error(errno)
+	if libc_ioctl(int32(s), int32(ioc), arg) < 0 {
+		return syscall.GetErrno()
 	}
 	return nil
 }
diff --git a/libgo/go/golang.org/x/net/lif/zsys_solaris.go b/libgo/go/golang.org/x/net/lif/zsys_solaris.go
new file mode 100644
--- /dev/null
+++ b/libgo/go/golang.org/x/net/lif/zsys_solaris.go
@@ -0,0 +1,101 @@
+// Created by cgo -godefs - DO NOT EDIT
+// cgo -godefs defs_solaris.go
+
+package lif
+
+import "unsafe"
+
+const (
+	sysAF_UNSPEC = 0x0
+	sysAF_INET   = 0x2
+	sysAF_INET6  = 0x1a
+
+	sysSOCK_DGRAM = 0x1
+)
+
+type sockaddrStorage struct {
+	Family     uint16
+	X_ss_pad1  [6]int8
+	X_ss_align float64
+	X_ss_pad2  [240]int8
+}
+
+const (
+	sysLIFC_NOXMIT          = 0x1
+	sysLIFC_EXTERNAL_SOURCE = 0x2
+	sysLIFC_TEMPORARY       = 0x4
+	sysLIFC_ALLZONES        = 0x8
+	sysLIFC_UNDER_IPMP      = 0x10
+	sysLIFC_ENABLED         = 0x20
+
+	sysSIOCGLIFADDR    = -0x3f87968f
+	sysSIOCGLIFDSTADDR = -0x3f87968d
+	sysSIOCGLIFFLAGS   = -0x3f87968b
+	sysSIOCGLIFMTU     = -0x3f879686
+	sysSIOCGLIFNETMASK = -0x3f879683
+	sysSIOCGLIFMETRIC  = -0x3f879681
+	sysSIOCGLIFNUM     = -0x3ff3967e
+	sysSIOCGLIFINDEX   = -0x3f87967b
+	sysSIOCGLIFSUBNET  = -0x3f879676
+	sysSIOCGLIFLNKINFO = -0x3f879674
+	sysSIOCGLIFCONF    = -0x3fef965b
+	sysSIOCGLIFHWADDR  = -0x3f879640
+)
+
+const (
+	sysIFF_UP          = 0x1
+	sysIFF_BROADCAST   = 0x2
+	sysIFF_DEBUG       = 0x4
+	sysIFF_LOOPBACK    = 0x8
+	sysIFF_POINTOPOINT = 0x10
+	sysIFF_NOTRAILERS  = 0x20
+	sysIFF_RUNNING     = 0x40
+	sysIFF_NOARP       = 0x80
+	sysIFF_PROMISC     = 0x100
+	sysIFF_ALLMULTI    = 0x200
+	sysIFF_INTELLIGENT = 0x400
+	sysIFF_MULTICAST   = 0x800
+	sysIFF_MULTI_BCAST = 0x1000
+	sysIFF_UNNUMBERED  = 0x2000
+	sysIFF_PRIVATE     = 0x8000
+)
+
+const (
+	sizeofLifnum       = 0xc
+	sizeofLifreq       = 0x178
+	sizeofLifconf      = 0x18
+	sizeofLifIfinfoReq = 0x10
+)
+
+type lifnum struct {
+	Family    uint16
+	Flags     int32
+	Count     int32
+}
+
+type lifreq struct {
+	Name   [32]int8
+	Lifru1 [4]byte
+	Type   uint32
+	Lifru  [336]byte
+}
+
+type lifconf struct {
+	Family    uint16
+	Flags     int32
+	Len       int32
+	Lifcu     [unsafe.Sizeof(unsafe.Pointer(nil))]byte
+}
+
+type lifIfinfoReq struct {
+	Maxhops      uint8
+	Reachtime    uint32
+	Reachretrans uint32
+	Maxmtu       uint32
+}
+
+const (
+	sysIFT_IPV4 = 0xc8
+	sysIFT_IPV6 = 0xc9
+	sysIFT_6TO4 = 0xca
+)
diff --git a/libgo/go/golang.org/x/net/lif/zsys_solaris_amd64.go b/libgo/go/golang.org/x/net/lif/zsys_solaris_amd64.go
deleted file mode 100644
--- a/libgo/go/golang.org/x/net/lif/zsys_solaris_amd64.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs defs_solaris.go
-
-package lif
-
-const (
-	sysAF_UNSPEC = 0x0
-	sysAF_INET   = 0x2
-	sysAF_INET6  = 0x1a
-
-	sysSOCK_DGRAM = 0x1
-)
-
-type sockaddrStorage struct {
-	Family     uint16
-	X_ss_pad1  [6]int8
-	X_ss_align float64
-	X_ss_pad2  [240]int8
-}
-
-const (
-	sysLIFC_NOXMIT          = 0x1
-	sysLIFC_EXTERNAL_SOURCE = 0x2
-	sysLIFC_TEMPORARY       = 0x4
-	sysLIFC_ALLZONES        = 0x8
-	sysLIFC_UNDER_IPMP      = 0x10
-	sysLIFC_ENABLED         = 0x20
-
-	sysSIOCGLIFADDR    = -0x3f87968f
-	sysSIOCGLIFDSTADDR = -0x3f87968d
-	sysSIOCGLIFFLAGS   = -0x3f87968b
-	sysSIOCGLIFMTU     = -0x3f879686
-	sysSIOCGLIFNETMASK = -0x3f879683
-	sysSIOCGLIFMETRIC  = -0x3f879681
-	sysSIOCGLIFNUM     = -0x3ff3967e
-	sysSIOCGLIFINDEX   = -0x3f87967b
-	sysSIOCGLIFSUBNET  = -0x3f879676
-	sysSIOCGLIFLNKINFO = -0x3f879674
-	sysSIOCGLIFCONF    = -0x3fef965b
-	sysSIOCGLIFHWADDR  = -0x3f879640
-)
-
-const (
-	sysIFF_UP          = 0x1
-	sysIFF_BROADCAST   = 0x2
-	sysIFF_DEBUG       = 0x4
-	sysIFF_LOOPBACK    = 0x8
-	sysIFF_POINTOPOINT = 0x10
-	sysIFF_NOTRAILERS  = 0x20
-	sysIFF_RUNNING     = 0x40
-	sysIFF_NOARP       = 0x80
-	sysIFF_PROMISC     = 0x100
-	sysIFF_ALLMULTI    = 0x200
-	sysIFF_INTELLIGENT = 0x400
-	sysIFF_MULTICAST   = 0x800
-	sysIFF_MULTI_BCAST = 0x1000
-	sysIFF_UNNUMBERED  = 0x2000
-	sysIFF_PRIVATE     = 0x8000
-)
-
-const (
-	sizeofLifnum       = 0xc
-	sizeofLifreq       = 0x178
-	sizeofLifconf      = 0x18
-	sizeofLifIfinfoReq = 0x10
-)
-
-type lifnum struct {
-	Family    uint16
-	Pad_cgo_0 [2]byte
-	Flags     int32
-	Count     int32
-}
-
-type lifreq struct {
-	Name   [32]int8
-	Lifru1 [4]byte
-	Type   uint32
-	Lifru  [336]byte
-}
-
-type lifconf struct {
-	Family    uint16
-	Pad_cgo_0 [2]byte
-	Flags     int32
-	Len       int32
-	Pad_cgo_1 [4]byte
-	Lifcu     [8]byte
-}
-
-type lifIfinfoReq struct {
-	Maxhops      uint8
-	Pad_cgo_0    [3]byte
-	Reachtime    uint32
-	Reachretrans uint32
-	Maxmtu       uint32
-}
-
-const (
-	sysIFT_IPV4 = 0xc8
-	sysIFT_IPV6 = 0xc9
-	sysIFT_6TO4 = 0xca
-)
diff --git a/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.c b/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.c
--- a/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.c
+++ b/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.c
@@ -3,7 +3,9 @@
 // license that can be found in the LICENSE file.
 
 // +build 386 amd64 amd64p32
-// +build gccgo
+// +build gccgo,386 gccgo,amd64
+
+#if defined(__i386__) || defined(__x86_64__)
 
 #include <cpuid.h>
 #include <stdint.h>
@@ -41,3 +43,5 @@ gccgoXgetbv(uint32_t *eax, uint32_t *edx
 	      "  xgetbv"
 	    : "=a"(*eax), "=d"(*edx));
 }
+
+#endif /* defined(__i386__) || defined(__x86_64__)  */
diff --git a/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.go b/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.go
--- a/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.go
+++ b/libgo/go/golang.org/x/sys/cpu/cpu_gccgo.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build 386 amd64 amd64p32
-// +build gccgo
+// +build gccgo,386 gccgo,amd64
 
 package cpu
 
diff --git a/libgo/go/golang.org/x/sys/cpu/cpu_sparcx.go b/libgo/go/golang.org/x/sys/cpu/cpu_sparcx.go
new file mode 100644
--- /dev/null
+++ b/libgo/go/golang.org/x/sys/cpu/cpu_sparcx.go
@@ -0,0 +1,12 @@
+// Copyright 2019 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.
+
+// +build sparc sparc64
+
+package cpu
+
+// FIXME: Check.
+const cacheLineSize = 32
+
+func doinit() {}
diff --git a/libgo/go/runtime/os_solaris.go b/libgo/go/runtime/os_solaris.go
--- a/libgo/go/runtime/os_solaris.go
+++ b/libgo/go/runtime/os_solaris.go
@@ -31,7 +31,7 @@ func sem_reltimedwait_np(sem *semt, time
 
 //go:nosplit
 func semacreate(mp *m) {
-	if mp.mos.waitsema != 0 {
+	if mp.waitsema != 0 {
 		return
 	}
 
@@ -44,7 +44,7 @@ func semacreate(mp *m) {
 	if sem_init(sem, 0, 0) != 0 {
 		throw("sem_init")
 	}
-	mp.mos.waitsema = uintptr(unsafe.Pointer(sem))
+	mp.waitsema = uintptr(unsafe.Pointer(sem))
 }
 
 //go:nosplit
@@ -54,7 +54,7 @@ func semasleep(ns int64) int32 {
 		var ts timespec
 		ts.setNsec(ns)
 
-		if sem_reltimedwait_np((*semt)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 {
+		if sem_reltimedwait_np((*semt)(unsafe.Pointer(_m_.waitsema)), &ts) != 0 {
 			err := errno()
 			if err == _ETIMEDOUT || err == _EAGAIN || err == _EINTR {
 				return -1
@@ -64,7 +64,7 @@ func semasleep(ns int64) int32 {
 		return 0
 	}
 	for {
-		r1 := sem_wait((*semt)(unsafe.Pointer(_m_.mos.waitsema)))
+		r1 := sem_wait((*semt)(unsafe.Pointer(_m_.waitsema)))
 		if r1 == 0 {
 			break
 		}
@@ -78,7 +78,7 @@ func semasleep(ns int64) int32 {
 
 //go:nosplit
 func semawakeup(mp *m) {
-	if sem_post((*semt)(unsafe.Pointer(mp.mos.waitsema))) != 0 {
+	if sem_post((*semt)(unsafe.Pointer(mp.waitsema))) != 0 {
 		throw("sem_post")
 	}
 }

Reply via email to