On Fri, Aug 13, 2021 at 2:08 PM Rainer Orth <r...@cebitec.uni-bielefeld.de> wrote: > > unfortunately, things are considerably worse: syscall.lo fails to build > and go1 even ICEs: > > /vol/gcc/src/hg/master/local/libgo/go/syscall/libcall_posix_utimesnano.go:13:1: > error: redefinition of ‘UtimesNano’ > 13 | func UtimesNano(path string, ts []Timespec) error { > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/libcall_linux_utimesnano.go:13:1: > note: previous definition of ‘UtimesNano’ was here > 13 | func UtimesNano(path string, ts []Timespec) (err error) { > | ^ > > The second file is Linux-only and needs a corresponding build guard. > > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:193:16: error: use > of undefined type ‘SysProcAttr’ > 193 | Sys *SysProcAttr > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:235:15: error: > reference to field ‘Chroot’ in object which has no fields or methods > 235 | if sys.Chroot != "" { > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:236:52: error: > reference to field ‘Chroot’ in object which has no fields or methods > 236 | chroot, err = BytePtrFromString(sys.Chroot) > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:251:15: error: > reference to field ‘Setctty’ in object which has no fields or methods > 251 | if sys.Setctty && sys.Foreground { > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:251:30: error: > reference to field ‘Foreground’ in object which has no fields or methods > 251 | if sys.Setctty && sys.Foreground { > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:254:15: error: > reference to field ‘Setctty’ in object which has no fields or methods > 254 | if sys.Setctty && sys.Ctty >= len(attr.Files) { > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:254:30: error: > reference to field ‘Ctty’ in object which has no fields or methods > 254 | if sys.Setctty && sys.Ctty >= len(attr.Files) { > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_unix.go:269:21: error: > reference to undefined name ‘forkAndExecInChild’ > 269 | pid, err1 = forkAndExecInChild(argv0p, argvp, envvp, chroot, > dir, attr, sys, p[1]) > | ^ > > I found that upstream has exec_libc.go for AIX and Solaris with the > missing SysProcAttr and forkAndExecInChild definitions. It doesn't work > out of the box, though: > > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:63:9: error: > reference to undefined name ‘execveLibc’ > 63 | execveLibc = execve > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:137:25: error: > reference to undefined name ‘_Pid_t’ > 137 | pgrp := _Pid_t(sys.Pgid) > | ^ > /vol/gcc/src/hg/master/local/libgo/go/syscall/exec_libc.go:144:32: error: > reference to undefined name ‘_Pid_t’ > 144 | pgrp = _Pid_t(r1) > | ^ > > For one, switching to Pid_t is needed: > > > Besides, support for execveLibc has been dropped in exec_unix.go > compared to upstream. > > terminate called after throwing an instance of 'std::out_of_range' > what(): vector::_M_range_check: __n (which is 1) >= this->size() (which is > 1) > go1: internal compiler error: Abort > 0xce1abf crash_signal > /vol/gcc/src/hg/master/local/gcc/toplev.c:328 > > This went away after the fixes above. > > Next, I get > > /vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:10:15: > error: imported and not used: unsafe > 10 | "unsafe" > | ^ > /vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:32:30: > error: reference to undefined name 'getrandomUnsupported' > 32 | if atomic.LoadInt32(&getrandomUnsupported) != 0 { > | ^ > /vol/gcc/src/hg/master/local/libgo/go/internal/syscall/unix/getrandom_solaris.go:41:44: > error: reference to undefined name 'getrandomUnsupported' > 41 | atomic.StoreInt32(&getrandomUnsupported, 1) > | ^ > make[4]: *** [Makefile:3008: internal/syscall/unix.lo] Error 1 > > The definition dropped compared to upstream. > > /vol/gcc/src/hg/master/local/libgo/go/os/user/listgroups_unix.go:39:15: > error: reference to undefined name ‘libc_getgrouplist’ > 39 | rv := libc_getgrouplist(nameC, userGID, &gidsC[0], &n) > | ^ > /vol/gcc/src/hg/master/local/libgo/go/os/user/listgroups_unix.go:49:23: > error: reference to undefined name ‘libc_getgrouplist’ > 49 | rv := libc_getgrouplist(nameC, userGID, &gidsC[0], &n) > | ^ > make[6]: *** [Makefile:3008: os/user.lo] Error 1 > > I've added it to decls_solaris.go. > > With those changes, libgo compiles and links. Unfortunately, every > executable fails to link now: > > Undefined first referenced > symbol in file > syscall.setpgid > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.chroot1 > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.getpid > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.fcntl1 > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.execve > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.setgid > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.setsid > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.setuid > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.exit > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.write1 > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.chdir > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.close > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.forkx > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.ioctl > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.dup2child > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > syscall.setgroups1 > ../i386-pc-solaris2.11/libgo/.libs/libgo.so > ld: fatal: symbol referencing errors > collect2: error: ld returned 1 exit status > > They are declared in go/syscall/exec_libc.go, but I don't see the best > way to handle this. I'm calling it a night now.
I committed this path that should fix these problems. Ian
a9cc8b18a7ebe76592f0db69d2c30a73a57c2cf5 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3000285fbf0..950f1797b55 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -f2b7a2ce94127ad444a772bd1631516c5c67fb73 +77bc32767b61feb6499ca7921e96b356603517dc 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/syscall/unix/getrandom_solaris.go b/libgo/go/internal/syscall/unix/getrandom_solaris.go index caf9b60d036..9d0f0944e18 100644 --- a/libgo/go/internal/syscall/unix/getrandom_solaris.go +++ b/libgo/go/internal/syscall/unix/getrandom_solaris.go @@ -7,12 +7,13 @@ package unix import ( "sync/atomic" "syscall" - "unsafe" ) //extern getrandom func libc_getrandom(*byte, uintptr, uint32) uintptr +var getrandomUnsupported int32 // atomic + // GetRandomFlag is a flag supported by the getrandom system call. type GetRandomFlag uintptr diff --git a/libgo/go/os/user/decls_solaris.go b/libgo/go/os/user/decls_solaris.go index ccdf36b13d6..43b6a044047 100644 --- a/libgo/go/os/user/decls_solaris.go +++ b/libgo/go/os/user/decls_solaris.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. -// +build solaris -// +build cgo +//go:build solaris && cgo +// +build solaris,cgo package user @@ -22,3 +22,6 @@ func libc_getgrnam_r(name *byte, grp *syscall.Group, buf *byte, buflen syscall.S //extern __posix_getgrgid_r func libc_getgrgid_r(gid syscall.Gid_t, grp *syscall.Group, buf *byte, buflen syscall.Size_t, result **syscall.Group) int + +//extern getgrouplist +func libc_getgrouplist(user *byte, group syscall.Gid_t, groups *syscall.Gid_t, ngroups *int32) int diff --git a/libgo/go/runtime/crash_test.go b/libgo/go/runtime/crash_test.go index 15c60008dbf..e3633af7ccf 100644 --- a/libgo/go/runtime/crash_test.go +++ b/libgo/go/runtime/crash_test.go @@ -744,6 +744,10 @@ func TestTimePprof(t *testing.T) { // Test that runtime.abort does so. func TestAbort(t *testing.T) { + if runtime.Compiler == "gccgo" && runtime.GOOS == "solaris" { + t.Skip("not supported by gofrontend on Solaris") + } + // Pass GOTRACEBACK to ensure we get runtime frames. output := runTestProg(t, "testprog", "Abort", "GOTRACEBACK=system") if want := "runtime.abort"; !strings.Contains(output, want) { @@ -805,6 +809,10 @@ func TestRuntimePanic(t *testing.T) { // Test that g0 stack overflows are handled gracefully. func TestG0StackOverflow(t *testing.T) { + if runtime.Compiler == "gccgo" { + t.Skip("g0 stack overflow not supported by gofrontend") + } + testenv.MustHaveExec(t) switch runtime.GOOS { diff --git a/libgo/go/syscall/exec_bsd.go b/libgo/go/syscall/exec_bsd.go index a081c096fea..ad65f63c57b 100644 --- a/libgo/go/syscall/exec_bsd.go +++ b/libgo/go/syscall/exec_bsd.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 dragonfly || freebsd || hurd || netbsd || (openbsd && mips64) -// +build dragonfly freebsd hurd netbsd openbsd,mips64 +//go:build aix || darwin || dragonfly || freebsd || hurd || netbsd || openbsd || solaris +// +build aix darwin dragonfly freebsd hurd netbsd openbsd solaris package syscall diff --git a/libgo/go/syscall/exec_unix_test.go b/libgo/go/syscall/exec_unix_test.go index 85957225692..3b78d20db99 100644 --- a/libgo/go/syscall/exec_unix_test.go +++ b/libgo/go/syscall/exec_unix_test.go @@ -180,7 +180,7 @@ func TestForeground(t *testing.T) { fpgrp := syscall.Pid_t(0) - errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp))) + errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, unsafe.Pointer(&fpgrp)) if errno != 0 { t.Fatalf("TIOCGPGRP failed with error code: %s", errno) } @@ -217,7 +217,7 @@ func TestForeground(t *testing.T) { // This call fails on darwin/arm64. The failure doesn't matter, though. // This is just best effort. - syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp))) + syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, unsafe.Pointer(&fpgrp)) } func TestForegroundSignal(t *testing.T) { @@ -231,7 +231,7 @@ func TestForegroundSignal(t *testing.T) { // equivalent. fpgrp := int32(0) - errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp))) + errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, unsafe.Pointer(&fpgrp)) if errno != 0 { t.Fatalf("TIOCGPGRP failed with error code: %s", errno) } @@ -242,7 +242,7 @@ func TestForegroundSignal(t *testing.T) { defer func() { signal.Ignore(syscall.SIGTTIN, syscall.SIGTTOU) - syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp))) + syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, unsafe.Pointer(&fpgrp)) signal.Reset() }() diff --git a/libgo/go/syscall/export_aix_test.go b/libgo/go/syscall/export_aix_test.go index 044337b9993..7ea5864a66d 100644 --- a/libgo/go/syscall/export_aix_test.go +++ b/libgo/go/syscall/export_aix_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix // +build aix package syscall @@ -10,7 +11,7 @@ import ( "unsafe" ) -func Ioctl(fd, req, arg uintptr) (err Errno) { - _, err = raw_ioctl_ptr(int(fd), req, unsafe.Pointer(arg)) +func Ioctl(fd, req uintptr, arg unsafe.Pointer) (err Errno) { + _, err = raw_ioctl_ptr(int(fd), req, arg) return err } diff --git a/libgo/go/syscall/export_unix_test.go b/libgo/go/syscall/export_unix_test.go index b051e368d4f..f32118b519d 100644 --- a/libgo/go/syscall/export_unix_test.go +++ b/libgo/go/syscall/export_unix_test.go @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build dragonfly || freebsd || hurd || linux || netbsd || openbsd -// +build dragonfly freebsd hurd linux netbsd openbsd +//go:build dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris +// +build dragonfly freebsd hurd linux netbsd openbsd solaris package syscall -func Ioctl(fd, req, arg uintptr) (err Errno) { - _, _, err = Syscall(SYS_IOCTL, fd, req, arg) +import "unsafe" + +func Ioctl(fd, req uintptr, arg unsafe.Pointer) (err Errno) { + _, err = raw_ioctl_ptr(int(fd), req, arg) return err } diff --git a/libgo/go/syscall/libcall_linux_utimesnano.go b/libgo/go/syscall/libcall_linux_utimesnano.go index 90da2ae04e5..582833812f6 100644 --- a/libgo/go/syscall/libcall_linux_utimesnano.go +++ b/libgo/go/syscall/libcall_linux_utimesnano.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux +// +build linux + // GNU/Linux version of UtimesNano. package syscall diff --git a/libgo/mkruntimeinc.sh b/libgo/mkruntimeinc.sh index dbe44d99175..61d830af876 100755 --- a/libgo/mkruntimeinc.sh +++ b/libgo/mkruntimeinc.sh @@ -19,7 +19,7 @@ rm -f runtime.inc.tmp2 runtime.inc.tmp3 # boundsError has a field name that is a C keyword, and we don't need it. # mSpanInuse is both a constant and a field name, and we don't need it. -grep -v "#define _" ${IN} | grep -v "#define [cm][01234] " | grep -v "#define empty " | grep -v "#define \\$" | grep -v "#define mSpanInUse " > runtime.inc.tmp2 +grep -v "#define _" ${IN} | grep -v "#define [cm][012345] " | grep -v "#define empty " | grep -v "#define \\$" | grep -v "#define mSpanInUse " > runtime.inc.tmp2 for pattern in '_[GP][a-z]' _Max _Lock _Sig _Trace _MHeap _Num do grep "#define $pattern" ${IN} >> runtime.inc.tmp2