diff mbox series

Hurd port for gcc-7 go PATCH 1-3(15)

Message ID 1509982599.28464.30.camel@gmail.com
State New
Headers show
Series Hurd port for gcc-7 go PATCH 1-3(15) | expand

Commit Message

Svante Signell Nov. 6, 2017, 3:36 p.m. UTC
Hi,

Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-7 (7-7.2.0-12).

The first two patches are Debian-specific:
Enable build of gccgo for GNU/Hurd:
* debian_rules.defs.diff
Define patches for the generated series file:
* debian_rules.patch.diff

The third enables split-stack support:
* src_gcc_config_i386_gnu.h.diff

The test suite results are as follows:

		=== go Summary ===

# of expected passes		7359
# of unexpected failures	13
# of expected failures		1
# of untested testcases		7
# of unsupported tests		2

		=== libgo Summary ===

# of expected passes		119
# of unexpected failures	26

Most failing go tests and more than half of the libgo tests are runtime errors
probably due to exception handling not working as expected, stopping execution
with SIGSEGV. These issues are also present in  the gcc-6 port (where libgo is
implemented with more C code) and might be due to issues in gnumach/hurd/glibc
yet to be solved.

Another large group of tests, mainly in libgo, fails with SIGILL. The reason for
these failures are also currently unknown. Maybe it is still some more things to
address with the port, but the cause can also be due to the above. Unfortunately
gdb and rpctrace are not especially usable, the former due to hangs, and the
second due to bugs?? in multi-thread support.

Another issue is that /proc/self/exe has to return an absolute path for the
built program go-7 to execute properly. This is solved by a pending patch for
glibc in Debian and will be available in the next upload of glibc-2.24.
Adding to this, the executable ./build/gotools/go does work displaying the help
text, but e.g. ./build/gotools/go env exits with a SIGILL: Illegal instruction.

Furthermore, since more code is written in go the previous routine
src/libgo/rutime/netpoll_select.c has to be rewritten in go. The supplied file
src/libgo/go/runtime/netpoll_gnu.go is merely a stub for now and has to be
implemented using either select or poll since neither epoll or kqueue or exists
in GNU/Hurd.

Nevertheless, it seems like not so much is left for gccgo working
properly on GNU/Hurd, as for gcc-6. However, since I'm currently stuck, having
spent a lot of time debugging, it is time to hand over to more people taking a
look at this port.

More detailed information on specific issues will be supplied on request.

Thanks!

Comments

Matthias Klose Nov. 6, 2017, 6:43 p.m. UTC | #1
On 06.11.2017 16:36, Svante Signell wrote:
> Hi,
> 
> Attached are patches to enable gccgo to build properly on Debian
> GNU/Hurd on gcc-7 (7-7.2.0-12).

Svante, please could you base your patches on upstream trunk, or the gcc-8
packages from experimental, which follow upstream trunk until gcc-8 branches?

I think upstream would rather like to see your patches against the current trunk.

Thanks, Matthias
Matthias Klose Nov. 15, 2017, 8:40 p.m. UTC | #2
On 06.11.2017 16:36, Svante Signell wrote:
> Hi,
> 
> Attached are patches to enable gccgo to build properly on Debian
> GNU/Hurd on gcc-7 (7-7.2.0-12).

sysinfo.go:6744:7: error: redefinition of 'SYS_IOCTL'
 const SYS_IOCTL = _SYS_ioctl
       ^
sysinfo.go:6403:7: note: previous definition of 'SYS_IOCTL' was here
 const SYS_IOCTL = 0
       ^
the patches break the build on any Linux architecture.  Please could you test
your patches against a linux target as well?
Svante Signell Nov. 15, 2017, 8:54 p.m. UTC | #3
On Wed, 2017-11-15 at 21:40 +0100, Matthias Klose wrote:
> On 06.11.2017 16:36, Svante Signell wrote:
> > Hi,
> > 
> > Attached are patches to enable gccgo to build properly on Debian
> > GNU/Hurd on gcc-7 (7-7.2.0-12).
> 
> sysinfo.go:6744:7: error: redefinition of 'SYS_IOCTL'
>  const SYS_IOCTL = _SYS_ioctl
>        ^
> sysinfo.go:6403:7: note: previous definition of 'SYS_IOCTL' was here
>  const SYS_IOCTL = 0
>        ^
> the patches break the build on any Linux architecture.  Please could you test
> your patches against a linux target as well?

I'm really sorry. I regularly do that, but missed this one for gcc-7. Do you
mean the patches against gcc-8 you asked me for? You wrote that gcc-7 is not of
interest and I should concentrate on gcc-8.

Again, I'm really sorry. Wil fix this tomorrow hopefully.

