retitle 1005297 gcc-12-12-29229214: FTBFS on hurd-i386 thanks On Thu, 2022-02-10 at 19:34 +0100, Svante Signell wrote: > Source: gcc-12 > Version: 12_12-20220206-1 > Severity: important > Tags: patch > User: debian-h...@lists.debian.org > Usertags: hurd
Hi again, Attached are patches to successfully build gcc-12-12-20220214-1 from source: debian_rules.patch.patch: Adds hurd-specific patches to to debian/rules.patch. gcc_config_gnu.h.diff: Re-enables split-stack support. The patches below are needed for a successful build of libgo.so.21.0.0: libgo_go_net_unixsock_readmsg_cloexec.go.diff libgo_go_runtime_netpoll_hurd.go.diff libgo_go_runtime_os_hurd.go.diff libgo_go_syscall_exec_bsd.go.diff libgo_go_syscall_exec_hurd.go.diff libgo_go_os_user_cgo_listgroups_unix.go.diff libgo_go_os_user_getgrouplist_unix.go.diff libgo_go_internal_testenv_testenv_unix.go.diff libgo_go_os_exec_internal_fdtest_exists_unix.go.diff Makefile.in.diff: This patch is modified from the upstream patch src_Makefile.in.diff since the Debian-specific patch gm2.diff makes changes to src/Makefile.in before Makefile.in.diff is applied. All patches have been submitted upstream in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104290 The patch, libgo_go_net_unixsock_readmsg_cloexec.go.diff, has already been committed upstream by Ian. Thanks!
--- a/debian/rules.patch 2022-02-15 23:07:04.000000000 +0100 +++ b/debian/rules.patch 2022-02-15 23:14:51.000000000 +0100 @@ -192,6 +192,17 @@ ifeq ($(DEB_TARGET_ARCH_OS),hurd) debian_patches += hurd-changes + debian_patches += gcc_config_gnu.h + debian_patches += libgo_go_net_unixsock_readmsg_cloexec.go + debian_patches += libgo_go_runtime_netpoll_hurd.go + debian_patches += libgo_go_runtime_os_hurd.go + debian_patches += libgo_go_syscall_exec_bsd.go + debian_patches += libgo_go_syscall_exec_hurd.go + debian_patches += libgo_go_os_user_cgo_listgroups_unix.go + debian_patches += libgo_go_os_user_getgrouplist_unix.go + debian_patches += libgo_go_internal_testenv_testenv_unix.go + debian_patches += libgo_go_os_exec_internal_fdtest_exists_unix.go + debian-patches += Makefile.in endif debian_patches += gcc-ice-dump
--- a/src/gcc/config/gnu.h 2022-02-06 11:59:41.000000000 +0100 +++ b/src/gcc/config/gnu.h 2022-02-06 12:00:19.000000000 +0100 @@ -19,6 +19,9 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>. */ +#define OPTION_GLIBC_P(opts) (DEFAULT_LIBC == LIBC_GLIBC) +#define OPTION_GLIBC OPTION_GLIBC_P (&global_options) + #undef GNU_USER_TARGET_OS_CPP_BUILTINS #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ do { \
--- a/src/libgo/go/internal/testenv/testenv_unix.go 2022-02-14 03:23:21.000000000 +0100 +++ b/src/libgo/go/internal/testenv/testenv_unix.go 2022-02-15 13:06:16.000000000 +0100 @@ -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 aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris +//go:build aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris package testenv
--- a/src/libgo/go/net/unixsock_readmsg_cloexec.go 2022-02-15 00:27:45.000000000 +0100 +++ b/src/libgo/go/net/unixsock_readmsg_cloexec.go 2022-02-15 00:29:01.000000000 +0100 @@ -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 aix || darwin || freebsd || solaris +//go:build aix || darwin || freebsd || hurd || solaris package net
--- a/src/libgo/go/os/exec/internal/fdtest/exists_unix.go 2022-02-14 03:23:21.000000000 +0100 +++ b/src/libgo/go/os/exec/internal/fdtest/exists_unix.go 2022-02-15 13:38:42.000000000 +0100 @@ -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 aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris +//go:build aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris // Package fdtest provides test helpers for working with file descriptors across exec. package fdtest
--- a/src/libgo/go/os/user/cgo_listgroups_unix.go 2022-02-14 03:23:22.000000000 +0100 +++ b/src/libgo/go/os/user/cgo_listgroups_unix.go 2022-02-15 12:13:35.000000000 +0100 @@ -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 (dragonfly || darwin || freebsd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo +//go:build (dragonfly || darwin || freebsd || hurd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo package user
--- a/src/libgo/go/os/user/getgrouplist_unix.go 2022-02-14 03:23:22.000000000 +0100 +++ b/src/libgo/go/os/user/getgrouplist_unix.go 2022-02-15 12:17:12.000000000 +0100 @@ -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 (dragonfly || freebsd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo +//go:build (dragonfly || freebsd || hurd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo package user
--- a/src/libgo/go/runtime/netpoll_hurd.go 2020-10-20 15:26:29.000000000 +0200 +++ b/src/libgo/go/runtime/netpoll_hurd.go 2022-02-15 10:28:56.000000000 +0100 @@ -238,10 +238,7 @@ pfd.events &= ^_POLLOUT } if mode != 0 { - pds[i].everr = false - if pfd.revents == _POLLERR { - pds[i].everr = true - } + pds[i].setEventErr(pfd.revents == _POLLERR) netpollready(&toRun, pds[i], mode) n-- }
--- a/src/libgo/go/runtime/os_hurd.go 2022-02-15 10:42:15.000000000 +0100 +++ b/src/libgo/go/runtime/os_hurd.go 2022-02-15 10:40:21.000000000 +0100 @@ -129,3 +129,16 @@ physPageSize = uintptr(getPageSize()) } } + +func setProcessCPUProfiler(hz int32) { + setProcessCPUProfilerTimer(hz) +} + +func setThreadCPUProfiler(hz int32) { + setThreadCPUProfilerHz(hz) +} + +//go:nosplit +func validSIGPROF(mp *m, c *sigctxt) bool { + return true +}
--- a/src/libgo/go/syscall/exec_bsd.go 2022-02-14 03:23:22.000000000 +0100 +++ b/src/libgo/go/syscall/exec_bsd.go 2022-02-15 11:36:32.000000000 +0100 @@ -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 aix || darwin || dragonfly || hurd || netbsd || openbsd || solaris +//go:build aix || darwin || dragonfly || netbsd || openbsd || solaris package syscall
--- /dev/null 2022-02-15 11:30:22.000000000 +0100 +++ b/src/libgo/go/syscall/exec_hurd.go 2022-02-15 11:42:28.000000000 +0100 @@ -0,0 +1,278 @@ +// Copyright 2011 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. + +//go:build hurd + +package syscall + +import ( + "runtime" + "unsafe" +) + +type SysProcAttr struct { + Chroot string // Chroot. + Credential *Credential // Credential. + Ptrace bool // Enable tracing. + Setsid bool // Create session. + // Setpgid sets the process group ID of the child to Pgid, + // or, if Pgid == 0, to the new child's process ID. + Setpgid bool + // Setctty sets the controlling terminal of the child to + // file descriptor Ctty. Ctty must be a descriptor number + // in the child process: an index into ProcAttr.Files. + // This is only meaningful if Setsid is true. + Setctty bool + Noctty bool // Detach fd 0 from controlling terminal + Ctty int // Controlling TTY fd + // Foreground places the child process group in the foreground. + // This implies Setpgid. The Ctty field must be set to + // the descriptor of the controlling TTY. + // Unlike Setctty, in this case Ctty must be a descriptor + // number in the parent process. + Foreground bool + Pgid int // Child's process group ID if Setpgid. +} + +// Implemented in runtime package. +func runtime_BeforeFork() +func runtime_AfterFork() +func runtime_AfterForkInChild() + +// Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child. +// If a dup or exec fails, write the errno error to pipe. +// (Pipe is close-on-exec so if exec succeeds, it will be closed.) +// In the child, this function must not acquire any locks, because +// they might have been locked at the time of the fork. This means +// no rescheduling, no malloc calls, and no new stack segments. +// For the same reason compiler does not race instrument it. +// The calls to RawSyscall are okay because they are assembly +// functions that do not grow the stack. +//go:norace +func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) { + // Declare all variables at top in case any + // declarations require heap allocation (e.g., err1). + var ( + r1 Pid_t + err1 Errno + nextfd int + i int + ) + + // guard against side effects of shuffling fds below. + // Make sure that nextfd is beyond any currently open files so + // that we can't run the risk of overwriting any of them. + fd := make([]int, len(attr.Files)) + nextfd = len(attr.Files) + for i, ufd := range attr.Files { + if nextfd < int(ufd) { + nextfd = int(ufd) + } + fd[i] = int(ufd) + } + nextfd++ + + // About to call fork. + // No more allocation or calls of non-assembly functions. + runtime_BeforeFork() + r1, err1 = raw_fork() + if err1 != 0 { + runtime_AfterFork() + return 0, err1 + } + + if r1 != 0 { + // parent; return PID + runtime_AfterFork() + return int(r1), 0 + } + + // Fork succeeded, now in child. + + // Enable tracing if requested. + if sys.Ptrace { + err1 = raw_ptrace(_PTRACE_TRACEME, 0, 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Session ID + if sys.Setsid { + err1 = raw_setsid() + if err1 != 0 { + goto childerror + } + } + + // Set process group + if sys.Setpgid || sys.Foreground { + // Place child in process group. + err1 = raw_setpgid(0, sys.Pgid) + if err1 != 0 { + goto childerror + } + } + + if sys.Foreground { + pgrp := Pid_t(sys.Pgid) + if pgrp == 0 { + pgrp = raw_getpid() + } + + // Place process group in foreground. + _, err1 = raw_ioctl_ptr(sys.Ctty, TIOCSPGRP, unsafe.Pointer(&pgrp)) + if err1 != 0 { + goto childerror + } + } + + // Restore the signal mask. We do this after TIOCSPGRP to avoid + // having the kernel send a SIGTTOU signal to the process group. + runtime_AfterForkInChild() + + // Chroot + if chroot != nil { + err1 = raw_chroot(chroot) + if err1 != 0 { + goto childerror + } + } + + // User and groups + if cred := sys.Credential; cred != nil { + ngroups := len(cred.Groups) + var groups unsafe.Pointer + if ngroups > 0 { + groups = unsafe.Pointer(&cred.Groups[0]) + } + if !cred.NoSetGroups { + err1 = raw_setgroups(ngroups, groups) + if err1 != 0 { + goto childerror + } + } + err2 := Setgid(int(cred.Gid)) + if err2 != nil { + err1 = err2.(Errno) + goto childerror + } + err2 = Setuid(int(cred.Uid)) + if err2 != nil { + err1 = err2.(Errno) + goto childerror + } + } + + // Chdir + if dir != nil { + err1 = raw_chdir(dir) + if err1 != 0 { + goto childerror + } + } + + // Pass 1: look for fd[i] < i and move those up above len(fd) + // so that pass 2 won't stomp on an fd it needs later. + if pipe < nextfd { + switch runtime.GOOS { + case "netbsd": + err1 = raw_dup3(pipe, nextfd, O_CLOEXEC) + if err1 != 0 { + goto childerror + } + default: + err1 = raw_dup2(pipe, nextfd) + if err1 != 0 { + goto childerror + } + raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC) + } + pipe = nextfd + nextfd++ + } + for i = 0; i < len(fd); i++ { + if fd[i] >= 0 && fd[i] < int(i) { + if nextfd == pipe { // don't stomp on pipe + nextfd++ + } + switch runtime.GOOS { + case "netbsd": + err1 = raw_dup3(fd[i], nextfd, O_CLOEXEC) + if err1 != 0 { + goto childerror + } + default: + err1 = raw_dup2(fd[i], nextfd) + if err1 != 0 { + goto childerror + } + raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC) + } + fd[i] = nextfd + nextfd++ + } + } + + // Pass 2: dup fd[i] down onto i. + for i = 0; i < len(fd); i++ { + if fd[i] == -1 { + raw_close(i) + continue + } + if fd[i] == int(i) { + // dup2(i, i) won't clear close-on-exec flag on Linux, + // probably not elsewhere either. + _, err1 = raw_fcntl(fd[i], F_SETFD, 0) + if err1 != 0 { + goto childerror + } + continue + } + // The new fd is created NOT close-on-exec, + // which is exactly what we want. + err1 = raw_dup2(fd[i], i) + if err1 != 0 { + goto childerror + } + } + + // By convention, we don't close-on-exec the fds we are + // started with, so if len(fd) < 3, close 0, 1, 2 as needed. + // Programs that know they inherit fds >= 3 will need + // to set them close-on-exec. + for i = len(fd); i < 3; i++ { + raw_close(i) + } + + // Detach fd 0 from tty + if sys.Noctty { + _, err1 = raw_ioctl(0, TIOCNOTTY, 0) + if err1 != 0 { + goto childerror + } + } + + // Set the controlling TTY to Ctty + if sys.Setctty { + if TIOCSCTTY == 0 { + err1 = ENOSYS + goto childerror + } + _, err1 = raw_ioctl(sys.Ctty, TIOCSCTTY, 0) + if err1 != 0 { + goto childerror + } + } + + // Time to exec. + err1 = raw_execve(argv0, &argv[0], &envv[0]) + +childerror: + // send error code on pipe + raw_write(pipe, (*byte)(unsafe.Pointer(&err1)), int(unsafe.Sizeof(err1))) + for { + raw_exit(253) + } +}
--- a/src/Makefile.in 2022-02-15 00:20:00.000000000 +0100 +++ b/src/Makefile.in 2022-02-15 00:25:27.000000000 +0100 @@ -66351,6 +66351,8 @@ all-m4: maybe-all-build-texinfo configure-target-libgo: maybe-configure-target-libffi all-target-libgo: maybe-all-target-libffi +all-target-libgo: maybe-all-target-libbacktrace +all-target-libgo: maybe-all-target-libatomic configure-target-libphobos: maybe-configure-target-libbacktrace configure-stage1-target-libphobos: maybe-configure-stage1-target-libbacktrace configure-stage2-target-libphobos: maybe-configure-stage2-target-libbacktrace @@ -66516,8 +66518,6 @@ configure-target-fastjar: maybe-configure-target-zlib all-target-fastjar: maybe-all-target-zlib configure-target-libgo: maybe-all-target-libstdc++-v3 -all-target-libgo: maybe-all-target-libbacktrace -all-target-libgo: maybe-all-target-libatomic configure-target-liboffloadmic: maybe-configure-target-libgomp all-target-liboffloadmic: maybe-all-target-libgomp configure-target-newlib: maybe-all-binutils