Current 7 branch doesn't build against recent glibc, not just because of libsanitizer issues tracked in another PR, but also due to: ../../../../libgo/go/syscall/syscall_linux_s390.go:16:16: error: reference to undefined name ‘PTRACE_GETREGS’ return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) ^ ../../../../libgo/go/syscall/syscall_linux_s390.go:20:16: error: reference to undefined name ‘PTRACE_SETREGS’ return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) ^ make[6]: *** [Makefile:3331: syscall.lo] Error 1 This is because glibc has removed those in: https://sourceware.org/bugzilla/show_bug.cgi?id=21539 claiming the kernel never supported them and it never worked. Thus, I think syscall_linux_s390{,x}.go should probably use PTRACE_GETREGSET and PTRACE_SETREGSET instead. Elsewhere I found static long our_ptrace_getregs(pid_t pid, struct USER_REGS_TYPE *regs) { #ifdef AARCH64 struct iovec iovec = { regs, sizeof(*regs) }; return our_ptrace(PTRACE_GETREGSET, pid, (void *)NT_PRSTATUS, &iovec); #else return our_ptrace(PTRACE_GETREGS, pid, NULL, regs); #endif } static long our_ptrace_setregs(pid_t pid, struct USER_REGS_TYPE *regs) { #ifdef AARCH64 struct iovec iovec = { regs, sizeof(*regs) }; return our_ptrace(PTRACE_SETREGSET, pid, (void *)NT_PRSTATUS, &iovec); #else return our_ptrace(PTRACE_SETREGS, pid, NULL, regs); #endif } where aarch64 doesn't support PTRACE_SETREGS/GETREGS similarly to s390{,x} (though for some reason doesn't provide any syscall_linux_{arm64,aarch64}.go or whatever). In sysinfo.go I see PTRACE_{G,S}ETREGSET defined, but not NT_PRSTATUS (which is 1, in elf.h?), and I see _iovec type.
Created attachment 41716 [details] Experimental patch The patch I'm currently testing
Created attachment 41717 [details] Tested Patch I had to add typecasts also for the 64 bit code.
Author: ian Date: Thu Jul 13 03:44:14 2017 New Revision: 250174 URL: https://gcc.gnu.org/viewcvs?rev=250174&root=gcc&view=rev Log: PR go/81393 syscall: don't use GETREGS/SETREGS on s390 They were removed in recent glibc. Patch by Andreas Krebbel for GCC PR 81393. Reviewed-on: https://go-review.googlesource.com/48231 Modified: trunk/gcc/go/gofrontend/MERGE trunk/libgo/go/syscall/syscall_linux_s390.go trunk/libgo/go/syscall/syscall_linux_s390x.go
Should be fixed.
Only on the trunk. Could you please backport it to release branches as well? I think all of gcc 7, 6 and 5 are affected by this.
Note that the patch doesn't apply cleanly (capital vs. lowercase letter of some field), and depends on r249472, r249662 and r250324.
Oh, and r249712.
And r249663. Perhaps it would be better for the release branches to just define the ptrace_area type in the *.go files like syscall_linux_alpha.go used to.
Created attachment 41791 [details] Possible patch I agree that the simplest approach is to not try to pick up the definitions from the header files for the older branches, but to just write them directly. I don't have a way to test a patch; can you see if this one works?
https://kojipkgs.fedoraproject.org//work/tasks/6506/20616506/build.log That fails to build: ../../../../libgo/go/syscall/syscall_linux_s390.go:28:33: error: reference to undefined name 'regs' uint32(uintptr(unsafe.Pointer(regs))), ^ make[8]: Leaving directory '/builddir/build/BUILD/gcc-7.1.1-20170718/obj-s390x-redhat-linux/s390x-redhat-linux/32/libgo' make[8]: *** [Makefile:3331: syscall.lo] Error 1 make[7]: *** [Makefile:2746: all-recursive] Error 1 Guess the each first uint32(uintptr(unsafe.Pointer(regs))) line should be actually uint32(uintptr(unsafe.Pointer(regsout)))
Created attachment 41793 [details] Possible patch Sorry about that, updated patch.
That is better, syscall_linux_s390.go already compiles, but syscall_linux_s390x.go still doesn't: ../../../libgo/go/syscall/syscall_linux_s390x.go:28:3: error: incompatible type for field 3 in struct construction (cannot use type uint32 as type uint64) uint32(uintptr(unsafe.Pointer(regs))), ^ ../../../libgo/go/syscall/syscall_linux_s390x.go:37:3: error: incompatible type for field 3 in struct construction (cannot use type uint32 as type uint64) uint32(uintptr(unsafe.Pointer(regs))), ^ Those s390x two occurrences of uint32(uintptr(unsafe.Pointer(regs))) really should be uint64(uintptr(unsafe.Pointer(regs))). Let me test that now.
(In reply to Jakub Jelinek from comment #12) > That is better, syscall_linux_s390.go already compiles, but > syscall_linux_s390x.go still doesn't: > ../../../libgo/go/syscall/syscall_linux_s390x.go:28:3: error: incompatible > type for field 3 in struct construction (cannot use type uint32 as type > uint64) > uint32(uintptr(unsafe.Pointer(regs))), > ^ > ../../../libgo/go/syscall/syscall_linux_s390x.go:37:3: error: incompatible > type for field 3 in struct construction (cannot use type uint32 as type > uint64) > uint32(uintptr(unsafe.Pointer(regs))), > ^ > Those s390x two occurrences of uint32(uintptr(unsafe.Pointer(regs))) really > should be uint64(uintptr(unsafe.Pointer(regs))). Let me test that now. With that change it passed bootstrap/regtest on s390x-linux.
Thanks. Do you want to commit or should I do it?
You wrote it, so go ahead ;).
Author: ian Date: Thu Jul 20 22:03:26 2017 New Revision: 250402 URL: https://gcc.gnu.org/viewcvs?rev=250402&root=gcc&view=rev Log: PR go/81393 syscall: don't use GETREGS/SETREGS on s390 They were removed in recent glibc. This is a backport of https://golang.org/cl/48231 to earlier branches. Define required type and constants in syscall package directly, don't try to pull them from the system header files. Modified: branches/gcc-7-branch/libgo/go/syscall/syscall_linux_s390.go branches/gcc-7-branch/libgo/go/syscall/syscall_linux_s390x.go
Author: ian Date: Thu Jul 20 22:03:48 2017 New Revision: 250403 URL: https://gcc.gnu.org/viewcvs?rev=250403&root=gcc&view=rev Log: PR go/81393 syscall: don't use GETREGS/SETREGS on s390 They were removed in recent glibc. This is a backport of https://golang.org/cl/48231 to earlier branches. Define required type and constants in syscall package directly, don't try to pull them from the system header files. Modified: branches/gcc-6-branch/libgo/go/syscall/syscall_linux_s390.go branches/gcc-6-branch/libgo/go/syscall/syscall_linux_s390x.go
Author: ian Date: Thu Jul 20 22:04:02 2017 New Revision: 250404 URL: https://gcc.gnu.org/viewcvs?rev=250404&root=gcc&view=rev Log: PR go/81393 syscall: don't use GETREGS/SETREGS on s390 They were removed in recent glibc. This is a backport of https://golang.org/cl/48231 to earlier branches. Define required type and constants in syscall package directly, don't try to pull them from the system header files. Modified: branches/gcc-5-branch/libgo/go/syscall/syscall_linux_s390.go branches/gcc-5-branch/libgo/go/syscall/syscall_linux_s390x.go
Should be fixed everywhere, I hope.