Thanks!
Svante Signell Nov. 16, 2017, 1:12 p.m. UTC | #4
On Wed, 2017-11-15 at 21:54 +0100, Svante Signell wrote:
> On Wed, 2017-11-15 at 21:40 +0100, Matthias Klose wrote:
> > On 06.11.2017 16:36, Svante Signell wrote:
> > > Hi,
> > > 
> > > Attached are patches to enable gccgo to build properly on Debian
> > > GNU/Hurd on gcc-7 (7-7.2.0-12).
> > 
> > sysinfo.go:6744:7: error: redefinition of 'SYS_IOCTL'
> >  const SYS_IOCTL = _SYS_ioctl
> >        ^
> > sysinfo.go:6403:7: note: previous definition of 'SYS_IOCTL' was here
> >  const SYS_IOCTL = 0
> >        ^
> > the patches break the build on any Linux architecture.  Please could you
> > test
> > your patches against a linux target as well?
> 
> I'm really sorry. I regularly do that, but missed this one for gcc-7. Do you
> mean the patches against gcc-8 you asked me for? You wrote that gcc-7 is not
> of
> interest and I should concentrate on gcc-8.
> 
> Again, I'm really sorry. Will fix this tomorrow hopefully.
> 
> Thanks!

Attached is an updated patch for gcc-7. An updated patch for gcc-8 will follow
shortly when I have build tested gcc-8 go on both Linux and Hurd.

The patch for src/libgo/mksysinfo.sh worked fine in gcc-5 and gcc-6. The problem
is that in gcc-7 and gcc-8 generation of build/<arch-triplet>/libgo/sysinfo.go
is made differently.

The Hurd-specific entry about SYS_IOCTL had to be moved after:

# The syscall numbers.  We force the names to upper case.
grep '^const _SYS_' gen-sysinfo.go | \
  sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
  while read sys; do
    sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
    echo "const $sup = _$sys" >> ${OUT}
  done

Thanks!
Index: gcc-7-7.2.0/src/libgo/configure.ac
===================================================================
--- gcc-7-7.2.0.orig/src/libgo/configure.ac
+++ gcc-7-7.2.0/src/libgo/configure.ac
@@ -146,7 +146,7 @@ AC_SUBST(go_include)
 # All known GOOS values.  This is the union of all operating systems
 # supported by the gofrontend and all operating systems supported by
 # the gc toolchain.
-ALLGOOS="android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows"
+ALLGOOS="android darwin dragonfly freebsd irix gnu linux netbsd openbsd plan9 rtems solaris windows"
 
 is_darwin=no
 is_freebsd=no
@@ -157,6 +157,7 @@ is_openbsd=no
 is_dragonfly=no
 is_rtems=no
 is_solaris=no
+is_gnu=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -168,6 +169,7 @@ case ${host} in
   *-*-dragonfly*) is_dragonfly=yes; GOOS=dragonfly ;;
   *-*-rtems*)    is_rtems=yes;   GOOS=rtems ;;
   *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
+  *-*-gnu*)      is_gnu=yes;     GOOS=gnu ;;
 esac
 AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
 AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
@@ -178,6 +180,7 @@ AM_CONDITIONAL(LIBGO_IS_OPENBSD, test $i
 AM_CONDITIONAL(LIBGO_IS_DRAGONFLY, test $is_dragonfly = yes)
 AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
 AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
+AM_CONDITIONAL(LIBGO_IS_GNU, test $is_gnu = yes)
 AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is_freebsd = yes -o $is_netbsd = yes -o $is_openbsd = yes)
 AC_SUBST(GOOS)
 AC_SUBST(ALLGOOS)
@@ -838,6 +841,14 @@ main ()
 CFLAGS="$CFLAGS_hold"
 LIBS="$LIBS_hold"
 ])
+
+case ${host} in
+  *-*-gnu*)
+  LIBS="$LIBS -lpthread"
+  AC_SUBST(LIBS)
+  ;;
+esac
+
 dnl overwrite for the mips* 64bit multilibs, fails on some buildds
 if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
   case "$target" in
Index: gcc-7-7.2.0/src/libgo/Makefile.am
===================================================================
--- gcc-7-7.2.0.orig/src/libgo/Makefile.am
+++ gcc-7-7.2.0/src/libgo/Makefile.am
@@ -420,10 +420,14 @@ else
 if LIBGO_IS_NETBSD
 runtime_getncpu_file = runtime/getncpu-bsd.c
 else
+if LIBGO_IS_GNU
+runtime_getncpu_file = runtime/getncpu-gnu.c
+else
 runtime_getncpu_file = runtime/getncpu-none.c
 endif
 endif
 endif
+endif
 endif
 endif
 endif
Index: gcc-7-7.2.0/src/libgo/Makefile.in
===================================================================
--- gcc-7-7.2.0.orig/src/libgo/Makefile.in
+++ gcc-7-7.2.0/src/libgo/Makefile.in
@@ -183,7 +183,8 @@ libgo_llgo_la_DEPENDENCIES = $(am__DEPEN
 @LIBGO_IS_LINUX_FALSE@am__objects_2 = thread-sema.lo
 @LIBGO_IS_LINUX_TRUE@am__objects_2 = thread-linux.lo
 @LIBGO_IS_RTEMS_TRUE@am__objects_3 = rtems-task-variable-add.lo
-@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-none.lo
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-none.lo
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-gnu.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_TRUE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-bsd.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_4 = getncpu-bsd.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_TRUE@am__objects_4 = getncpu-solaris.lo
@@ -768,7 +769,8 @@ toolexeclibgounicode_DATA = \
 @LIBGO_IS_RTEMS_TRUE@rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
 @LIBGO_IS_LINUX_FALSE@runtime_thread_files = runtime/thread-sema.c
 @LIBGO_IS_LINUX_TRUE@runtime_thread_files = runtime/thread-linux.c
-@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-none.c
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-none.c
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-gnu.c
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_TRUE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-bsd.c
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-bsd.c
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_TRUE@runtime_getncpu_file = runtime/getncpu-solaris.c
@@ -1086,7 +1088,7 @@ BUILDGOX = \
 	$(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`
 
 GOTESTFLAGS = 
-GOBENCH =
+GOBENCH = 
 
 # Check a package.
 CHECK = \
@@ -1494,6 +1496,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeshash.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-bsd.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-gnu.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-irix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-linux.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-none.Plo@am__quote@
@@ -1979,6 +1982,13 @@ getncpu-none.lo: runtime/getncpu-none.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getncpu-none.lo `test -f 'runtime/getncpu-none.c' || echo '$(srcdir)/'`runtime/getncpu-none.c
 
+getncpu-gnu.lo: runtime/getncpu-gnu.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getncpu-gnu.lo -MD -MP -MF $(DEPDIR)/getncpu-gnu.Tpo -c -o getncpu-gnu.lo `test -f 'runtime/getncpu-gnu.c' || echo '$(srcdir)/'`runtime/getncpu-gnu.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/getncpu-gnu.Tpo $(DEPDIR)/getncpu-gnu.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='runtime/getncpu-gnu.c' object='getncpu-gnu.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getncpu-gnu.lo `test -f 'runtime/getncpu-gnu.c' || echo '$(srcdir)/'`runtime/getncpu-gnu.c
+
 getncpu-bsd.lo: runtime/getncpu-bsd.c
 @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getncpu-bsd.lo -MD -MP -MF $(DEPDIR)/getncpu-bsd.Tpo -c -o getncpu-bsd.lo `test -f 'runtime/getncpu-bsd.c' || echo '$(srcdir)/'`runtime/getncpu-bsd.c
 @am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/getncpu-bsd.Tpo $(DEPDIR)/getncpu-bsd.Plo
Index: gcc-7-7.2.0/src/libgo/match.sh
===================================================================
--- gcc-7-7.2.0.orig/src/libgo/match.sh
+++ gcc-7-7.2.0/src/libgo/match.sh
@@ -113,7 +113,7 @@ for f in $gofiles; do
 	"") ;;
 	$goarch) ;;
 	$goos) ;;
-	android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	android | darwin | dragonfly | freebsd | gnu | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag1=nonmatchingtag
 	    ;;
 	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
@@ -125,7 +125,7 @@ for f in $gofiles; do
 	"") ;;
 	$goarch) ;;
 	$goos) ;;
-	android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	android | darwin | dragonfly | freebsd | gnu | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag2=nonmatchingtag
 	    ;;
 	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
Index: gcc-7-7.2.0/src/libgo/mksigtab.sh
===================================================================
--- gcc-7-7.2.0.orig/src/libgo/mksigtab.sh
+++ gcc-7-7.2.0/src/libgo/mksigtab.sh
@@ -29,7 +29,13 @@ echo '	_SIGINT:    {_SigNotify + _SigKil
 echo '	_SIGQUIT:   {_SigNotify + _SigThrow, "SIGQUIT: quit"},'
 echo '	_SIGILL:    {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"},'
 echo '	_SIGTRAP:   {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"},'
+# Special treatment of SIGABRT for GNU/Hurd
+# /usr/include/i386-gnu/bits/signum.h: #define SIGABRT SIGIOT
+if egrep 'define SIGABRT SIGIOT' gen-sysinfo.go > /dev/null 2>&1; then
+echo '	_SIGIOT:    {_SigNotify + _SigThrow, "SIGIOT: abort"},'
+else
 echo '	_SIGABRT:   {_SigNotify + _SigThrow, "SIGABRT: abort"},'
+fi
 echo '	_SIGBUS:    {_SigPanic + _SigUnblock, "SIGBUS: bus error"},'
 echo '	_SIGFPE:    {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"},'
 echo '	_SIGKILL:   {0, "SIGKILL: kill"},'
@@ -77,6 +83,7 @@ checksig _SIGCANCEL ' {_SigSetStack + _S
 checksig _SIGXRES '   {_SigNotify, "SIGXRES: resource control exceeded"}'
 checksig _SIGJVM1 '   {_SigNotify, "SIGJVM1: reserved signal for Java Virtual Machine"}'
 checksig _SIGJVM2 '   {_SigNotify, "SIGJVM2: reserved signal for Java Virtual Machine"}'
+checksig _SIGLOST '   {_SigNotify, "SIGLOST: resource lost (Sun); server died (GNU)"}'
 
 # Special handling of signals 32 and 33 on GNU/Linux systems,
 # because they are special to glibc.
Index: gcc-7-7.2.0/src/libgo/mksysinfo.sh
===================================================================
--- gcc-7-7.2.0.orig/src/libgo/mksysinfo.sh
+++ gcc-7-7.2.0/src/libgo/mksysinfo.sh
@@ -46,6 +46,13 @@ grep -v '^// ' gen-sysinfo.go | \
   egrep '#define E[A-Z0-9_]+ ' errno.i | \
   sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
 
+# Special treatment of EWOULDBLOCK for GNU/Hurd
+# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
+if egrep 'define EWOULDBLOCK EAGAIN' gen-sysinfo.go > /dev/null 2>&1; then
+  egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+    sed -i -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+fi
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
@@ -104,6 +111,11 @@ grep '^const _SYS_' gen-sysinfo.go | \
     echo "const $sup = _$sys" >> ${OUT}
   done
 
+# Special treatment of SYS_IOCTL for GNU/Hurd
+if ! grep '^const SYS_IOCTL' ${OUT} > /dev/null 2>&1; then
+  echo "const SYS_IOCTL = 0" >> ${OUT}
+fi
+
 # The GNU/Linux support wants to use SYS_GETDENTS64 if available.
 if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then
   echo "const SYS_GETDENTS = 0" >> ${OUT}
@@ -425,6 +437,11 @@ grep '^type _tms ' gen-sysinfo.go | \
 
 # The stat type.
 # Prefer largefile variant if available.
+# Special treatment of st_dev for GNU/Hurd
+# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
+if grep 'define st_dev st_fsid' gen-sysinfo.go > /dev/null 2>&1; then
+  sed -i -e 's/; st_fsid/; st_dev/' gen-sysinfo.go
+fi
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test "$stat" != ""; then
   grep '^type _stat64 ' gen-sysinfo.go
Svante Signell Nov. 16, 2017, 7:39 p.m. UTC | #5
On Thu, 2017-11-16 at 14:12 +0100, Svante Signell wrote:
> On Wed, 2017-11-15 at 21:54 +0100, Svante Signell wrote:
> > 
> 
> Attached is an updated patch for gcc-7. An updated patch for gcc-8 will follow
> shortly when I have build tested gcc-8 go on both Linux and Hurd.
> 
> The patch for src/libgo/mksysinfo.sh worked fine in gcc-5 and gcc-6. The
> problem is that in gcc-7 and gcc-8 generation of build/<arch-
> triplet>/libgo/sysinfo.go is made differently.

Well, in gcc-5 and gcc-6 the gccgo patches in debian/rules.patch are
conditional, and were not in gcc-7-7.2.0-15. In gcc-7-7.2.0-16 they are
conditional again.

> The Hurd-specific entry about SYS_IOCTL had to be moved after:
> 
> # The syscall numbers.  We force the names to upper case.
> grep '^const _SYS_' gen-sysinfo.go | \
>   sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
>   while read sys; do
>     sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
>     echo "const $sup = _$sys" >> ${OUT}
>   done

For completeness updated patches for gcc-6 and gcc-8 are attached.

gcc-6-6.4.0-10: src_libgo_mksysinfo.sh.diff
gcc-8-8-20171108-1: srs_libgo_build.diff

And thank you for finding the bug in the patches by making them (temporarily)
unconditional.

Thanks!
Index: gcc-6-6.4.0/src/libgo/mksysinfo.sh
===================================================================
--- gcc-6-6.4.0.orig/src/libgo/mksysinfo.sh
+++ gcc-6-6.4.0/src/libgo/mksysinfo.sh
@@ -304,6 +304,13 @@ echo '#include <errno.h>' | ${CC} -x c -
   egrep '#define E[A-Z0-9_]+ ' | \
   sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
 
+# Special treatment of EWOULDBLOCK for GNU/Hurd
+# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
+if egrep 'define EWOULDBLOCK EAGAIN' gen-sysinfo.go > /dev/null 2>&1; then
+  egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+    sed -i -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+fi
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
@@ -362,6 +369,11 @@ grep '^const _SYS_' gen-sysinfo.go | \
     echo "const $sup = _$sys" >> ${OUT}
   done
 
+# Special treatment of SYS_IOCTL for GNU/Hurd
+if ! grep '^const SYS_IOCTL' ${OUT} > /dev/null 2>&1; then
+  echo "const SYS_IOCTL = 0" >> ${OUT}
+fi
+
 # The GNU/Linux support wants to use SYS_GETDENTS64 if available.
 if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then
   echo "const SYS_GETDENTS = 0" >> ${OUT}
@@ -676,6 +688,11 @@ grep '^type _tms ' gen-sysinfo.go | \
 
 # The stat type.
 # Prefer largefile variant if available.
+# Special treatment of st_dev for GNU/Hurd
+# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
+if grep 'define st_dev st_fsid' gen-sysinfo.go > /dev/null 2>&1; then
+  sed -i -e 's/; st_fsid/; st_dev/' gen-sysinfo.go
+fi
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test "$stat" != ""; then
   grep '^type _stat64 ' gen-sysinfo.go
Index: gcc-8-8-20171108/src/libgo/configure.ac
===================================================================
--- gcc-8-8-20171108.orig/src/libgo/configure.ac
+++ gcc-8-8-20171108/src/libgo/configure.ac
@@ -154,7 +154,7 @@ AC_SUBST(go_include)
 # All known GOOS values.  This is the union of all operating systems
 # supported by the gofrontend and all operating systems supported by
 # the gc toolchain.
-ALLGOOS="aix android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows"
+ALLGOOS="aix android darwin dragonfly freebsd irix gnu linux netbsd openbsd plan9 rtems solaris windows"
 
 is_darwin=no
 is_freebsd=no
@@ -166,6 +166,7 @@ is_dragonfly=no
 is_rtems=no
 is_solaris=no
 is_aix=no
+is_gnu=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -178,6 +179,7 @@ case ${host} in
   *-*-rtems*)    is_rtems=yes;   GOOS=rtems ;;
   *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
   *-*-aix*)      is_aix=yes;     GOOS=aix ;;
+  *-*-gnu*)      is_gnu=yes;     GOOS=gnu ;;
 esac
 AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
 AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
@@ -189,6 +191,7 @@ AM_CONDITIONAL(LIBGO_IS_DRAGONFLY, test
 AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
 AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
 AM_CONDITIONAL(LIBGO_IS_AIX, test $is_aix = yes)
+AM_CONDITIONAL(LIBGO_IS_GNU, test $is_gnu = yes)
 AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is_freebsd = yes -o $is_netbsd = yes -o $is_openbsd = yes)
 AC_SUBST(GOOS)
 AC_SUBST(ALLGOOS)
@@ -853,6 +856,13 @@ main ()
 CFLAGS="$CFLAGS_hold"
 LIBS="$LIBS_hold"
 ])
+case ${host} in
+  *-*-gnu*)
+  LIBS="$LIBS -lpthread"
+  AC_SUBST(LIBS)
+  ;;
+esac
+
 dnl overwrite for the mips* 64bit multilibs, fails on some buildds
 if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
   case "$target" in
Index: gcc-8-8-20171108/src/libgo/Makefile.am
===================================================================
--- gcc-8-8-20171108.orig/src/libgo/Makefile.am
+++ gcc-8-8-20171108/src/libgo/Makefile.am
@@ -431,10 +431,14 @@ else
 if LIBGO_IS_AIX
 runtime_getncpu_file = runtime/getncpu-aix.c
 else
+if LIBGO_IS_GNU
+runtime_getncpu_file = runtime/getncpu-gnu.c
+else
 runtime_getncpu_file = runtime/getncpu-none.c
 endif
 endif
 endif
+endif
 endif
 endif
 endif
Index: gcc-8-8-20171108/src/libgo/Makefile.in
===================================================================
--- gcc-8-8-20171108.orig/src/libgo/Makefile.in
+++ gcc-8-8-20171108/src/libgo/Makefile.in
@@ -187,7 +187,8 @@ am__DEPENDENCIES_4 = $(am__DEPENDENCIES_
 	$(am__DEPENDENCIES_3) $(am__DEPENDENCIES_3)
 libgo_llgo_la_DEPENDENCIES = $(am__DEPENDENCIES_4)
 @LIBGO_IS_RTEMS_TRUE@am__objects_1 = rtems-task-variable-add.lo
-@LIBGO_IS_AIX_FALSE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_2 = getncpu-none.lo
+@LIBGO_IS_AIX_FALSE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_2 = getncpu-none.lo
+@LIBGO_IS_AIX_FALSE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_2 = getncpu-gnu.lo
 @LIBGO_IS_AIX_TRUE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_2 = getncpu-aix.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_TRUE@@LIBGO_IS_SOLARIS_FALSE@am__objects_2 = getncpu-bsd.lo
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@am__objects_2 = getncpu-bsd.lo
@@ -234,10 +235,10 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLF
 SOURCES = $(libgobegin_llgo_a_SOURCES) $(libgobegin_a_SOURCES) \
 	$(libgolibbegin_a_SOURCES) $(libgotool_a_SOURCES) \
 	$(libgo_llgo_la_SOURCES) $(libgo_la_SOURCES)
-MULTISRCTOP = 
-MULTIBUILDTOP = 
-MULTIDIRS = 
-MULTISUBDIR = 
+MULTISRCTOP =
+MULTIBUILDTOP =
+MULTIDIRS =
+MULTISUBDIR =
 MULTIDO = true
 MULTICLEAN = true
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -469,7 +470,7 @@ AM_LDFLAGS = $(am__append_1) $(am__appen
 @LIBGO_IS_AIX_TRUE@EXTRA_libgo_la_DEPENDENCIES = libgo.imp
 
 # Multilib support.
-MAKEOVERRIDES = 
+MAKEOVERRIDES =
 
 # Work around what appears to be a GNU make  handling MAKEFLAGS
 # values defined in terms of make variables, as is the case for CC and
@@ -773,9 +774,10 @@ toolexeclibgounicode_DATA = \
 # Force them to be built.
 noinst_DATA = internal/testenv.gox net/internal/socktest.gox \
 	zstdpkglist.go zdefaultcc.go
-@LIBGO_IS_RTEMS_FALSE@rtems_task_variable_add_file = 
+@LIBGO_IS_RTEMS_FALSE@rtems_task_variable_add_file =
 @LIBGO_IS_RTEMS_TRUE@rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
-@LIBGO_IS_AIX_FALSE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-none.c
+@LIBGO_IS_AIX_FALSE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-none.c
+@LIBGO_IS_AIX_FALSE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_GNU_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-gnu.c
 @LIBGO_IS_AIX_TRUE@@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-aix.c
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_FALSE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_NETBSD_TRUE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-bsd.c
 @LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_FREEBSD_TRUE@@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_SOLARIS_FALSE@runtime_getncpu_file = runtime/getncpu-bsd.c
@@ -825,13 +827,13 @@ runtime_files = \
 GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
-@LIBGO_IS_LINUX_FALSE@syscall_epoll_file = 
+@LIBGO_IS_LINUX_FALSE@syscall_epoll_file =
 @LIBGO_IS_LINUX_TRUE@syscall_epoll_file = epoll.go
 SYSINFO_FLAGS = \
 	$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(OSCFLAGS) -O
 
-@LIBGO_IS_LINUX_FALSE@syscall_lib_clone_lo = 
+@LIBGO_IS_LINUX_FALSE@syscall_lib_clone_lo =
 @LIBGO_IS_LINUX_TRUE@syscall_lib_clone_lo = syscall/clone_linux.lo
 PACKAGES = \
 	archive/tar \
@@ -1078,7 +1080,7 @@ GOTOOL_PACKAGES = \
 	cmd/internal/browser \
 	cmd/internal/objabi
 
-libgotool_a_SOURCES = 
+libgotool_a_SOURCES =
 libgotool_a_DEPENDENCIES = $(addsuffix .lo,$(GOTOOL_PACKAGES))
 libgotool_a_LIBADD = $(addsuffix .o,$(GOTOOL_PACKAGES))
 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
@@ -1121,7 +1123,7 @@ BUILDGOX = \
 	$(OBJCOPY) -j .go_export $$f $@.tmp; \
 	$(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`
 
-GOTESTFLAGS = 
+GOTESTFLAGS =
 GOBENCH =
 
 # Check a package.
@@ -1207,7 +1209,7 @@ runtime_internal_atomic_lo_GOCFLAGS = -f
 runtime_internal_atomic_lo_check_GOCFLAGS = -fgo-compiling-runtime
 runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime
 runtime_internal_sys_lo_check_GOCFLAGS = -fgo-compiling-runtime
-@USE_LIBFFI_FALSE@matchargs_runtime = 
+@USE_LIBFFI_FALSE@matchargs_runtime =
 
 # If libffi is supported (the normal case) use the ffi build tag for
 # the runtime package.
@@ -1224,12 +1226,12 @@ extra_check_libs_cmd_go_internal_generat
 extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a
-@HAVE_STAT_TIMESPEC_FALSE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = 
+@HAVE_STAT_TIMESPEC_FALSE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os =
 
 # Solaris 12 changed the type of fields in struct stat.
 # Use a build tag, based on a configure check, to cope.
 @HAVE_STAT_TIMESPEC_TRUE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = --tag=solaristag
-@LIBGO_IS_SOLARIS_FALSE@matchargs_os = 
+@LIBGO_IS_SOLARIS_FALSE@matchargs_os =
 @LIBGO_IS_BSD_TRUE@golang_org_x_net_route_lo = \
 @LIBGO_IS_BSD_TRUE@	golang_org/x/net/route.lo
 
@@ -1411,6 +1413,7 @@ MOSTLYCLEANFILES = \
 CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc \
 	*.dep */*.dep */*/*.dep */*/*/*.dep */*/*.dep */*/*/*/*.dep \
 	*/*/*/*/*/*.dep
+
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -1458,7 +1461,7 @@ config.h: stamp-h1
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 	rm -f stamp-h1
 	touch $@
@@ -1499,19 +1502,19 @@ uninstall-toolexeclibLIBRARIES:
 
 clean-toolexeclibLIBRARIES:
 	-test -z "$(toolexeclib_LIBRARIES)" || rm -f $(toolexeclib_LIBRARIES)
-libgobegin-llgo.a: $(libgobegin_llgo_a_OBJECTS) $(libgobegin_llgo_a_DEPENDENCIES) $(EXTRA_libgobegin_llgo_a_DEPENDENCIES) 
+libgobegin-llgo.a: $(libgobegin_llgo_a_OBJECTS) $(libgobegin_llgo_a_DEPENDENCIES) $(EXTRA_libgobegin_llgo_a_DEPENDENCIES)
 	-rm -f libgobegin-llgo.a
 	$(libgobegin_llgo_a_AR) libgobegin-llgo.a $(libgobegin_llgo_a_OBJECTS) $(libgobegin_llgo_a_LIBADD)
 	$(RANLIB) libgobegin-llgo.a
-libgobegin.a: $(libgobegin_a_OBJECTS) $(libgobegin_a_DEPENDENCIES) $(EXTRA_libgobegin_a_DEPENDENCIES) 
+libgobegin.a: $(libgobegin_a_OBJECTS) $(libgobegin_a_DEPENDENCIES) $(EXTRA_libgobegin_a_DEPENDENCIES)
 	-rm -f libgobegin.a
 	$(libgobegin_a_AR) libgobegin.a $(libgobegin_a_OBJECTS) $(libgobegin_a_LIBADD)
 	$(RANLIB) libgobegin.a
-libgolibbegin.a: $(libgolibbegin_a_OBJECTS) $(libgolibbegin_a_DEPENDENCIES) $(EXTRA_libgolibbegin_a_DEPENDENCIES) 
+libgolibbegin.a: $(libgolibbegin_a_OBJECTS) $(libgolibbegin_a_DEPENDENCIES) $(EXTRA_libgolibbegin_a_DEPENDENCIES)
 	-rm -f libgolibbegin.a
 	$(libgolibbegin_a_AR) libgolibbegin.a $(libgolibbegin_a_OBJECTS) $(libgolibbegin_a_LIBADD)
 	$(RANLIB) libgolibbegin.a
-libgotool.a: $(libgotool_a_OBJECTS) $(libgotool_a_DEPENDENCIES) $(EXTRA_libgotool_a_DEPENDENCIES) 
+libgotool.a: $(libgotool_a_OBJECTS) $(libgotool_a_DEPENDENCIES) $(EXTRA_libgotool_a_DEPENDENCIES)
 	-rm -f libgotool.a
 	$(libgotool_a_AR) libgotool.a $(libgotool_a_OBJECTS) $(libgotool_a_LIBADD)
 	$(RANLIB) libgotool.a
@@ -1547,9 +1550,9 @@ clean-toolexeclibLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-libgo-llgo.la: $(libgo_llgo_la_OBJECTS) $(libgo_llgo_la_DEPENDENCIES) $(EXTRA_libgo_llgo_la_DEPENDENCIES) 
+libgo-llgo.la: $(libgo_llgo_la_OBJECTS) $(libgo_llgo_la_DEPENDENCIES) $(EXTRA_libgo_llgo_la_DEPENDENCIES)
 	$(libgo_llgo_la_LINK) $(am_libgo_llgo_la_rpath) $(libgo_llgo_la_OBJECTS) $(libgo_llgo_la_LIBADD) $(LIBS)
-libgo.la: $(libgo_la_OBJECTS) $(libgo_la_DEPENDENCIES) $(EXTRA_libgo_la_DEPENDENCIES) 
+libgo.la: $(libgo_la_OBJECTS) $(libgo_la_DEPENDENCIES) $(EXTRA_libgo_la_DEPENDENCIES)
 	$(libgo_la_LINK) $(am_libgo_la_rpath) $(libgo_la_OBJECTS) $(libgo_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
@@ -1562,6 +1565,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-aix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-bsd.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-gnu.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-irix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-linux.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getncpu-none.Plo@am__quote@
@@ -1926,6 +1930,13 @@ getncpu-none.lo: runtime/getncpu-none.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getncpu-none.lo `test -f 'runtime/getncpu-none.c' || echo '$(srcdir)/'`runtime/getncpu-none.c
 
+getncpu-gnu.lo: runtime/getncpu-gnu.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getncpu-gnu.lo -MD -MP -MF $(DEPDIR)/getncpu-gnu.Tpo -c -o getncpu-gnu.lo `test -f 'runtime/getncpu-gnu.c' || echo '$(srcdir)/'`runtime/getncpu-gnu.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/getncpu-gnu.Tpo $(DEPDIR)/getncpu-gnu.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='runtime/getncpu-gnu.c' object='getncpu-gnu.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getncpu-gnu.lo `test -f 'runtime/getncpu-gnu.c' || echo '$(srcdir)/'`runtime/getncpu-gnu.c
+
 getncpu-aix.lo: runtime/getncpu-aix.c
 @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getncpu-aix.lo -MD -MP -MF $(DEPDIR)/getncpu-aix.Tpo -c -o getncpu-aix.lo `test -f 'runtime/getncpu-aix.c' || echo '$(srcdir)/'`runtime/getncpu-aix.c
 @am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/getncpu-aix.Tpo $(DEPDIR)/getncpu-aix.Plo
@@ -3161,7 +3172,7 @@ s-zdefaultcc: Makefile
 	echo 'const DefaultCXX = "$(GXX_INSTALL_NAME)"' >> zdefaultcc.go.tmp
 	echo 'const DefaultPkgConfig = "pkg-config"' >> zdefaultcc.go.tmp
 	$(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
-	$(STAMP) $@ 
+	$(STAMP) $@
 
 # _Complex_lock and _Reader_lock are Go translations of some AIX system
 # types and should not be exported back to C
Index: gcc-8-8-20171108/src/libgo/match.sh
===================================================================
--- gcc-8-8-20171108.orig/src/libgo/match.sh
+++ gcc-8-8-20171108/src/libgo/match.sh
@@ -113,7 +113,7 @@ for f in $gofiles; do
 	"") ;;
 	$goarch) ;;
 	$goos) ;;
-	aix | android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	aix | android | darwin | dragonfly | freebsd | gnu | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag1=nonmatchingtag
 	    ;;
 	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
@@ -125,7 +125,7 @@ for f in $gofiles; do
 	"") ;;
 	$goarch) ;;
 	$goos) ;;
-	aix | android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
+	aix | android | darwin | dragonfly | freebsd | gnu | linux | nacl | netbsd | openbsd | plan9 | solaris | windows)
 	    tag2=nonmatchingtag
 	    ;;
 	386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | ppc64 | ppc64le | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | ppc | s390 | s390x | sparc | sparc64)
Index: gcc-8-8-20171108/src/libgo/mksigtab.sh
===================================================================
--- gcc-8-8-20171108.orig/src/libgo/mksigtab.sh
+++ gcc-8-8-20171108/src/libgo/mksigtab.sh
@@ -43,7 +43,13 @@ addsig _SIGINT     '{_SigNotify + _SigKi
 addsig _SIGQUIT    '{_SigNotify + _SigThrow, "SIGQUIT: quit"}'
 addsig _SIGILL     '{_SigThrow + _SigUnblock, "SIGILL: illegal instruction"}'
 addsig _SIGTRAP    '{_SigThrow + _SigUnblock, "SIGTRAP: trace trap"}'
+# Special treatment of SIGABRT for GNU/Hurd
+# /usr/include/i386-gnu/bits/signum.h: #define SIGABRT SIGIOT
+if egrep 'define SIGABRT SIGIOT' gen-sysinfo.go > /dev/null 2>&1; then
+addsig _SIGIOT     '{_SigNotify + _SigThrow, "SIGIOT: abort"}'
+else
 addsig _SIGABRT    '{_SigNotify + _SigThrow, "SIGABRT: abort"}'
+fi
 addsig _SIGBUS     '{_SigPanic + _SigUnblock, "SIGBUS: bus error"}'
 addsig _SIGFPE     '{_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"}'
 addsig _SIGKILL    '{0, "SIGKILL: kill"}'
@@ -91,6 +97,7 @@ checksig _SIGCANCEL  '{_SigSetStack + _S
 checksig _SIGXRES    '{_SigNotify, "SIGXRES: resource control exceeded"}'
 checksig _SIGJVM1    '{_SigNotify, "SIGJVM1: reserved signal for Java Virtual Machine"}'
 checksig _SIGJVM2    '{_SigNotify, "SIGJVM2: reserved signal for Java Virtual Machine"}'
+checksig _SIGLOST '   {_SigNotify, "SIGLOST: resource lost (Sun); server died (GNU)"}'
 
 # Special handling of signals 32 and 33 on GNU/Linux systems,
 # because they are special to glibc.
Index: gcc-8-8-20171108/src/libgo/mksysinfo.sh
===================================================================
--- gcc-8-8-20171108.orig/src/libgo/mksysinfo.sh
+++ gcc-8-8-20171108/src/libgo/mksysinfo.sh
@@ -57,6 +57,13 @@ grep '^type _mld_hdr_t ' gen-sysinfo.go
   egrep '#define E[A-Z0-9_]+ ' errno.i | \
   sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
 
+# Special treatment of EWOULDBLOCK for GNU/Hurd
+# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
+if egrep 'define EWOULDBLOCK EAGAIN' gen-sysinfo.go > /dev/null 2>&1; then
+  egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+    sed -i -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+fi
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
@@ -124,6 +131,11 @@ grep '^const _SYS_' gen-sysinfo.go | \
     echo "const $sup = _$sys" >> ${OUT}
   done
 
+# Special treatment of SYS_IOCTL for GNU/Hurd
+if ! grep '^const SYS_IOCTL' ${OUT} > /dev/null 2>&1; then
+  echo "const SYS_IOCTL = 0" >> ${OUT}
+fi
+
 # The GNU/Linux support wants to use SYS_GETDENTS64 if available.
 if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then
   echo "const SYS_GETDENTS = 0" >> ${OUT}
@@ -445,6 +457,11 @@ grep '^type _tms ' gen-sysinfo.go | \
 
 # The stat type.
 # Prefer largefile variant if available.
+# Special treatment of st_dev for GNU/Hurd
+# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
+if grep 'define st_dev st_fsid' gen-sysinfo.go > /dev/null 2>&1; then
+  sed -i -e 's/; st_fsid/; st_dev/' gen-sysinfo.go
+fi
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test "$stat" != ""; then
   grep '^type _stat64 ' gen-sysinfo.go
Samuel Thibault Nov. 19, 2017, 12:58 p.m. UTC | #6
Hello,

Svante Signell, on lun. 06 nov. 2017 16:36:39 +0100, wrote:
> Another issue is that /proc/self/exe has to return an absolute path for the
> built program go-7 to execute properly. This is solved by a pending patch for
> glibc in Debian and will be available in the next upload of glibc-2.24.

FI, this was uploaded.

> Adding to this, the executable ./build/gotools/go does work displaying the help
> text, but e.g. ./build/gotools/go env exits with a SIGILL: Illegal instruction.

That seems to be still happening with the updated libc.

Samuel
diff mbox series

Patch

Index: gcc-7-7.2.0-12.1/src/gcc/config/i386/gnu.h
===================================================================
--- gcc-7-7.2.0-12.1.orig/src/gcc/config/i386/gnu.h
+++ gcc-7-7.2.0-12.1/src/gcc/config/i386/gnu.h
@@ -37,11 +37,14 @@  along with GCC.  If not, see <http://www
 
 #ifdef TARGET_LIBC_PROVIDES_SSP
 
-/* Not supported yet.  */
-# undef TARGET_THREAD_SSP_OFFSET
-
-/* Not supported yet.  */
-# undef TARGET_CAN_SPLIT_STACK
-# undef TARGET_THREAD_SPLIT_STACK_OFFSET
+/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+#define TARGET_THREAD_SSP_OFFSET        0x14
 
+/* We only build the -fsplit-stack support in libgcc if the
+   assembler has full support for the CFI directives.  */
+#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+#define TARGET_CAN_SPLIT_STACK
+#endif
+/* We steal the last transactional memory word.  */
+#define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
 #endif