Bug#946709: gcc-9: Backported upstream gccgo patch for hurd-i386
Package: gcc-9
Version: 9.2.1-1
Severity: important
Tags: patch
Hello,
gccgo patches for GNU/Hurd are now committed upstream for both gcc-9 and gcc-10.
As found out by Samuel Thibault the current code in os_hurd.go use a relative
time instead of an absolute time, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92861
That bug is now fixed for gcc-10 upstream. However, for gcc-9 we need a patch to
fix also that problem. I've adapted the upstream commit to the attached file
gcc.git-fix-sem_timedwait.diff. A patch for debian/rules.patch is also attached.
Running the libgo testsuite for gcc-9-9.2.1-1 reveals that (almost) all timeout
failures are gone. The number of failing tests has decreased considerably:
(PASS/FAIL) = (158/26) -> (167/17).
Thanks!
--- a/src/libgo/go/runtime/os_hurd.go 2019-12-11 23:50:43.000000000 +0100
+++ b/src/libgo/go/runtime/os_hurd.go 2019-12-12 00:02:20.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.
-// This file is derived from os_solaris.go.
+// This file is derived from os_aix.go.
package runtime
@@ -31,6 +31,10 @@
//extern sem_timedwait
func sem_timedwait(sem *_sem_t, timeout *timespec) int32
+//go:noescape
+//extern clock_gettime
+func clock_gettime(clock_id int32, timeout *timespec) int32
+
//go:nosplit
func semacreate(mp *m) {
if mp.mos.waitsema != 0 {
@@ -54,8 +58,23 @@
_m_ := getg().m
if ns >= 0 {
var ts timespec
- ts.set_sec(ns / 1000000000)
- ts.set_nsec(int32(ns % 1000000000))
+
+ if clock_gettime(_CLOCK_REALTIME, &ts) != 0 {
+ throw("clock_gettime")
+ }
+
+ sec := int64(ts.tv_sec) + ns/1e9
+ nsec := int64(ts.tv_nsec) + ns%1e9
+ if nsec >= 1e9 {
+ sec++
+ nsec -= 1e9
+ }
+ if sec != int64(timespec_sec_t(sec)) {
+ // Handle overflows (timespec_sec_t is 32-bit in 32-bit applications)
+ sec = 1<<31 - 1
+ }
+ ts.tv_sec = timespec_sec_t(sec)
+ ts.tv_nsec = timespec_nsec_t(nsec)
if sem_timedwait((*_sem_t)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 {
err := errno()
--- a/debian/rules.patch 2019-11-25 15:31:24.000000000 +0100
+++ b/debian/rules.patch 2019-12-11 15:23:57.000000000 +0100
@@ -215,6 +215,7 @@
ifeq ($(DEB_TARGET_ARCH_OS),hurd)
debian_patches += hurd-changes
+ debian_patches += gcc.git-fix-sem_timedwait
endif
debian_patches += gcc-ice-dump
Reply to: