Now gcc-13: [Fwd: [PATCH] gcc-12: Re-enable split-stack support for GNU/Hurd.]

2023-03-15 Thread Svante Signell via Gcc-patches
Package: gcc-snapshot
Version: 1:20230315-1
Severity: important
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd
Affects: gcc-snapshot
X-Debbugs-CC: debian-h...@lists.debian.org

Hello, seems like the patch gcc_config_gnu.h.diff, in debian gcc-12 named:
pr104290-followup.diff was lost (again).

How can this patch ever become upstreamed??

It seems like sending to gcc-patches is not enough. Create a regression bug?  
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104290 is already reported as a
regression, it has to be updated to cover upstream releases of gcc-13 now.

For gcc-12 Debian has been carrying it as:
pr104290-followup.diff

Submitting this problem as new bug to Debian/gcc-13/gcc-snapshot!

Thanks!
--- Begin Message ---
Hello,

In line of porting the latest build of libgo/go with gcc-12 to GNU/Hurd, support
of split-stack was found to be removed.
 
After patching the files in libgo the build of gotools fails:
go1: error: '-fsplit-stack' currently only supported on GNU/Linux
go1: error: '-fsplit-stack' is not supported by this compiler configuration

The attached patch defines OPTION_GLIBC_P(opts) and OPTION_GLIBC that was lost
in config/gnu.h, needed to enable split-stack support for GNU/Hurd. 

This problem happened with the latest commit as discussed in the mail thread
starting with https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588973.html
.

The file first doing this check is: (first error: ..)
src/gcc/common/config/i386/i386-common.cc
in function:
static bool ix86_supports_split_stack (bool report,
struct gcc_options *opts ATTRIBUTE_UNUSED)

and secondly in:src/gcc/opts.cc: (second error: ...)
in function:
void
finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
location_t loc)

The checking logic is in function ix86_supports_split_stack():
#if defined(TARGET_THREAD_SPLIT_STACK_OFFSET) && defined(OPTION_GLIBC_P)
  if (!OPTION_GLIBC_P (opts))
#endif
{
  if (report)
error ("%<-fsplit-stack%> currently only supported on GNU/Linux");
  return false;
}

  bool ret = true;

In case of GNU/Hurd TARGET_THREAD_SPLIT_STACK_OFFSET is defined as well as
OPTION_GLIBC_P but OPTION_GLIBC_P(opts) is needed to. The attached patch to
src/gcc/config/gnu.h creates that definition. For GNU/Hurd, gnu.h is included in
the configure stage:
Configuring stage 1 in ./gcc
...
Using the following target machine macro files:
...
../../src/gcc/config/gnu.h

For a longer history about this bug see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104290

Additionally, I would propose the text in gcc/common/config/i386/i386-common.cc
to change from:
error ("%<-fsplit-stack%> currently only supported on GNU/Linux");
to:
error ("%<-fsplit-stack%> currently only supported on GLIBC-based systems");

Thanks!

--- a/src/gcc/config/gnu.h	2022-02-06 11:59:41.0 +0100
+++ b/src/gcc/config/gnu.h	2022-02-06 12:00:19.0 +0100
@@ -19,6 +19,9 @@
 along with GCC.  If not, see .
 */
 
+#define OPTION_GLIBC_P(opts)	(DEFAULT_LIBC == LIBC_GLIBC)
+#define OPTION_GLIBC		OPTION_GLIBC_P (_options)
+
 #undef GNU_USER_TARGET_OS_CPP_BUILTINS
 #define GNU_USER_TARGET_OS_CPP_BUILTINS()		\
 do {	\
--- End Message ---


gcc-snapshot: FTBFS on hurd-i386 (and other archs?)

2023-01-16 Thread Svante Signell via Gcc-patches
Source: gcc-snapshot
Version: 20230108-1
Severity: important
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd
X-Debbugs-CC: debian-h...@lists.debian.org

Hi,

gcc-snapshot in sid FTBFS on hurd-i386 due to that some patches are not
applied when building gcc-snapshot. After the statement in rules.patch
ifeq ($(single_package),yes)
  debian_patches =
endif
previously defined patches are cleared, causing the build failure, see
below.

debian/ files causing the problem:

debian/rules.defs:
ifneq (,$(findstring gcc-snapshot, $(PKGSOURCE)))
  single_package = yes
  trunk_build = yes

debian/rules.patch:
ifeq ($(single_package),yes)
  debian_patches =
endif

Thanks!




gcc-11: FTBFS on hurd-i386

2023-01-03 Thread Svante Signell via Gcc-patches
Source: gcc-11
Version: 11.3.0-10
Severity: important
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd
Affects: gcc-11, gcc-snapshot
X-Debbugs-CC: debian-h...@lists.debian.org

Hi,

gcc-11-11.3.0-10 in sid FTBFS on hurd-i386 due to failing linkage of
pthread_once (same error already fixed in gcc-12 and gcc-13):
/<>/build/i686-gnu/libstdc++-v3/include/i686-gnu/bits/gthr-
default.h:700: undefined reference to `pthread_once'
and more.

The patch at hand is: libstdc++-hurd.diff, attached here for convenience.

Thanks!

This is notably needed because in glibc 2.34, the move of pthread functions
into libc.so happened for Linux only, not GNU/Hurd.

The pthread_self() function can also always be used fine as it is on
GNU/Hurd.

libstdc++-v3/ChangeLog:

* config/os/gnu-linux/os_defines.h [!__linux__]
  (_GLIBCXX_NATIVE_THREAD_ID, _GLIBCXX_GTHREAD_USE_WEAK): Do not define.

--- a/libstdc++-v3/config/os/gnu-linux/os_defines.h
+++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h
@@ -49,22 +49,24 @@
 // version dynamically in case it has changed since libstdc++ was configured.
 #define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23)
 
-#if __GLIBC_PREREQ(2, 27)
-// Since glibc 2.27 pthread_self() is usable without linking to libpthread.
-# define _GLIBCXX_NATIVE_THREAD_ID pthread_self()
-#else
+#ifdef __linux__
+# if __GLIBC_PREREQ(2, 27)
+// Since glibc 2.27 Linux' pthread_self() is usable without linking to libpthread.
+#  define _GLIBCXX_NATIVE_THREAD_ID pthread_self()
+# else
 // Before then it was in libc.so.6 but not libc.a, and always returns 0,
 // which breaks the invariant this_thread::get_id() != thread::id{}.
 // So only use it if we know the libpthread version is available.
 // Otherwise use (__gthread_t)1 as the ID of the main (and only) thread.
-# define _GLIBCXX_NATIVE_THREAD_ID \
-  (__gthread_active_p() ? __gthread_self() : (__gthread_t)1)
-#endif
+#  define _GLIBCXX_NATIVE_THREAD_ID \
+   (__gthread_active_p() ? __gthread_self() : (__gthread_t)1)
+# endif
 
-#if __GLIBC_PREREQ(2, 34)
-// Since glibc 2.34 all pthreads functions are usable without linking to
+# if __GLIBC_PREREQ(2, 34)
+// Since glibc 2.34 all Linux pthreads functions are usable without linking to
 // libpthread.
-# define _GLIBCXX_GTHREAD_USE_WEAK 0
+#  define _GLIBCXX_GTHREAD_USE_WEAK 0
+# endif
 #endif
 
 #endif


gcc-12: FTBFS on hurd-i386

2022-10-06 Thread Svante Signell via Gcc-patches
Source: gcc-12
Version: 12_12.2.0-5
Severity: important
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd
Affects: gcc-11, gcc-snapshot
X-Debbugs-CC: debian-h...@lists.debian.org

Hi,

gcc-12-12.2.0-4/5 in sid FTBFS on hurd-i386 due to failing linkage of
pthread_once (same error for gcc-11, gcc-12, gcc-snapshot):
/<>/build/i686-gnu/libstdc++-v3/include/i686-gnu/bits/gthr-
default.h:700: undefined reference to `pthread_once'

Patches have already submitted upstream by Samuel Thibault in August and
September, see
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600469.html
https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601754.html

Unfortunately upstream is not very responsive. Therefore I have taken the time
to send these patches to Debian in the mean time.

Patches extracted and attached from that mail message are:
1.diff-6.diff. Note that 1.diff does not apply to gcc-12, it is related to the
git repo. This is reflected in attached debian_rules.patch by commenting out
1.diff.

Just a reflection: Matthias you are really doing a great job with the
gcc releases: Kudos!

Thanks!

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ba5939d9003..dd288cce2ca 100644
--- a/src/libstdc++-v3/ChangeLog
+++ b/src/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2022-08-28  Samuel Thibault  
+
+   * config/os/gnu/os_defines.h: New file.
+   * config/os/gnu/ctype_base.h: New file.
+   * config/os/gnu/ctype_configure_char.cc: New file.
+   * config/os/gnu/ctype_inline.h: New file.
+   * configure.host: On gnu* host, use os/gnu instead of os/gnu-linux.
+
 2022-08-27  Patrick Palka  
diff --git a/src/libstdc++-v3/config/os/gnu/ctype_base.h b/src/libstdc++-v3/config/os/gnu/ctype_base.h
new file mode 100644
index 000..955146543db
--- /dev/null
+++ b/src/libstdc++-v3/config/os/gnu/ctype_base.h
@@ -0,0 +1,66 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1997-2022 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file bits/ctype_base.h
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{locale}
+ */
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+
+// Information as gleaned from /usr/include/ctype.h
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  /// @brief  Base class for ctype.
+  struct ctype_base
+  {
+// Non-standard typedefs.
+typedef const int* 		__to_type;
+
+// NB: Offsets into ctype::_M_table force a particular size
+// on the mask type. Because of this, we don't use an enum.
+typedef unsigned short 	mask;
+static const mask upper	= _ISupper;
+static const mask lower 	= _ISlower;
+static const mask alpha 	= _ISalpha;
+static const mask digit 	= _ISdigit;
+static const mask xdigit 	= _ISxdigit;
+static const mask space 	= _ISspace;
+static const mask print 	= _ISprint;
+static const mask graph 	= _ISalpha | _ISdigit | _ISpunct;
+static const mask cntrl 	= _IScntrl;
+static const mask punct 	= _ISpunct;
+static const mask alnum 	= _ISalpha | _ISdigit;
+#if __cplusplus >= 201103L
+static const mask blank	= _ISblank;
+#endif
+  };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/src/libstdc++-v3/config/os/gnu/ctype_configure_char.cc b/src/libstdc++-v3/config/os/gnu/ctype_configure_char.cc
new file mode 100644
index 000..5a88fc11ab3
--- /dev/null
+++ b/src/libstdc++-v3/config/os/gnu/ctype_configure_char.cc
@@ -0,0 +1,196 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2011-2022 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but 

Re: [PATCH] gcc-12: Re-enable split-stack support for GNU/Hurd.

2022-03-17 Thread Svante Signell via Gcc-patches
ping

On Wed, 2022-02-23 at 11:13 +0100, Svante Signell wrote:
> Hello,
> 
> In line of porting the latest build of libgo/go with gcc-12 to GNU/Hurd,
> support
> of split-stack was found to be removed.
>  
> After patching the files in libgo the build of gotools fails:
> go1: error: '-fsplit-stack' currently only supported on GNU/Linux
> go1: error: '-fsplit-stack' is not supported by this compiler configuration
> 
> The attached patch defines OPTION_GLIBC_P(opts) and OPTION_GLIBC that was lost
> in config/gnu.h, needed to enable split-stack support for GNU/Hurd. 
> 
> This problem happened with the latest commit as discussed in the mail thread
> starting with 
> https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588973.html
> .
> 
> The file first doing this check is: (first error: ..)
> src/gcc/common/config/i386/i386-common.cc
> in function:
> static bool ix86_supports_split_stack (bool report,
> struct gcc_options *opts ATTRIBUTE_UNUSED)
> 
> and secondly in:src/gcc/opts.cc: (second error: ...)
> in function:
> void
> finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
> location_t loc)
> 
> The checking logic is in function ix86_supports_split_stack():
> #if defined(TARGET_THREAD_SPLIT_STACK_OFFSET) && defined(OPTION_GLIBC_P)
>   if (!OPTION_GLIBC_P (opts))
> #endif
> {
>   if (report)
> error ("%<-fsplit-stack%> currently only supported on GNU/Linux");
>   return false;
> }
> 
>   bool ret = true;
> 
> In case of GNU/Hurd TARGET_THREAD_SPLIT_STACK_OFFSET is defined as well as
> OPTION_GLIBC_P but OPTION_GLIBC_P(opts) is needed to. The attached patch to
> src/gcc/config/gnu.h creates that definition. For GNU/Hurd, gnu.h is included
> in
> the configure stage:
> Configuring stage 1 in ./gcc
> ...
> Using the following target machine macro files:
> ...
> ../../src/gcc/config/gnu.h
> 
> For a longer history about this bug see:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104290
> 
> Additionally, I would propose the text in gcc/common/config/i386/i386-
> common.cc
> to change from:
> error ("%<-fsplit-stack%> currently only supported on GNU/Linux");
> to:
> error ("%<-fsplit-stack%> currently only supported on GLIBC-based systems");
> 
> Thanks!



[PATCH] gcc-12: Re-enable split-stack support for GNU/Hurd.

2022-02-23 Thread Svante Signell via Gcc-patches
Hello,

In line of porting the latest build of libgo/go with gcc-12 to GNU/Hurd, support
of split-stack was found to be removed.
 
After patching the files in libgo the build of gotools fails:
go1: error: '-fsplit-stack' currently only supported on GNU/Linux
go1: error: '-fsplit-stack' is not supported by this compiler configuration

The attached patch defines OPTION_GLIBC_P(opts) and OPTION_GLIBC that was lost
in config/gnu.h, needed to enable split-stack support for GNU/Hurd. 

This problem happened with the latest commit as discussed in the mail thread
starting with https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588973.html
.

The file first doing this check is: (first error: ..)
src/gcc/common/config/i386/i386-common.cc
in function:
static bool ix86_supports_split_stack (bool report,
struct gcc_options *opts ATTRIBUTE_UNUSED)

and secondly in:src/gcc/opts.cc: (second error: ...)
in function:
void
finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
location_t loc)

The checking logic is in function ix86_supports_split_stack():
#if defined(TARGET_THREAD_SPLIT_STACK_OFFSET) && defined(OPTION_GLIBC_P)
  if (!OPTION_GLIBC_P (opts))
#endif
{
  if (report)
error ("%<-fsplit-stack%> currently only supported on GNU/Linux");
  return false;
}

  bool ret = true;

In case of GNU/Hurd TARGET_THREAD_SPLIT_STACK_OFFSET is defined as well as
OPTION_GLIBC_P but OPTION_GLIBC_P(opts) is needed to. The attached patch to
src/gcc/config/gnu.h creates that definition. For GNU/Hurd, gnu.h is included in
the configure stage:
Configuring stage 1 in ./gcc
...
Using the following target machine macro files:
...
../../src/gcc/config/gnu.h

For a longer history about this bug see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104290

Additionally, I would propose the text in gcc/common/config/i386/i386-common.cc
to change from:
error ("%<-fsplit-stack%> currently only supported on GNU/Linux");
to:
error ("%<-fsplit-stack%> currently only supported on GLIBC-based systems");

Thanks!
--- a/src/gcc/config/gnu.h	2022-02-06 11:59:41.0 +0100
+++ b/src/gcc/config/gnu.h	2022-02-06 12:00:19.0 +0100
@@ -19,6 +19,9 @@
 along with GCC.  If not, see .
 */
 
+#define OPTION_GLIBC_P(opts)	(DEFAULT_LIBC == LIBC_GLIBC)
+#define OPTION_GLIBC		OPTION_GLIBC_P (_options)
+
 #undef GNU_USER_TARGET_OS_CPP_BUILTINS
 #define GNU_USER_TARGET_OS_CPP_BUILTINS()		\
 do {	\


[PATCH] New patch for the port of gccgo to GNU/Hurd

2020-09-25 Thread Svante Signell via Gcc-patches
Hello,

Latest Debian snapshot of gcc (20200917-1) FTBFS due to a missing hurd
entry in the // +build line of libgo/go/net/fd_posix.go. Attached is a
patch for that missing entry.

With it the latest Debian snapshot has been successfully built. Test
results for libgo and go are:

=== libgo Summary ===

# of expected passes163
# of unexpected failures12

=== go Summary ===

# of expected passes7469
# of unexpected failures10
# of expected failures  1
# of untested testcases 6
# of unsupported tests  2


Thanks!
--- a/src/libgo/go/net/fd_posix.go	2020-08-03 15:12:53.0 +0200
+++ b/src/libgo/go/net/fd_posix.go	2020-09-24 16:03:50.0 +0200
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
+// +build aix darwin dragonfly freebsd hurd linux netbsd openbsd solaris windows
 
 package net
 


Re: [PATCH] Updated patches for the port of gccgo to GNU/Hurd

2019-02-11 Thread Svante Signell
On Mon, 2019-02-11 at 10:27 -0800, Ian Lance Taylor wrote:
> On Mon, Feb 11, 2019 at 3:10 AM Svante Signell 
> wrote:
> > On Sun, 2019-02-10 at 22:08 -0800, Ian Lance Taylor wrote:
> > > On Sun, Feb 10, 2019 at 3:41 AM Svante Signell 
> > > wrote:
> > > > On Sat, 2019-02-09 at 23:57 +0100, Svante Signell wrote:
> > > > > On Sat, 2019-02-09 at 14:40 -0800, Ian Lance Taylor wrote:
> > > > > > On Fri, Feb 8, 2019 at 3:07 PM Matthias Klose 
> > > > > > wrote:
> > > > > > > On 07.02.19 06:04, Ian Lance Taylor wrote:
> > > > > > What are the lines before that in the log?  For some reason libtool
> > > > > > is
> > > > > > being invoke with no source files.  The lines before the failing
> > > > > > line
> > > > > > should show an invocation of match.sh that determines the source
> > > > > > files.
> > > > > 
> > > > > Thanks for your job upstreaming the patches!
> > > > > 
> > > > > I've found some problems. Current problem is with the mksysinfo.sh
> > > > > patch.
> > > > > But there are some other things missing. New patches will be submitted
> > > > > tomorrow.
> > > > 
> > > > Attached are three additional patches needed to build libgo on GNU/Hurd:
> > > > src_libgo_mksysinfo.sh.diff
> > > > src_libgo_go_syscall_wait.c.diff
> > > > src_libgo_testsuite_gotest.diff
> > > > 
> > > > For the first patch, src_libgo_mksysinfo.sh.diff, I had to go back to
> > > > the
> > > > old version, using sed -i -e. As written now ${fsid_to_dev} expands to
> > > > fsid_to_dev='-e '\''s/st_fsid/Dev/'\''' resulting in: "sed: -e
> > > > expression
> > > > #4, char 1: unknown command: `''". Unfortunately, I have not yet been
> > > > able
> > > > to modify the expansion omitting the single qoutes around the shell
> > > > variable.
> > > 
> > > I'm sorry, I don't want to use "sed -i".  That loses the original file
> > > and makes it harder to reconstruct what has happened.
> > 
> > What to do then?
> > 
> > > > The second patch, src_libgo_go_syscall_wait.c.diff, is needed since
> > > > WCONTINUED is not defined and is needed for WIFCONTINUED to be defined
> > > > in
> > > > wait.h.
> > > 
> > > I don't understand that.   is a system header file.  Are
> > > you saying that it is impossible to use  and WIFCONTINUED
> > > unless your source code does a #define WCONTINUED before #include'ing
> > > ?  That seems like a bug in the Hurd library code.
> > 
> > The problem is that WCONTINUED is not defined in /usr/include/i386-
> > gnu/bits/waitflags.h on Hurd. Only WNOHANG and WUNTRACED are. That causes
> > WIFCONTINUED not to be defined in /usr/include/i386-gnu/bits/waitstatus.h.
> > As
> > WCONTINUED is not defined, I assume that WIFCONTINUED is not supported.
> > 
> > From waitpid(2):
> > WCONTINUED (since Linux 2.6.10)
> >also return if a stopped child has been resumed by delivery of SIGCONT.
> > 
> > @Samuel: more info?
> > 
> > I think that that call to WIFCONTINUED in libgo/go/syscall/wait.c
> > _Bool
> > Continued (uint32_t *w)
> > {
> >   return WIFCONTINUED (*w) != 0;
> > }
> > 
> > has to be omitted somehow for Hurd.
> 
> It sound like the right fix is to use #ifdef WIFCONTINUED in
> syscall/wait.c.  If WIFCONTINUED is not defined, the Continued
> function should always return 0.

I've got some ideas on how to solve the mksysinfo.sh problem. I just don't have
time to try it out now. The idea is:
fsid_to_dev='s/st_dev/Dev/'
if grep 'define st_dev st_fsid' gen-sysinfo.go > /dev/null 2>&1; then
fsid_to_dev='s/st_fsid/Dev/'
...
remove: -e 's/st_dev/Dev/' \
add:-e ${fsid_to_dev} \


I can also easily submit a patch for WIFCONTINUED returning 0. Problem is I'll
be AFK for the next week. Maybe this can wait, or you find a solution? 
Regardinga comm opttion for ps Samuel is the best source. 

Thanks!



Re: [PATCH] Updated patches for the port of gccgo to GNU/Hurd

2019-02-11 Thread Svante Signell
On Sun, 2019-02-10 at 22:08 -0800, Ian Lance Taylor wrote:
> On Sun, Feb 10, 2019 at 3:41 AM Svante Signell 
> wrote:
> > On Sat, 2019-02-09 at 23:57 +0100, Svante Signell wrote:
> > > On Sat, 2019-02-09 at 14:40 -0800, Ian Lance Taylor wrote:
> > > > On Fri, Feb 8, 2019 at 3:07 PM Matthias Klose  wrote:
> > > > > On 07.02.19 06:04, Ian Lance Taylor wrote:
> > > > What are the lines before that in the log?  For some reason libtool is
> > > > being invoke with no source files.  The lines before the failing line
> > > > should show an invocation of match.sh that determines the source
> > > > files.
> > > 
> > > Thanks for your job upstreaming the patches!
> > > 
> > > I've found some problems. Current problem is with the mksysinfo.sh patch.
> > > But there are some other things missing. New patches will be submitted
> > > tomorrow.
> > 
> > Attached are three additional patches needed to build libgo on GNU/Hurd:
> > src_libgo_mksysinfo.sh.diff
> > src_libgo_go_syscall_wait.c.diff
> > src_libgo_testsuite_gotest.diff
> > 
> > For the first patch, src_libgo_mksysinfo.sh.diff, I had to go back to the
> > old version, using sed -i -e. As written now ${fsid_to_dev} expands to
> > fsid_to_dev='-e '\''s/st_fsid/Dev/'\''' resulting in: "sed: -e expression
> > #4, char 1: unknown command: `''". Unfortunately, I have not yet been able
> > to modify the expansion omitting the single qoutes around the shell
> > variable.
> 
> I'm sorry, I don't want to use "sed -i".  That loses the original file
> and makes it harder to reconstruct what has happened.

What to do then?

> > The second patch, src_libgo_go_syscall_wait.c.diff, is needed since
> > WCONTINUED is not defined and is needed for WIFCONTINUED to be defined in
> > wait.h.
> 
> I don't understand that.   is a system header file.  Are
> you saying that it is impossible to use  and WIFCONTINUED
> unless your source code does a #define WCONTINUED before #include'ing
> ?  That seems like a bug in the Hurd library code.

The problem is that WCONTINUED is not defined in /usr/include/i386-
gnu/bits/waitflags.h on Hurd. Only WNOHANG and WUNTRACED are. That causes
WIFCONTINUED not to be defined in /usr/include/i386-gnu/bits/waitstatus.h. As
WCONTINUED is not defined, I assume that WIFCONTINUED is not supported.

>From waitpid(2):
WCONTINUED (since Linux 2.6.10)
   also return if a stopped child has been resumed by delivery of SIGCONT.

@Samuel: more info?

I think that that call to WIFCONTINUED in libgo/go/syscall/wait.c
_Bool
Continued (uint32_t *w)
{
  return WIFCONTINUED (*w) != 0;
}

has to be omitted somehow for Hurd.

> > The third patch, src_libgo_testsuite_gotest.diff, is not strictly needed,
> > but running the tests the annoying text is displayed: "ps: comm: Unknown
> > format spec"
> 
> I get that "comm" doesn't work, but the change in that patch is simply
> incorrect.  If you don't pass "comm", the "grep sleep" will never
> succeed.  If there is no way to support this code on Hurd then we
> should skip it, not put in a command that can never work.

OK, let's drop that part then.

@Samuel: more info?




Re: [PATCH] Updated patches for the port of gccgo to GNU/Hurd

2019-02-10 Thread Svante Signell
On Sat, 2019-02-09 at 23:57 +0100, Svante Signell wrote:
> On Sat, 2019-02-09 at 14:40 -0800, Ian Lance Taylor wrote:
> > On Fri, Feb 8, 2019 at 3:07 PM Matthias Klose  wrote:
> > > On 07.02.19 06:04, Ian Lance Taylor wrote:
> > What are the lines before that in the log?  For some reason libtool is
> > being invoke with no source files.  The lines before the failing line
> > should show an invocation of match.sh that determines the source
> > files.
> 
> Thanks for your job upstreaming the patches!
> 
> I've found some problems. Current problem is with the mksysinfo.sh patch. But
> there are some other things missing. New patches will be submitted tomorrow. 

Attached are three additional patches needed to build libgo on GNU/Hurd:
src_libgo_mksysinfo.sh.diff
src_libgo_go_syscall_wait.c.diff
src_libgo_testsuite_gotest.diff

For the first patch, src_libgo_mksysinfo.sh.diff, I had to go back to the old
version, using sed -i -e. As written now ${fsid_to_dev} expands to 
fsid_to_dev='-e '\''s/st_fsid/Dev/'\''' resulting in: "sed: -e expression #4,
char 1: unknown command: `''". Unfortunately, I have not yet been able to modify
the expansion omitting the single qoutes around the shell variable.

The second patch, src_libgo_go_syscall_wait.c.diff, is needed since WCONTINUED
is not defined and is needed for WIFCONTINUED to be defined in wait.h.

The third patch, src_libgo_testsuite_gotest.diff, is not strictly needed, but
running the tests the annoying text is displayed: "ps: comm: Unknown format
spec"

Thanks!
Index: gcc-9-9-20190208/src/libgo/go/syscall/wait.c
===
--- gcc-9-9-20190208.orig/src/libgo/go/syscall/wait.c
+++ gcc-9-9-20190208/src/libgo/go/syscall/wait.c
@@ -8,6 +8,13 @@
OS-independent.  */
 
 #include 
+
+/* WCONTINUED is not defined on GNU/Hurd */
+#ifdef __GNU__
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
+#endif
 #include 
 
 #include "runtime.h"
Index: gcc-9-9-20190208/src/libgo/mksysinfo.sh
===
--- gcc-9-9-20190208.orig/src/libgo/mksysinfo.sh
+++ gcc-9-9-20190208/src/libgo/mksysinfo.sh
@@ -486,9 +486,8 @@ grep '^type _st_timespec ' gen-sysinfo.g
 
 # Special treatment of struct stat st_dev for GNU/Hurd
 # /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
-fsid_to_dev=
 if grep 'define st_dev st_fsid' gen-sysinfo.go > /dev/null 2>&1; then
-  fsid_to_dev="-e 's/st_fsid/Dev/'"
+  sed -i -e 's/; st_fsid/; st_dev/' gen-sysinfo.go
 fi
 
 # The stat type.
@@ -501,7 +500,6 @@ else
 fi | sed -e 's/type _stat64/type Stat_t/' \
  -e 's/type _stat/type Stat_t/' \
  -e 's/st_dev/Dev/' \
- ${fsid_to_dev} \
  -e 's/st_ino/Ino/g' \
  -e 's/st_nlink/Nlink/' \
  -e 's/st_mode/Mode/' \
libgo/ChangeLog

2018-10-20  Svante Signell 
  * libgo/testsuite/gotest: Remove ps -o comm option for GNU/Hurd.

Index: gcc-9-9-20190208/src/libgo/testsuite/gotest
===
--- gcc-9-9-20190208.orig/src/libgo/testsuite/gotest
+++ gcc-9-9-20190208/src/libgo/testsuite/gotest
@@ -650,7 +650,11 @@ xno)
 		wait $pid
 		status=$?
 		if ! test -f gotest-timeout; then
-		sleeppid=`ps -o pid,ppid,comm | grep " $alarmpid " | grep sleep | sed -e 's/ *\([0-9]*\) .*$/\1/'`
+		if test "$goos" = "hurd"; then
+			sleeppid=`ps -o pid,ppid | grep " $alarmpid " | grep sleep | sed -e 's/ *\([0-9]*\) .*$/\1/'`
+		else
+			sleeppid=`ps -o pid,ppid,comm | grep " $alarmpid " | grep sleep | sed -e 's/ *\([0-9]*\) .*$/\1/'`
+		fi
 		kill $alarmpid
 		wait $alarmpid
 		if test "$sleeppid" != ""; then


Re: [PATCH] Updated patches for the port of gccgo to GNU/Hurd

2019-02-09 Thread Svante Signell
On Sat, 2019-02-09 at 14:40 -0800, Ian Lance Taylor wrote:
> On Fri, Feb 8, 2019 at 3:07 PM Matthias Klose  wrote:
> > On 07.02.19 06:04, Ian Lance Taylor wrote:

> What are the lines before that in the log?  For some reason libtool is
> being invoke with no source files.  The lines before the failing line
> should show an invocation of match.sh that determines the source
> files.

Thanks for your job upstreaming the patches!

I've found some problems. Current problem is with the mksysinfo.sh patch. But
there are some other things missing. New patches will be submitted tomorrow. 

Thanks!



Add split_stack support for GNU/Hurd

2019-01-12 Thread Svante Signell
Hello,

I order to prepare for inclusion of gccgo to GNU/Hurd split stack support has
been proposed, and in reality this patch has been applied to Debian since gcc-6.

Please commit this patch. Late on updated patches for gccgo in gcc-8 and gcc-9?
will be reviewed and committed with the aid of Ian Lance Taylor and Matthis
Klose.

Thanks!

gcc/config/ChangeLog

2018-10-10  Svante Signell 
  * gcc/config/i386/gnu.h: Enable split-stack support

Index: gcc-snapshot-20181019-1.1/src/gcc/config/i386/gnu.h
===
--- gcc-snapshot-20181019-1.1.orig/src/gcc/config/i386/gnu.h
+++ gcc-snapshot-20181019-1.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_OFFSET0x14
 
+/* 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


Re: GOOS updated: Port of gccgo to GNU/Hurd

2018-11-03 Thread Svante Signell
ping, no feedback so far, is anything missing/are the patches rejected?

On Sat, 2018-10-27 at 20:43 +0200, Svante Signell wrote:
> Hello,
> 
> As advised by the Debian gcc maintainer Matthias Klose and golang
> developer Ian Lance Taylor I'm (re-)submitting the patches for
> the port of gccgo to GNU/Hurd again. Now GOOS value is changed from
> gnu
> to hurd as requested.
> 
> The 13 patches are:
> src_gcc_config_i386_gnu.h.diff
> src_libgo_build.diff
> src_libgo_go_crypto.diff
> src_libgo_go_go_build_syslist.go.diff
> src_libgo_go_net.diff
> src_libgo_go_os.diff
> src_libgo_go_runtime.diff
> src_libgo_go_syscall.diff
> src_libgo_go_syscall_syscall_gnu_test.go.diff
> src_libgo_runtime.diff
> src_libgo_testsuite_gotest.diff
> add-gnu-to-libgo-headers.diff
> add-gnu-to-libgo-test-headers.diff
> 
> Preliminary ChangeLog entries are included in each patch.
> 
> With them the latest the latest Debian gcc-snapshot (20181019-1) has
> been successfully built. Test results for libgo and go:
> 
> === libgo Summary ===
> 
> # of expected passes162
> # of unexpected failures21
> 
> === go Summary ===
> 
> # of expected passes7394
> # of unexpected failures10
> # of expected failures  1
> # of untested testcases 7
> # of unsupported tests  2
> 
> Thanks!


Re: Port of gccgo to GNU/Hurd

2018-10-22 Thread Svante Signell
On Mon, 2018-10-22 at 11:15 +0200, Svante Signell wrote:
> Hello,
> 
> As advised by the Debian gcc maintainer Matthias Klose and golang
> developer Ian Lance Taylor (Cc:ed) I'm (re-)submitting the patches
> for the port of gccgo to GNU/Hurd.
> 
> The 13 patches are:

Due to some editing errors this patch had to be updated:
> src_libgo_go_syscall_syscall_gnu_test.go.diff


Thanks!libgo/ChangeLog

2018-10-20  Svante Signell 
  * libgo/go/syscall/syscall_gnu_test.go: New file,
  derived from syscall_unix_test.go. Flock_t members
  Type and Whence are int32 instead of int16.
  
Index: gcc-snapshot-20181019-1.1/src/libgo/go/syscall/syscall_gnu_test.go
===
--- /dev/null
+++ gcc-snapshot-20181019-1.1/src/libgo/go/syscall/syscall_gnu_test.go
@@ -0,0 +1,357 @@
+// Copyright 2013 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.
+// This file is identical to syscall_unix_test.go except that
+// Flock_t members Type and Whence are int32 instead of int16.
+
+// +build gnu
+
+package syscall_test
+
+import (
+	"flag"
+	"fmt"
+	"internal/testenv"
+	"io"
+	"io/ioutil"
+	"net"
+	"os"
+	"os/exec"
+	"path/filepath"
+	"runtime"
+	"syscall"
+	"testing"
+	"time"
+)
+
+// Tests that below functions, structures and constants are consistent
+// on all Unix-like systems.
+func _() {
+	// program scheduling priority functions and constants
+	var (
+		_ func(int, int, int) error   = syscall.Setpriority
+		_ func(int, int) (int, error) = syscall.Getpriority
+	)
+	const (
+		_ int = syscall.PRIO_USER
+		_ int = syscall.PRIO_PROCESS
+		_ int = syscall.PRIO_PGRP
+	)
+
+	// termios constants
+	const (
+		_ int = syscall.TCIFLUSH
+		_ int = syscall.TCIOFLUSH
+		_ int = syscall.TCOFLUSH
+	)
+
+	// fcntl file locking structure and constants
+	var (
+		_ = syscall.Flock_t{
+			Type:   int32(0),
+			Whence: int32(0),
+			Start:  int64(0),
+			Len:int64(0),
+			Pid:int32(0),
+		}
+	)
+	const (
+		_ = syscall.F_GETLK
+		_ = syscall.F_SETLK
+		_ = syscall.F_SETLKW
+	)
+}
+
+// TestFcntlFlock tests whether the file locking structure matches
+// the calling convention of each kernel.
+// On some Linux systems, glibc uses another set of values for the
+// commands and translates them to the correct value that the kernel
+// expects just before the actual fcntl syscall. As Go uses raw
+// syscalls directly, it must use the real value, not the glibc value.
+// Thus this test also verifies that the Flock_t structure can be
+// roundtripped with F_SETLK and F_GETLK.
+func TestFcntlFlock(t *testing.T) {
+	if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
+		t.Skip("skipping; no child processes allowed on iOS")
+	}
+	flock := syscall.Flock_t{
+		Type:  syscall.F_WRLCK,
+		Start: 31415, Len: 271828, Whence: 1,
+	}
+	if os.Getenv("GO_WANT_HELPER_PROCESS") == "" {
+		// parent
+		tempDir, err := ioutil.TempDir("", "TestFcntlFlock")
+		if err != nil {
+			t.Fatalf("Failed to create temp dir: %v", err)
+		}
+		name := filepath.Join(tempDir, "TestFcntlFlock")
+		fd, err := syscall.Open(name, syscall.O_CREAT|syscall.O_RDWR|syscall.O_CLOEXEC, 0)
+		if err != nil {
+			t.Fatalf("Open failed: %v", err)
+		}
+		defer os.RemoveAll(tempDir)
+		defer syscall.Close(fd)
+		if err := syscall.Ftruncate(fd, 1<<20); err != nil {
+			t.Fatalf("Ftruncate(1<<20) failed: %v", err)
+		}
+		if err := syscall.FcntlFlock(uintptr(fd), syscall.F_SETLK, ); err != nil {
+			t.Fatalf("FcntlFlock(F_SETLK) failed: %v", err)
+		}
+		cmd := exec.Command(os.Args[0], "-test.run=^TestFcntlFlock$")
+		cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1")
+		cmd.ExtraFiles = []*os.File{os.NewFile(uintptr(fd), name)}
+		out, err := cmd.CombinedOutput()
+		if len(out) > 0 || err != nil {
+			t.Fatalf("child process: %q, %v", out, err)
+		}
+	} else {
+		// child
+		got := flock
+		// make sure the child lock is conflicting with the parent lock
+		got.Start--
+		got.Len++
+		if err := syscall.FcntlFlock(3, syscall.F_GETLK, ); err != nil {
+			t.Fatalf("FcntlFlock(F_GETLK) failed: %v", err)
+		}
+		flock.Pid = int32(syscall.Getppid())
+		// Linux kernel always set Whence to 0
+		flock.Whence = 0
+		if got.Type == flock.Type && got.Start == flock.Start && got.Len == flock.Len && got.Pid == flock.Pid && got.Whence == flock.Whence {
+			os.Exit(0)
+		}
+		t.Fatalf("FcntlFlock got %v, want %v", got, flock)
+	}
+}
+
+// TestPassFD tests passing a file descriptor over a Unix socket.
+//
+// This test involved b

Re: PATCH: Hurd port of go to gcc-8 (gcc-8-8-20180310+) 16 patches

2018-03-13 Thread Svante Signell
On Mon, 2018-03-12 at 14:44 +0100, Svante Signell wrote:
> On Mon, 2018-03-12 at 13:29 +0100, Svante Signell wrote:
> 
> 
> > The patches really changed are only four:
> > src_libgo_runtime.diff
> > src_libgo_go_go_build_syslist.go.diff
> > src_libgo_go_runtime.diff
> > src_libgo_build.diff
> 
> Correction: five:
> add-gnu-to-libgo-headers.diff

And src_libgo_go_syscall.diff, eventually more. Best to use the complete set.

Regarding test suites the go test results are the same as for e.g. amd64:
This time the problem is with the symbol __libc_start_main@@GLIBC_2.2.6.

tail build/gcc/testsuite/go/go.sum

=== go Summary ===

# of expected passes518
# of untested testcases 834

grep ^FAIL: build/gcc/testsuite/go/go.log
FAIL: checksyms x 8
checksyms: found unexpected symbol "__libc_start_main@@GLIBC_2.2.6"

These problems are reported in debian bug #892167


Re: PATCH: Hurd port of go to gcc-8 (gcc-8-8-20180310+) 16 patches

2018-03-12 Thread Svante Signell
On Mon, 2018-03-12 at 13:29 +0100, Svante Signell wrote:


> The patches really changed are only four:
> src_libgo_runtime.diff
> src_libgo_go_go_build_syslist.go.diff
> src_libgo_go_runtime.diff
> src_libgo_build.diff

Correction: five:
add-gnu-to-libgo-headers.diff


Update: Hurd port for gcc-7 go : 7.3.0-8+ for glibc 2.26+

2018-03-10 Thread Svante Signell
Hi,

Attached is the updated patch, src_libgo_build.diff, to build gccgo properly on
Debian GNU/Hurd on gcc-7 (7-7.3.0-{8,9,10}) again after the update of glibc to
2.26+

The libgo tests show the following:

=== libgo Summary ===

# of expected passes119
# of unexpected failures26

Replacing the stub code of netpoll_gnu.go with a poll-based implementation the
libgo tests improves to:

=== libgo Summary ===

# of expected passes124
# of unexpected failures21

The change is reflected in the updated version of src_libgo_go_runtime.diff,
also attached!

Thanks!Index: gcc-7-7.3.0-8.1/src/libgo/configure.ac
===
--- gcc-7-7.3.0-8.1.orig/src/libgo/configure.ac
+++ gcc-7-7.3.0-8.1/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.3.0-8.1/src/libgo/Makefile.am
===
--- gcc-7-7.3.0-8.1.orig/src/libgo/Makefile.am
+++ gcc-7-7.3.0-8.1/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.3.0-8.1/src/libgo/Makefile.in
===
--- gcc-7-7.3.0-8.1.orig/src/libgo/Makefile.in
+++ gcc-7-7.3.0-8.1/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

Re: Fix gcc-7 and gcc-8 build of GO for Hurd and not kFreeBSD in debian/rules.defs

2017-11-20 Thread Svante Signell
On Mon, 2017-11-20 at 14:04 +0100, Aurelien Jarno wrote:
> On 2017-11-20 13:20, Svante Signell wrote:
> > On Thu, 2017-11-16 at 20:39 +0100, Svante Signell wrote:
> > 
> > Seeing the recent update of debian/rules.defs in gcc-7 a mistake was
> > revealed in the patch debian_rules.defs for both gcc-7 and gcc-8. The
> > correct patch is inlined below:
> > 
> > --- a/debian/rules.defs 2017-11-20 12:59:25.0 +0100
> > +++ b/debian/rules.defs 2017-11-20 13:01:54.0 +0100
> > @@ -807,7 +807,7 @@
> >  ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty
> > karmic
> > lucid maverick natty oneiric))
> >    go_no_cpus := $(filter-out arm, $(go_no_cpus))
> >  endif
> > -go_no_systems := gnu kfreebsd-gnu
> > +go_no_systems := kfreebsd
> >  
> >  ifneq ($(with_base_only),yes)
> >    ifneq ($(separate_lang),yes)
> > @@ -817,7 +817,7 @@
> >  ifneq (,$(filter $(DEB_TARGET_ARCH_CPU),$(go_no_cpus)))
> >    with_go := disabled for cpu $(DEB_TARGET_ARCH_CPU)
> >  endif
> > -ifneq (,$(findstring $(DEB_TARGET_GNU_SYSTEM),$(go_no_systems)))
> > +ifneq (,$(findstring $(DEB_TARGET_ARCH_OS),$(go_no_systems)))
> >    with_go := disabled for system $(DEB_TARGET_GNU_SYSTEM)
> >  endif
> >  ifeq ($(go_no_cross)-$(DEB_CROSS),yes-yes)
> > 
> > Changing back to go_no_systems := kfreebsd-gnu as aurel32 did disables the
> > build of go also for GNU/Hurd. The culprit is to match DEB_TARGET_ARCH_OS to
> > kfreebsd to disable the build of go for GNU/kFreeBSD, not to match
> > DEB_TARGET_GNU_SYSTEM to kfreebsd-gnu, since that will match gnu too :(
> 
> I did that change because changing go_no_systems from kfreebsd-gnu to
> kfreebsd is what caused GCC 7 to FTBFS on at least kfreebsd-i386 since
> version 7.2.0-15 (see bug#881656).
> 
> Your change also looks fine to me. Should I commit it?

Yes please. And do this change also for gcc-8, otherwise it will FTBFS on
kFreeBSD too.


Fix gcc-7 and gcc-8 build of GO for Hurd and not kFreeBSD in debian/rules.defs

2017-11-20 Thread Svante Signell
On Thu, 2017-11-16 at 20:39 +0100, Svante Signell wrote:

Seeing the recent update of debian/rules.defs in gcc-7 a mistake was revealed in
the patch debian_rules.defs for both gcc-7 and gcc-8. The correct patch is
inlined below:

--- a/debian/rules.defs 2017-11-20 12:59:25.0 +0100
+++ b/debian/rules.defs 2017-11-20 13:01:54.0 +0100
@@ -807,7 +807,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic
lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
@@ -817,7 +817,7 @@
 ifneq (,$(filter $(DEB_TARGET_ARCH_CPU),$(go_no_cpus)))
   with_go := disabled for cpu $(DEB_TARGET_ARCH_CPU)
 endif
-ifneq (,$(findstring $(DEB_TARGET_GNU_SYSTEM),$(go_no_systems)))
+ifneq (,$(findstring $(DEB_TARGET_ARCH_OS),$(go_no_systems)))
   with_go := disabled for system $(DEB_TARGET_GNU_SYSTEM)
 endif
 ifeq ($(go_no_cross)-$(DEB_CROSS),yes-yes)

Changing back to go_no_systems := kfreebsd-gnu as aurel32 did disables the build
of go also for GNU/Hurd. The culprit is to match DEB_TARGET_ARCH_OS to kfreebsd
to disable the build of go for GNU/kFreeBSD, not to match DEB_TARGET_GNU_SYSTEM
to kfreebsd-gnu, since that will match gnu too :(

rules.defs is OK for gcc-5 and gcc-6.



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

2017-11-16 Thread Svante Signell
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/ 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 ' | ${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

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

2017-11-16 Thread Svante Signell
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//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 =

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

2017-11-15 Thread Svante Signell
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!



Hurd port for gcc-8 go PATCH 11-15(15)

2017-11-10 Thread Svante Signell
* add-gnu-to-libgo-headers.diff: Add gnu to libgo headers for build.
* add-gnu-to-libgo-test-headers.diff: Add gnu to libgo headers for tests.
* src_libgo_go_go_build_syslist.go.diff: Add gnu to the goosList.
* src_libgo_go_syscall_syscall_gnu_test.go.diff: gnu-specific file for tests
involving struct flock.
* src_libgo_testsuite_gotest.diff: gnu-specific gotest output.Index: gcc-8-8-20171108-1.1/src/libgo/go/archive/tar/stat_atim.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/archive/tar/stat_atim.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/archive/tar/stat_atim.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux dragonfly openbsd solaris
+// +build gnu linux dragonfly openbsd solaris
 
 package tar
 
Index: gcc-8-8-20171108-1.1/src/libgo/go/cmd/go/internal/base/signal_unix.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/cmd/go/internal/base/signal_unix.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/cmd/go/internal/base/signal_unix.go
@@ -1,8 +1,9 @@
+
 // Copyright 2012 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.
 
-// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd gnu linux nacl netbsd openbsd solaris
 
 package base
 
Index: gcc-8-8-20171108-1.1/src/libgo/go/crypto/x509/root_unix.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/crypto/x509/root_unix.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/crypto/x509/root_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build aix dragonfly freebsd gnu linux nacl netbsd openbsd solaris
 
 package x509
 
Index: gcc-8-8-20171108-1.1/src/libgo/go/net/interface_stub.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/net/interface_stub.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/net/interface_stub.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix nacl
+// +build aix nacl gnu
 
 package net
 
Index: gcc-8-8-20171108-1.1/src/libgo/go/net/internal/socktest/switch_unix.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/net/internal/socktest/switch_unix.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/net/internal/socktest/switch_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd gnu linux nacl netbsd openbsd solaris
 
 package socktest
 
Index: gcc-8-8-20171108-1.1/src/libgo/go/net/port_unix.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/net/port_unix.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/net/port_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris nacl
+// +build aix darwin dragonfly freebsd gnu linux netbsd openbsd solaris nacl
 
 // Read system port mappings from /etc/services
 
Index: gcc-8-8-20171108-1.1/src/libgo/go/os/dir_largefile.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/os/dir_largefile.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/os/dir_largefile.go
@@ -5,7 +5,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix linux solaris,386 solaris,sparc
+// +build aix gnu linux solaris,386 solaris,sparc
 
 package os
 
Index: gcc-8-8-20171108-1.1/src/libgo/go/os/dir_regfile.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/os/dir_regfile.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/os/dir_regfile.go
@@ -6,6 +6,7 @@
 // license that can be found in the LICENSE file.
 
 // +build !aix
+// +build !gnu
 // +build !linux
 // +build !solaris !386
 // +build !solaris !sparc
Index: gcc-8-8-20171108-1.1/src/libgo/go/os/dir_unix.go
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/go/os/dir_unix.go
+++ gcc-8-8-20171108-1.1/src/libgo/go/os/dir_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build aix darwin dragonfly freebsd linux nacl netbsd 

Hurd port for gcc-8 go PATCH 4-10(15)

2017-11-10 Thread Svante Signell
* src_libgo_build.diff: configure.ac, Makefile.* and shell script patches.
* src_libgo_go_crypto.diff: Certificate go files.
* src_libgo_go_net.diff: OS-specific net go files.
* src_libgo_go_os.diff: OS-specific os go files.
* src_libgo_go_runtime.diff: OS-specific runtime go files.
* src_libgo_go_syscall.diff: OS-specific syscall go files.
* src_libgo_runtime.diff: OS-specific runtime C files.Index: gcc-8-8-20171108-1.1/src/libgo/configure.ac
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/configure.ac
+++ gcc-8-8-20171108-1.1/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-1.1/src/libgo/Makefile.am
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/Makefile.am
+++ gcc-8-8-20171108-1.1/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-1.1/src/libgo/Makefile.in
===
--- gcc-8-8-20171108-1.1.orig/src/libgo/Makefile.in
+++ gcc-8-8-20171108-1.1/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 =
 
 # 

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

2017-11-10 Thread Svante Signell
Hi,

Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-8 (8-8-20171108-1).

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 passes7359
# of unexpected failures13
# of expected failures  1
# of untested testcases 7
# of unsupported tests  2

=== libgo Summary ===

# of expected passes128
# of unexpected failures27

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. I'm currently working on an implementation using poll(2). 

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!--- a/debian/rules.defs.orig	2017-08-14 14:40:23.0 +0200
+++ b/debian/rules.defs		2017-08-14 15:26:42.0 +0200
@@ -807,7 +807,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
--- a/debian/rules.patch	2017-09-06 11:49:38.0 +0200
+++ b/debian/rules.patch	2017-09-06 12:02:13.0 +0200
@@ -228,7 +228,21 @@
 endif
 
 ifeq ($(DEB_TARGET_ARCH_OS),hurd)
-  debian_patches += hurd-changes
+  debian_patches += hurd-changes \
+src_gcc_config_i386_gnu.h \
+src_libgo_build \
+src_libgo_runtime \
+src_libgo_go_crypto \
+src_libgo_go_net \
+src_libgo_go_os \
+src_libgo_go_runtime \
+src_libgo_go_syscall \
+src_libgo_go_go_build_syslist.go \
+add-gnu-to-libgo-headers \
+add-gnu-to-libgo-test-headers \
+src_libgo_go_syscall_syscall_gnu_test.go \
+src_libgo_testsuite_gotest \
+
 endif
 
 debian_patches += gcc-ice-dump
Index: gcc-8-8-20171108-1.1/src/gcc/config/i386/gnu.h
===
--- gcc-8-8-20171108-1.1.orig/src/gcc/config/i386/gnu.h
+++ gcc-8-8-20171108-1.1/src/gcc/config/i386/gnu.h
@@ -37,11 +37,14 @@ along with GCC.  If not, see 

Hurd port for gcc-7 go PATCH 11-15(15)

2017-11-06 Thread Svante Signell
* add-gnu-to-libgo-headers.diff: Add gnu to libgo headers for build.
* add-gnu-to-libgo-test-headers.diff: Add gnu to libgo headers for tests.
* src_libgo_go_go_build_syslist.go.diff: Add gnu to the goosList.
* src_libgo_go_syscall_syscall_gnu_test.go.diff: gnu-specific file for tests
involving struct flock.
* src_libgo_testsuite_gotest.diff: gnu-specific gotest output.
Index: gcc-7-7.2.0-12.1/src/libgo/go/archive/tar/stat_atim.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/archive/tar/stat_atim.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/archive/tar/stat_atim.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux dragonfly openbsd solaris
+// +build gnu linux dragonfly openbsd solaris
 
 package tar
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/cmd/go/signal_unix.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/cmd/go/signal_unix.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/cmd/go/signal_unix.go
@@ -1,8 +1,9 @@
+
 // Copyright 2012 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.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd gnu linux nacl netbsd openbsd solaris
 
 package main
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/crypto/x509/root_unix.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/crypto/x509/root_unix.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/crypto/x509/root_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build dragonfly freebsd gnu linux nacl netbsd openbsd solaris
 
 package x509
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/net/fd_poll_runtime.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/net/fd_poll_runtime.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/net/fd_poll_runtime.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd windows solaris
+// +build darwin dragonfly freebsd gnu linux netbsd openbsd windows solaris
 
 package net
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/net/interface_stub.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/net/interface_stub.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/net/interface_stub.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build nacl
+// +build nacl gnu
 
 package net
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/net/internal/socktest/switch_unix.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/net/internal/socktest/switch_unix.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/net/internal/socktest/switch_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd gnu linux nacl netbsd openbsd solaris
 
 package socktest
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/net/port_unix.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/net/port_unix.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/net/port_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris nacl
+// +build darwin dragonfly freebsd gnu linux netbsd openbsd solaris nacl
 
 // Read system port mappings from /etc/services
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/os/dir_largefile.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/os/dir_largefile.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/os/dir_largefile.go
@@ -5,7 +5,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux solaris,386 solaris,sparc
+// +build gnu linux solaris,386 solaris,sparc
 
 package os
 
Index: gcc-7-7.2.0-12.1/src/libgo/go/os/dir_regfile.go
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/go/os/dir_regfile.go
+++ gcc-7-7.2.0-12.1/src/libgo/go/os/dir_regfile.go
@@ -5,6 +5,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build !gnu
 // +build !linux
 // +build !solaris !386
 // +build !solaris !sparc
Index: 

Hurd port for gcc-7 go PATCH 4-10(15)

2017-11-06 Thread Svante Signell
* src_libgo_build.diff: configure.ac, Makefile.* and shell script patches.
* src_libgo_go_crypto.diff: Certificate go files.
* src_libgo_go_net.diff: OS-specific net go files.
* src_libgo_go_os.diff: OS-specific os go files.
* src_libgo_go_runtime.diff: OS-specific runtime go files.
* src_libgo_go_syscall.diff: OS-specific syscall go files.
* src_libgo_runtime.diff: OS-specific runtime C files.Index: gcc-7-7.2.0-12.1/src/libgo/configure.ac
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/configure.ac
+++ gcc-7-7.2.0-12.1/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-12.1/src/libgo/Makefile.am
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/Makefile.am
+++ gcc-7-7.2.0-12.1/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-12.1/src/libgo/Makefile.in
===
--- gcc-7-7.2.0-12.1.orig/src/libgo/Makefile.in
+++ gcc-7-7.2.0-12.1/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

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

2017-11-06 Thread Svante Signell
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 passes7359
# of unexpected failures13
# of expected failures  1
# of untested testcases 7
# of unsupported tests  2

=== libgo Summary ===

# of expected passes119
# of unexpected failures26

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!
--- a/debian/rules.defs.orig	2017-08-14 14:40:23.0 +0200
+++ b/debian/rules.defs		2017-08-14 15:26:42.0 +0200
@@ -804,7 +804,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
--- a/debian/rules.patch	2017-09-06 11:49:38.0 +0200
+++ b/debian/rules.patch	2017-09-06 12:02:13.0 +0200
@@ -235,7 +235,21 @@
 endif
 
 ifeq ($(DEB_TARGET_ARCH_OS),hurd)
-  debian_patches += hurd-changes
+  debian_patches += hurd-changes \
+src_gcc_config_i386_gnu.h \
+src_libgo_build \
+src_libgo_runtime \
+src_libgo_go_crypto \
+src_libgo_go_net \
+src_libgo_go_os \
+src_libgo_go_runtime \
+src_libgo_go_syscall \
+src_libgo_go_go_build_syslist.go \
+add-gnu-to-libgo-headers \
+add-gnu-to-libgo-test-headers \
+src_libgo_go_syscall_syscall_gnu_test.go \
+src_libgo_testsuite_gotest \
+
 endif
 
 debian_patches += gcc-ice-dump
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 

Re: Hurd port for gcc go PATCH 1-4(23)

2016-12-07 Thread Svante Signell
On Wed, 2016-12-07 at 17:25 +0100, Samuel Thibault wrote:
> Svante Signell, on Wed 07 Dec 2016 15:32:31 +0100, wrote:
> > On Wed, 2016-12-07 at 15:08 +0100, Samuel Thibault wrote:
> > > Ok, but then I'd say move the function which change to a separate file,
> > > so that the other functions are kept shared.
> > > Otherwise it'll be tedious to maintain.
> > 
> > One problem is the file go/syscall/libcall_posix-1.go, derived
> > from go/syscall/libcall_posix.go but _removing_ four function definitions:
> > mount, madvise, mlockall and munlockall.
> 
> That's not a problem: move them out to another file, and include that
> file in the non-gnu case, but do not include that file in the gnu case.
> 
> Actually it's even odd to see mount among them, it's not a standard
> posix interface.

I'm sorry but neither of you or I are in the position to request changes of
already existing file names e.g. replacing linux with glibc in:
os/pipe_linux.go
crypto/x509/root_linux.go
syscall/errstr_linux.go

Neither are we in the position to request to rename libcall_posix.go to
something else, or move the four functions definitions mount, mlocall,
munlockall, madvise, mentioned above to a separate file.

So far, nobody, upstream or debian-gcc, have made any comment on the patches
whatsoever. So what are we doing? Let's forget about porting gccgo to GNU/Hurd.

Thanks!


Re: Hurd port for gcc go PATCH 1-4(23)

2016-12-07 Thread Svante Signell
On Wed, 2016-12-07 at 15:08 +0100, Samuel Thibault wrote:
> Svante Signell, on Wed 07 Dec 2016 14:52:35 +0100, wrote:
> > Since go does not have a preprocessor allowing conditional code paths this
> > is
> > how it should be done (and as I did):
> > http://blog.ralch.com/tutorial/golang-conditional-compilation/
> 
> Ok, but then I'd say move the function which change to a separate file,
> so that the other functions are kept shared.
> Otherwise it'll be tedious to maintain.

One problem is the file go/syscall/libcall_posix-1.go, derived
from go/syscall/libcall_posix.go but _removing_ four function definitions:
mount, madvise, mlockall and munlockall. A possible solution would then be to
rename that file to libcall_posix_gnu.go. The file libcall_gnu.go name is
already used.


Re: Hurd port for gcc go PATCH 1-4(23)

2016-12-07 Thread Svante Signell
On Sun, 2016-11-27 at 18:02 +0100, Samuel Thibault wrote:
> Hello,
> 
> Svante Signell, on Sun 27 Nov 2016 17:33:52 +0100, wrote:
> > > > 
> > > And
> > > src_libgo_go_syscall_syscall_gnu_test.go: New file:
> > >   Define Type and Whence as 32bit in syscall.Flock_t
> > > 
> > > Again, you'll probably have to discuss with upstream to see how they
> > > prefer to make it configurable rather than forking the whole file.
> > > 

I found the answer, see below!

> > I tried to patch the syscall_unix_test.go file, but did not succeed. 
> > Definitely if runtime.GOOS == "GNU" ... else ... or switch runtime.GOOS
> > ... does not work. The compiler sees all code and complains, also the
> > else part of the code :( Therefore I created a new file.
> 
> Then ask upstream how they think it can and should be done.
> 

Since go does not have a preprocessor allowing conditional code paths this is
how it should be done (and as I did):
http://blog.ralch.com/tutorial/golang-conditional-compilation/

Verdict
===
We should aim to develop and build our Go applications by following Go idioms.
If the source file targets a specific platform, we should choose file suffix
approach. Otherwise, if the source file is applicable for multiple platforms and
we want to exclude a specific feature or platform, we should use build
constraints instead.

Build constraints
=
A build constraints (known as build tags) is an optional top line comment that
starts with

// +build

package api

File suffixes
=
The second option for conditional compilation is the name of the
source file itself. This approach is simpler than build tags, and allows
the Go build system to exclude files without having to process the file.

We should add one of the following suffixes to desired files:

*_GOOS // operation system
*_GOARCH // platform architecture
*_GOOS_GOARCH // both combined



Re: Hurd port for gcc go PATCH 1-4(23)

2016-11-27 Thread Svante Signell
On Sun, 2016-11-27 at 18:02 +0100, Samuel Thibault wrote:
> Hello,
...
> > But as you wish, an updated patch is attached.
> 
>  _Bool
>  Continued (uint32_t *w)
>  {
> +#ifndef WCONTINUED
> +  *w = 0;
> +  return 0;
> +#else
>    return WIFCONTINUED (*w) != 0;
> +#endif
>  }
> 
> Err, recheck the semantic of WCONTINUED again, it doesn't modify its
> parameter, it just tests its value.
> 
> Do as I said, just return 0.
> 

No I can't the compiler complains about an unused variable. Maybe
adding an __attribute__((unused)) to the function header?

...

> 
> > This is for upstream to decide.
> 
> I'm just afraid they'd just frown on the code submission and not take
> the time to explain how they want it to look like if we don't raise
> the
> discussion ourselves.
> 

Should we propose these changes upstream? Or do you mean something
else? 

> > > And
> > > src_libgo_go_syscall_syscall_gnu_test.go: New file:
> > >   Define Type and Whence as 32bit in syscall.Flock_t
> > > 
> > > Again, you'll probably have to discuss with upstream to see how
> > > they
> > > prefer to make it configurable rather than forking the whole
> > > file.
> > > 
> > 
> > I tried to patch the syscall_unix_test.go file, but did not
> > succeed. 
> > Definitely if runtime.GOOS == "GNU" ... else ... or switch
> > runtime.GOOS
> > ... does not work. The compiler sees all code and complains, also
> > the
> > else part of the code :( Therefore I created a new file.
> 
> Then ask upstream how they think it can and should be done.
> 

Upstream would be Ian Lance Taylor, right?

> > > > -CLEANFILES = *.go *.gox goc2c *.c s-version libgo.sum
> > > > libgo.log
> > > > +CLEANFILES = *.go *.gox goc2c *.c s-* libgo.sum libgo.log
> > > 
> > > This seems unrelated?
> > > 
> > No, this is not unrelated: With this patch you can
> > make -C build/i686-gnu/libgo clean
> > make -C build/i686-gnu/libgo
> > to rebuild libgo. Otherwise libcalls.go is not regenerated,
> > mksysinfo.sh is not run etc. 
> 
> That's still unrelated to the matter here: porting go to
> GNU/Hurd.  It
> looks like a bug fix which is completely independant from GNU/Hurd.

Yes it is not Hurd-related. Maybe this should be filed as a separate
bug. To gcc upstream directly?

> > > 
> > > 
> > > We could rather just implement the comm field in ps, AIUI it's
> > > just an alias for the command field.
> > 
> > Your choice. When implemented this patch wouldn't bee needed.
> 
> Then please do implement it :)

Sorry, I need help for doing this. Any other Hurd developer listening?

Thanks for reviewing :) Nice to see that anybody cares.



Hurd port for gcc go PATCH 19-23(23)

2016-11-25 Thread Svante Signell
* src_libgo_runtime_netpoll.goc.diff: Fix restricted word bug.
  Rename variable errno to errno1.
* src_libgo_go_os_os_test.go.diff: Allow EFBIG return code to big
seeks.
* src_libgo_go_syscall_syscall_gnu_test.go: New file:
  Define Type and Whence as 32bit in syscall.Flock_t
* src_libgo_testsuite_gotest.diff: Remove comm option for ps -o.
* add-gnu-to-libgo-headers.diff:
  Add gnu to +build entry in file headers included in the build.
  FIXME:  Index: gcc-6-6.2.1-4.1/src/libgo/go/archive/tar/stat_atim.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/archive/tar/stat_atim.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/archive/tar/stat_atim.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux dragonfly openbsd solaris
+// +build linux dragonfly openbsd solaris gnu
 
 package tar
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_resnew.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/cgo_resnew.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_resnew.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build cgo,!netgo
-// +build darwin linux,!android netbsd solaris
+// +build darwin linux,!android netbsd solaris gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_socknew.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/cgo_socknew.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_socknew.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build cgo,!netgo
-// +build android linux solaris
+// +build android linux solaris gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/hook_cloexec.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/hook_cloexec.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/hook_cloexec.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build freebsd linux
+// +build freebsd linux gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/main_unix_test.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/main_unix_test.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/main_unix_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sock_cloexec.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/sock_cloexec.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sock_cloexec.go
@@ -5,7 +5,7 @@
 // This file implements sysSocket and accept for platforms that
 // provide a fast path for setting SetNonblock and CloseOnExec.
 
-// +build freebsd linux
+// +build freebsd linux gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sockoptip_posix.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/sockoptip_posix.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sockoptip_posix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd windows
+// +build darwin dragonfly freebsd linux netbsd openbsd windows gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/syscall/exec_unix.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/syscall/exec_unix.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/syscall/exec_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris gnu
 
 // Fork, exec, wait, etc.
 
Index: gcc-6-6.2.1-4.1/src/libgo/runtime/netpoll_select.c
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/runtime/netpoll_select.c
+++ gcc-6-6.2.1-4.1/src/libgo/runtime/netpoll_select.c
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build solaris
+// +build solaris gnu
 
 #include "config.h"
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/os/exec/lp_unix.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/os/exec/lp_unix.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/os/exec/lp_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be 

Hurd port for gcc go PATCH 11-18(23)

2016-11-25 Thread Svante Signell
* src_libgo_go_net_sendfile_gnu.go.diff: New file
* src_libgo_go_net_sock_gnu.go.diff: New file
* src_libgo_go_net_sockopt_gnu.go.diff: New file
* src_libgo_go_net_sockoptip_gnu.go.diff: New file
* src_libgo_go_syscall_libcall_gnu_386.go.diff: New file
* src_libgo_go_syscall_libcall_gnu.go.diff: New file
* src_libgo_go_syscall_libcall_posix-1.go.diff: New file derived from
libcall_posix.go
  Removed the mount call for GNU/Hurd, it exists but use translators.
  Removed the mlockall/munlockall calls for GNU/Hurd, not yet
implemented.
  Removed the madvise call for GNU/Hurd, not yet implemented.
* src_libgo_go_syscall_socket_gnu.go.diff: New fileIndex: gcc-6-6.2.1-4.1/src/libgo/go/net/sendfile_gnu.go
===
--- /dev/null
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sendfile_gnu.go
@@ -0,0 +1,79 @@
+// 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.
+
+package net
+
+import (
+	"io"
+	"os"
+	"syscall"
+)
+
+// maxSendfileSize is the largest chunk size we ask the kernel to copy
+// at a time.
+const maxSendfileSize int = 4 << 20
+
+// sendFile copies the contents of r to c using the sendfile
+// system call to minimize copies.
+//
+// if handled == true, sendFile returns the number of bytes copied and any
+// non-EOF error.
+//
+// if handled == false, sendFile performed no work.
+func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
+	var remain int64 = 1 << 62 // by default, copy until EOF
+
+	lr, ok := r.(*io.LimitedReader)
+	if ok {
+		remain, r = lr.N, lr.R
+		if remain <= 0 {
+			return 0, nil, true
+		}
+	}
+	f, ok := r.(*os.File)
+	if !ok {
+		return 0, nil, false
+	}
+
+	if err := c.writeLock(); err != nil {
+		return 0, err, true
+	}
+	defer c.writeUnlock()
+
+	dst := c.sysfd
+	src := int(f.Fd())
+	for remain > 0 {
+		n := maxSendfileSize
+		if int64(n) > remain {
+			n = int(remain)
+		}
+		n, err1 := syscall.Sendfile(dst, src, nil, n)
+		if n > 0 {
+			written += int64(n)
+			remain -= int64(n)
+		}
+		if n == 0 && err1 == nil {
+			break
+		}
+		if err1 == syscall.EAGAIN {
+			if err1 = c.pd.WaitWrite(); err1 == nil {
+continue
+			}
+		}
+		if err1 != nil {
+			// This includes syscall.ENOSYS (no kernel
+			// support) and syscall.EINVAL (fd types which
+			// don't implement sendfile)
+			err = err1
+			break
+		}
+	}
+	if lr != nil {
+		lr.N = remain
+	}
+	if err != nil {
+		err = os.NewSyscallError("sendfile", err)
+	}
+	return written, err, written > 0
+}
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sock_gnu.go
===
--- /dev/null
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sock_gnu.go
@@ -0,0 +1,14 @@
+// Copyright 2014 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.
+
+// +build gnu
+
+package net
+
+import "syscall"
+
+func maxListenerBacklog() int {
+   // From /usr/include/i386-gnu/bits/socket.h
+   return syscall.SOMAXCONN
+}
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sockopt_gnu.go
===
--- /dev/null
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sockopt_gnu.go
@@ -0,0 +1,45 @@
+// 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.
+
+// +build gnu
+
+package net
+
+import (
+	"os"
+	"syscall"
+)
+
+func setDefaultSockopts(s, family, sotype int, ipv6only bool) error {
+	if family == syscall.AF_INET6 && sotype != syscall.SOCK_RAW {
+		// Allow both IP versions even if the OS default
+		// is otherwise.  Note that some operating systems
+		// never admit this option.
+		syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, boolint(ipv6only))
+	}
+	// Allow broadcast.
+	return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1))
+}
+
+func setDefaultListenerSockopts(s int) error {
+	// Allow reuse of recently-used addresses.
+	return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1))
+}
+
+func setDefaultMulticastSockopts(s int) error {
+	// Allow multicast UDP and raw IP datagram sockets to listen
+	// concurrently across multiple listeners.
+	if err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil {
+		return os.NewSyscallError("setsockopt", err)
+	}
+	// Allow reuse of recently-used ports.
+	// This option is supported only in descendants of 4.4BSD,
+	// to make an effective multicast application that requires
+	// quick draw possible.
+	// Not supported on GNU/Hurd
+	//if syscall.SO_REUSEPORT != 0 {
+	//	return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1))
+	//}
+	return nil
+}

Hurd port for gcc go PATCH 1-4(23)

2016-11-25 Thread Svante Signell
Hi,

Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-6 (6-6.2.1-5).

The first three patches are Debian-specific:

* debian_rules.defs.diff: Enables build of gccgo for GNU/Hurd

Define patches for the generated series file:
* debian_rules.patch.diff:  Enables split-stack support.
* debian_rules.patch.diff:  Does not enable split-stack support.

* src_gcc_config_i386_gnu.h.diff: Enable split-stack support

The test suite results are as follows:
Without split-stack support:
              === go Summary ===
# of expected passes7359
# of unexpected failures7
# of expected failures  1
# of untested testcases 10
# of unsupported tests  2
                === libgo Summary ===
# of expected passes121
# of unexpected failures13

With split-stack support:

                === go Summary ===
# of expected passes7366
# of unexpected failures8
# of expected failures  1
# of untested testcases 6
# of unsupported tests  2
                === libgo Summary ===
# of expected passes120
# of unexpected failures14

All failing go tests and more than half of the libgo tests are runtime
errors due to exception handling not working as expected:
Aborted
runtime_sighandler ...
fatal error: unexpected signal during runtime execution
panic: runtime error: invalid memory address or nil pointer dereference

The above problems are probably due to some remaining issues in
gnumach/hurd/glibc to be solved. According to Samuel Thibault these
problems can be handled late when the patches are accepted upstream or
in Debian gcc. Another more annoying gnumch/hurd/glibc bug is that the
built program go (go-6 in Debian) gets killed when executed from the
shell vi path, but not when issued directly: /usr/bin/go-6 works fine.
 go-6
Segmentation fault (core dumped)
gdb /usr/bin/go-6 -c ./core
warning: Unexpected size of section `.reg2/16883' in core file.
Core was generated by `go-6'.
Program terminated with signal SIGSEGV, Segmentation fault.

warning: Unexpected size of section `.reg2/16883' in core file.
#0  0x01e854ae in ?? ()
(gdb) bt
#0  0x01e854ae in ?? ()
#1  0x in ?? ()

Nevertheless, it seems like not so much is left for gccgo working
properly on GNU/Hurd.

Thanks!

--- a/debian/rules.defs	2014-01-07 11:10:44.0 +0100
+++ b/debian/rules.defs	2014-01-07 11:23:47.0 +0100
@@ -933,7 +933,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
@@ -943,7 +943,7 @@
 ifneq (,$(filter $(DEB_TARGET_ARCH_CPU),$(go_no_cpus)))
   with_go := disabled for cpu $(DEB_TARGET_ARCH_CPU)
 endif
-ifneq (,$(findstring $(DEB_TARGET_GNU_SYSTEM),$(go_no_systems)))
+ifneq (,$(findstring $(DEB_TARGET_ARCH_OS),$(go_no_systems)))
   with_go := disabled for system $(DEB_TARGET_GNU_SYSTEM)
 endif
 ifeq ($(go_no_cross)-$(DEB_CROSS),yes-yes)
--- a/debian/rules.patch.orig	2016-11-12 16:50:46.0 +0100
+++ b/debian/rules.patch	2016-11-12 16:55:24.0 +0100
@@ -276,6 +276,27 @@
 
 ifeq ($(DEB_TARGET_ARCH_OS),hurd)
   debian_patches += hurd-changes
+  debian_patches += \
+ src_gcc_config_i386_gnu.h \
+ src_libgo_configure.ac \
+ src_libgo_go_net_sendfile_gnu.go \
+ src_libgo_go_net_sock_gnu.go \
+ src_libgo_go_net_sockopt_gnu.go \
+ src_libgo_go_net_sockoptip_gnu.go \
+ src_libgo_go_syscall_libcall_gnu_386.go \
+ src_libgo_go_syscall_libcall_gnu.go \
+ src_libgo_go_syscall_libcall_posix-1.go \
+ src_libgo_go_syscall_socket_gnu.go \
+ src_libgo_go_syscall_wait.c \
+ src_libgo_Makefile.am \
+ src_libgo_Makefile.in \
+ src_libgo_mksysinfo.sh \
+ src_libgo_runtime_getncpu-gnu.c \
+ src_libgo_runtime_netpoll.goc \
+		  src_libgo_go_os_os_test.go \
+ src_libgo_go_syscall_syscall_gnu_test.go \
+ src_libgo_testsuite_gotest \
+		  add-gnu-to-libgo-headers
 endif
 
 debian_patches += gcc-ice-dump
--- a/debian/rules.patch.orig	2016-11-12 16:50:46.0 +0100
+++ b/debian/rules.patch	2016-11-12 16:55:24.0 +0100
@@ -276,6 +276,26 @@
 
 ifeq ($(DEB_TARGET_ARCH_OS),hurd)
   debian_patches += hurd-changes
+  debian_patches += \
+ src_libgo_configure.ac \
+ src_libgo_go_net_sendfile_gnu.go \
+ src_libgo_go_net_sock_gnu.go \
+ src_libgo_go_net_sockopt_gnu.go \
+ src_libgo_go_net_sockoptip_gnu.go \
+ src_libgo_go_syscall_libcall_gnu_386.go \
+ 

Hurd port for gcc go PATCH 5-10(23)

2016-11-25 Thread Svante Signell
* src_libgo_configure.ac.diff: Define GOOS=gnu and LIBGO_IS_GNU
* src_libgo_Makefile.am.diff: Add support for GNU/Hurd.
* src_libgo_Makefile.in.diff: Update accordingly with autreconf2.64
* src_libgo_mksysinfo.sh.diff: Define SYS_IOCTL to 0 if not defined,
 Fix: #define EWOULDBLOCK EAGAIN in 
 Fix: #define st_dev st_fsid in Index: gcc-6-6.2.1-4.1/src/libgo/configure.ac
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/configure.ac
+++ gcc-6-6.2.1-4.1/src/libgo/configure.ac
@@ -151,6 +151,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 ;;
@@ -162,6 +163,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)
@@ -172,6 +174,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)
 AC_SUBST(GOOS)
 
 dnl Test whether we need to use DejaGNU or whether we can use the
Index: gcc-6-6.2.1-4.1/src/libgo/go/syscall/wait.c
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/syscall/wait.c
+++ gcc-6-6.2.1-4.1/src/libgo/go/syscall/wait.c
@@ -8,6 +8,9 @@
OS-independent.  */
 
 #include 
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
 #include 
 
 #include "runtime.h"
Index: gcc-6-6.2.1-4.1/src/libgo/Makefile.am
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/Makefile.am
+++ gcc-6-6.2.1-4.1/src/libgo/Makefile.am
@@ -419,6 +419,9 @@ 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
@@ -426,6 +429,7 @@ endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 runtime_netpoll_files = runtime/netpoll_epoll.c
@@ -433,9 +437,13 @@ else
 if LIBGO_IS_SOLARIS
 runtime_netpoll_files = runtime/netpoll_select.c
 else
+if LIBGO_IS_GNU
+runtime_netpoll_files = runtime/netpoll_select.c
+else
 runtime_netpoll_files = runtime/netpoll_kqueue.c
 endif
 endif
+endif
 
 runtime_files = \
 	runtime/go-append.c \
@@ -744,6 +752,14 @@ go_net_sockoptip_file = go/net/sockoptip
 go_net_cgo_sock_file = go/net/cgo_sockold.go
 go_net_cgo_res_file = go/net/cgo_resnew.go
 else
+if LIBGO_IS_GNU
+go_net_cgo_file = go/net/cgo_linux.go
+go_net_sock_file = go/net/sock_gnu.go
+go_net_sockopt_file = go/net/sockopt_gnu.go
+go_net_sockoptip_file = go/net/sockoptip_gnu.go go/net/sockoptip_posix.go
+go_net_cgo_sock_file = go/net/cgo_socknew.go
+go_net_cgo_res_file = go/net/cgo_resnew.go
+else
 go_net_cgo_file = go/net/cgo_bsd.go
 go_net_sock_file = go/net/sock_bsd.go
 go_net_sockopt_file = go/net/sockopt_bsd.go
@@ -755,6 +771,7 @@ endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_net_sendfile_file = go/net/sendfile_linux.go
@@ -768,11 +785,15 @@ else
 if LIBGO_IS_SOLARIS
 go_net_sendfile_file = go/net/sendfile_solaris.go
 else
+if LIBGO_IS_GNU
+go_net_sendfile_file = go/net/sendfile_gnu.go
+else
 go_net_sendfile_file = go/net/sendfile_stub.go
 endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_net_interface_file = go/net/interface_linux.go
@@ -794,9 +815,13 @@ else
 if LIBGO_IS_FREEBSD
 go_net_cloexec_file = go/net/sock_cloexec.go go/net/hook_cloexec.go
 else
+if LIBGO_IS_GNU
+go_net_cloexec_file = go/net/sock_cloexec.go go/net/hook_cloexec.go
+else
 go_net_cloexec_file = go/net/sys_cloexec.go
 endif
 endif
+endif
 
 if LIBGO_IS_OPENBSD
 go_net_tcpsockopt_file = go/net/tcpsockopt_openbsd.go
@@ -889,9 +914,13 @@ else
 if LIBGO_IS_LINUX
 go_os_dir_file = go/os/dir_largefile.go
 else
+if LIBGO_IS_GNU
+go_os_dir_file = go/os/dir_largefile.go
+else
 go_os_dir_file = go/os/dir_regfile.go
 endif
 endif
+endif
 
 if LIBGO_IS_DARWIN
 go_os_getwd_file = go/os/getwd_darwin.go
@@ -911,11 +940,15 @@ else
 if LIBGO_IS_RTEMS
 go_os_sys_file = go/os/sys_uname.go
 else
+if LIBGO_IS_GNU
+go_os_sys_file = go/os/sys_uname.go
+else
 go_os_sys_file = go/os/sys_bsd.go
 endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_FREEBSD
 go_os_cloexec_file = go/os/sys_freebsd.go
@@ -937,6 +970,9 @@ else
 if LIBGO_IS_LINUX
 go_os_stat_file = go/os/stat_atim.go
 else
+if LIBGO_IS_GNU
+go_os_stat_file = go/os/stat_atim.go
+else
 if LIBGO_IS_OPENBSD
 go_os_stat_file = go/os/stat_atim.go
 else
@@ -960,12 +996,17 @@ endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_os_pipe_file = go/os/pipe_linux.go
 else
+if LIBGO_IS_GNU
+go_os_pipe_file = go/os/pipe_linux.go
+else
 

Re: Please include ada-hurd.diff upstream (try2)

2016-05-04 Thread Svante Signell
On Wed, 2016-05-04 at 23:06 +0200, Samuel Thibault wrote:
> Svante Signell, on Wed 04 May 2016 19:43:27 +0200, wrote:
> > May I comment on Debian way of apt-get source gcc-*: Doing that
> > does
> > not unpack the sources, neither does it apply the patches, you have
> > to
> > unpack and patch before you can change sources and update patches.
> > Iv'e
> > patched the sources several times and still find that the updated
> > patches are not included in the next build. Really confusing.
> 
> Did you read debian/README.source?

Now I have read it, but still cannot find a convincing reason for doing
things this way, sorry! Matthias, why? There should be very strong
arguments for the present procedure.




Re: Please include ada-hurd.diff upstream (try2)

2016-05-04 Thread Svante Signell
On Wed, 2016-05-04 at 18:43 +0200, Svante Signell wrote:
> OnSamuel Thibault, on Wed 04 May 2016 17:29:48 +0200, wrote:
> > 
> > > -   --  From: /usr/include/unistd.h __getpagesize or
> > > getpagesize??
> > > -   function Get_Page_Size return int;
> > > +   --  From: /usr/include/i386-gnu/bits/shm.h __getpagesize or
> > > getpagesize??
> > > +   function Get_Page_Size return size_t;
> > > +   function Get_Page_Size return Address;
> > > 
> > > Why using size_t and Address?  Other OSes use int, and the
> > > prototype for
> > > getpagesize is returning int.
> > > 
> > > Also, don't use the __ versions of the glibc functions, they are
> > > internal aliases, the API is without __.
> > > 
> > 
> I thought I did change that, but apparently not. I did such a change,
> but it was probably somewhere else. Please submit your patch upstream
> and to Debian.

No it was not somewhere else. I did change that, see Debian bug
#811063. I even built gcc-6 to make sure everything was OK. And still
it did not get into the updated patch, strange.

May I comment on Debian way of apt-get source gcc-*: Doing that does
not unpack the sources, neither does it apply the patches, you have to
unpack and patch before you can change sources and update patches. Iv'e
patched the sources several times and still find that the updated
patches are not included in the next build. Really confusing.

Thanks!



Re: Please include ada-hurd.diff upstream (try2)

2016-05-04 Thread Svante Signell
On Wed, 2016-05-04 at 17:34 +0200, Samuel Thibault wrote:
> Samuel Thibault, on Wed 04 May 2016 17:29:48 +0200, wrote:
> > The gcc-6 build failed. I see that one of the change is:
> > 
> > -   --  From: /usr/include/unistd.h __getpagesize or getpagesize??
> > -   function Get_Page_Size return int;
> > +   --  From: /usr/include/i386-gnu/bits/shm.h __getpagesize or
> > getpagesize??
> > +   function Get_Page_Size return size_t;
> > +   function Get_Page_Size return Address;
> > 
> > Why using size_t and Address?  Other OSes use int, and the
> > prototype for
> > getpagesize is returning int.
> > 
> > Also, don't use the __ versions of the glibc functions, they are
> > internal aliases, the API is without __.
> 
> I.e. the proposed change below.
> 
> Samuel
> 
> 
> 2016-05-04  Samuel Thibault  
> 
> * s-osinte-gnu.ads: Make Get_Page_Size return int, and make it
> usehome/srs/DEBs/gcc-5/gcc-5-5.3.1/debian/patches/ada-hurd.diff
> getpagesize instead of __getpagesize.
> 
> --- a/src/gcc/ada/s-osinte-gnu.ads
> +++ b/src/gcc/ada/s-osinte-gnu.ads
> @@ -344,10 +344,9 @@ package System.OS_Interface is
> --  returns the stack base of the specified thread. Only call
> this function
> --  when Stack_Base_Available is True.
>  
> -   --  From: /usr/include/i386-gnu/bits/shm.h __getpagesize or
> getpagesize??
> -   function Get_Page_Size return size_t;
> -   function Get_Page_Size return Address;
> -   pragma Import (C, Get_Page_Size, "__getpagesize");
> +   --  From: /usr/include/i386-gnu/bits/shm.h
> +   function Get_Page_Size return int;
> +   pragma Import (C, Get_Page_Size, "getpagesize");
> --  Returns the size of a page
>  
> --  From /usr/include/i386-gnu/bits/mman.h

I thought I did change that, but apparently not. I did such a change,
but it was probably somewhere else. Please submit your patch upstream
and to Debian.

Thanks!



Re: Please include ada-hurd.diff upstream (try2)

2016-04-27 Thread Svante Signell
On Wed, 2016-04-27 at 09:41 +0200, Eric Botcazou wrote:
> > 
> > Attaching the modified ada-hurd.diff. Maybe it is ready for inclusion in
> > upstream now?
> Upstream already contains the first set of changes though.  Here's what I
> have 
> installed on mainline and 6 branch (not sure it will be in the 6.1 release).
> 
> 
> 2016-04-27  Svante Signell  <svante.sign...@gmail.com>
> 
>   * gcc-interface/Makefile.in (x86 GNU/Hurd): Use s-osinte-gnu.adb.
>   * s-osinte-gnu.ads: Small tweaks.
>   * s-osinte-gnu.adb: New file.

I did not know that, when did that happen? Thanks anyway :) Found the above
commits though, on https://gcc.gnu.org/ml/gcc-cvs/2016-04/


Re: Please include ada-hurd.diff upstream (try2)

2016-04-25 Thread Svante Signell
On Mon, 2016-04-25 at 11:50 +0200, Arnaud Charlet wrote:
> > 
> > Is replacing
> > 
> > +-- Copyright (C) 1991-1994, Florida State
> > University--
> > +-- Copyright (C) 1995-2014,
> > AdaCore --
> > +--  Copyright (C) 2015-2016, Free Software Foundation,
> > Inc. --
> > 
> > with only
> > 
> > +--  Copyright (C) 2015-2016, Free Software Foundation,
> > Inc. --
> > 
> > OK?
> For this specific new file, yes that's fine.

Attaching the modified ada-hurd.diff. Maybe it is ready for inclusion in
upstream now?

2016-03-31  Svante Signell  <svante.sign...@gmail.com>

* gcc-interface/Makefile.in: Add support for x86 GNU/Hurd.
* s-osinte-gnu.ads: New specification file.
* s-osinte-gnu.adb: New body file, basically s-osinte-posix.adb
  adding dummy implementation of functions not yet implemented.
---
Index: gcc-5-5.3.1/src/gcc/ada/s-osinte-gnu.adb
===
--- /dev/null
+++ gcc-5-5.3.1/src/gcc/ada/s-osinte-gnu.adb
@@ -0,0 +1,144 @@
+--
+--  --
+-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--   B o d y--
+--  --
+--  Copyright (C) 2015-2016, Free Software Foundation, Inc. --
+--  --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+--  --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.   --
+--  --
+-- You should have received a copy of the GNU General Public License and--
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see--
+-- <http://www.gnu.org/licenses/>.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd version of this package.
+
+pragma Polling (Off);
+--  Turn off polling, we do not want ATC polling to take place during
+--  tasking operations. It causes infinite loops and other problems.
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+package body System.OS_Interface is
+
+   
+   -- Get_Stack_Base --
+   
+
+   function Get_Stack_Base (thread : pthread_t) return Address is
+  pragma Warnings (Off, thread);
+
+   begin
+  return Null_Address;
+   end Get_Stack_Base;
+
+   --
+   -- pthread_init --
+   --
+
+   procedure pthread_init is
+   begin
+  null;
+   end pthread_init;
+
+   --
+   -- pthread_mutexattr_setprioceiling --
+   --
+
+   function pthread_mutexattr_setprioceiling
+ (attr : access pthread_mutexattr_t;
+  prioceiling : int) return int is
+  pragma Unreferenced (attr, prioceiling);
+   begin
+  return 0;
+   end pthread_mutexattr_setprioceiling;
+
+   --
+   -- pthread_mutexattr_getprioceiling --
+   --
+
+   function pthread_mutexattr_getprioceiling
+ (attr : access pt

Re: Please include ada-hurd.diff upstream (try2)

2016-04-25 Thread Svante Signell
On Tue, 2016-04-19 at 10:29 +0200, Arnaud Charlet wrote:
> > 
> > The updated attachment was included in message
> > https://gcc.gnu.org/ml/gcc-patches/2016-03/msg01659.html
> You should just put a FSF copyright on s-osinte-gnu.adb
> 
> OK with this change.

Is replacing

+-- Copyright (C) 1991-1994, Florida State University--
+-- Copyright (C) 1995-2014, AdaCore --
+--  Copyright (C) 2015-2016, Free Software Foundation, Inc. --

with only

+--  Copyright (C) 2015-2016, Free Software Foundation, Inc. --

OK?


Re: Please include ada-hurd.diff upstream (try2)

2016-04-19 Thread Svante Signell
ping!

The updated attachment was included in message
https://gcc.gnu.org/ml/gcc-patches/2016-03/msg01659.html


On Thu, 2016-03-31 at 11:33 +0200, Svante Signell wrote:
> On Thu, 2016-03-17 at 08:51 +0100, Arnaud Charlet wrote:
> > 
> > > 
> > > 
> > > > 
> > > > 
> > > > The copyright notices are wrong (or at least incomplete).
> > > Hi, what is wrong then, copyright years and/or the text?
> > Both. The copyright year should include 2016 and the text should be
> > copyright FSF, not AdaCore.
> Attached is an updated ada-hurd.diff with your comments above taken care of.
> OK now?
> 
> Thanks!


Re: Please include ada-hurd.diff upstream (try2)

2016-03-31 Thread Svante Signell
On Thu, 2016-03-17 at 08:51 +0100, Arnaud Charlet wrote:
> > 
> > > 
> > > The copyright notices are wrong (or at least incomplete).
> > Hi, what is wrong then, copyright years and/or the text?
> Both. The copyright year should include 2016 and the text should be
> copyright FSF, not AdaCore.

Attached is an updated ada-hurd.diff with your comments above taken care of.
OK now?

Thanks!2016-03-31  Svante Signell  <svante.sign...@gmail.com>

* gcc-interface/Makefile.in: Add support for x86 GNU/Hurd.
* s-osinte-gnu.ads: New specification file.
* s-osinte-gnu.adb: New body file, basically s-osinte-posix.adb
  adding dummy implementation of functions not yet implemented.
---
Index: gcc-5-5.3.1/src/gcc/ada/s-osinte-gnu.adb
===
--- /dev/null
+++ gcc-5-5.3.1/src/gcc/ada/s-osinte-gnu.adb
@@ -0,0 +1,146 @@
+--
+--  --
+-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--   B o d y--
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+-- Copyright (C) 1995-2014, AdaCore --
+--  Copyright (C) 2015-2016, Free Software Foundation, Inc. --
+--  --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+--  --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.   --
+--  --
+-- You should have received a copy of the GNU General Public License and--
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see--
+-- <http://www.gnu.org/licenses/>.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd version of this package.
+
+pragma Polling (Off);
+--  Turn off polling, we do not want ATC polling to take place during
+--  tasking operations. It causes infinite loops and other problems.
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+package body System.OS_Interface is
+
+   
+   -- Get_Stack_Base --
+   
+
+   function Get_Stack_Base (thread : pthread_t) return Address is
+  pragma Warnings (Off, thread);
+
+   begin
+  return Null_Address;
+   end Get_Stack_Base;
+
+   --
+   -- pthread_init --
+   --
+
+   procedure pthread_init is
+   begin
+  null;
+   end pthread_init;
+
+   --
+   -- pthread_mutexattr_setprioceiling --
+   --
+
+   function pthread_mutexattr_setprioceiling
+ (attr : access pthread_mutexattr_t;
+  prioceiling : int) return int is
+  pragma Unreferenced (attr, prioceiling);
+   begin
+  return 0;
+   end pthread_mutexattr_setprioceiling;
+
+   --
+   -- pthread_mutexattr_getprioceiling --
+   --
+
+   function pthread_mutexattr_getprioceiling
+ (attr : access pthread_mutexattr_t;
+  prioceiling : access int) return int is
+  pragma Unreferenced (attr, 

Re: Please include ada-hurd.diff upstream (try2)

2016-03-19 Thread Svante Signell
Sorry for manually creating this mail. Replying to Arnauds message crashes my
mail client (evolution).

On Wed, 2016-03-16 at 11:53 +0100, Arnaud Charlet wrote:
> Yes, you are right, somehow I submitted the old patch. Attached is the
> updated one, with a proposed ChangeLog entry included.
> 
> The copyright notices are wrong (or at least incomplete).

Hi, what is wrong then, copyright years and/or the text?


Re: Please include ada-hurd.diff upstream (try2)

2016-03-16 Thread Svante Signell
On Wed, 2016-03-16 at 11:53 +0100, Eric Botcazou wrote:
> > 
> > Sorry for not supplying a ChangeLog yet, I've been busy lately with other
> > things. Since there is another new file s-osinte-gnu.adb in the latest
> > patch, that might be added too.
> AFAICS there is only s-osinte-gnu.ads in the posted patch.

Yes, you are right, somehow I submitted the old patch. Attached is the updated
one, with a proposed ChangeLog entry included.

Thanks!2016-03-16  Svante Signell  <svante.sign...@gmail.com>

* gcc-interface/Makefile.in: Add support for x86 GNU/Hurd.
* s-osinte-gnu.ads: New specification file.
* s-osinte-gnu.adb: New body file, basically s-osinte-posix.adb
  adding dummy implementation of functions not yet implemented.
---
Index: gcc-5-5.3.1/src/gcc/ada/s-osinte-gnu.adb
===
--- /dev/null
+++ gcc-5-5.3.1/src/gcc/ada/s-osinte-gnu.adb
@@ -0,0 +1,147 @@
+--
+--  --
+-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--   B o d y--
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+-- Copyright (C) 1995-2006, AdaCore --
+--  --
+-- GNARL is free software; you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
+-- for  more details.  You should have  received  a copy of the GNU General --
+-- Public License  distributed with GNARL; see file COPYING.  If not, write --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.  --
+--  --
+-- As a special exception,  if other files  instantiate  generics from this --
+-- unit, or you link  this unit with other files  to produce an executable, --
+-- this  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd version of this package.
+
+pragma Polling (Off);
+--  Turn off polling, we do not want ATC polling to take place during
+--  tasking operations. It causes infinite loops and other problems.
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+package body System.OS_Interface is
+
+   
+   -- Get_Stack_Base --
+   
+
+   function Get_Stack_Base (thread : pthread_t) return Address is
+  pragma Warnings (Off, thread);
+
+   begin
+  return Null_Address;
+   end Get_Stack_Base;
+
+   --
+   -- pthread_init --
+   --
+
+   procedure pthread_init is
+   begin
+  null;
+   end pthread_init;
+
+   --
+   -- pthread_mutexattr_setprioceiling --
+   --
+
+   function pthread_mutexattr_setprioceiling
+ (attr : access pthread_mutexattr_t;
+  prioceiling : int) return int is
+  pragma Unreferenced (attr, prioceiling);
+   begin
+  return 0;
+   end pthread_mutexattr_setprioceiling;
+
+   --
+   -- pthread_mutexattr_getprioceiling --
+   --
+
+   function pthread_mutexattr_getprioceiling
+ (attr : access pthrea

Re: Please include ada-hurd.diff upstream (try2)

2016-03-16 Thread Svante Signell
On Wed, 2016-03-16 at 11:08 +0100, Eric Botcazou wrote:
> > 
> > Maybe the time has come now for a proper inclusion of Ada/Gnat support in
> > gcc-* for GNU/Hurd. (Yes, I commit to maintain Ada in gcc for GNU/Hurd in
> > the foreseeable future, according to my abilities).
> > 
> > Attached is an updated patch, now living e.g. in GNU/Debian versions of
> > gcc-5 and gcc-6.
> > 
> > Please tell me if you need a changelog entry too. And yes, I have already
> > signed all copyright papers for FSF wrt gcc (and other packages).
> Yes, patches need ChangeLog.  This one is small though so I have applied it:
> 
> 2016-03-16  Svante Signell  <svante.sign...@gmail.com>
> 
> * gcc-interface/Makefile.in: Add support for x86 GNU/Hurd.
> * s-osinte-gnu.ads: New file.

Hi Eric,

Sorry for not supplying a ChangeLog yet, I've been busy lately with other
things. Since there is another new file s-osinte-gnu.adb in the latest patch,
that might be added too.

2016-03-16  Svante Signell  <svante.sign...@gmail.com>

* gcc-interface/Makefile.in: Add support for x86 GNU/Hurd.
* s-osinte-gnu.ads: New specification file.
* s-osinte-gnu.adb: New body file, basically s-osinte-posix.adb
  adding dummy implementation of functions not yet implemented.

Thanks!


Please include ada-hurd.diff upstream (try2)

2016-03-01 Thread Svante Signell
Hello,

As time progresses, the ada-hurd.diff patch has now been living in Debian since
gcc-4.6 and is now in gcc-5 and gcc-6. Last try to get it included upstream was
in 2012, and 2014, e.g see
https://gcc.gnu.org/ml/gcc-patches/2012-06/msg0.html
and follow-ups.

Maybe the time has come now for a proper inclusion of Ada/Gnat support in gcc-*
for GNU/Hurd. (Yes, I commit to maintain Ada in gcc for GNU/Hurd in the
foreseeable future, according to my abilities).

Attached is an updated patch, now living e.g. in GNU/Debian versions of gcc-5
and gcc-6.

Please tell me if you need a changelog entry too. And yes, I have already signed
all copyright papers for FSF wrt gcc (and other packages).

Thanks!


Index: gcc-6-6-20160109/src/gcc/ada/s-osinte-gnu.ads
===
--- /dev/null
+++ gcc-6-6-20160109/src/gcc/ada/s-osinte-gnu.ads
@@ -0,0 +1,801 @@
+--
+--  --
+--GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--  S p e c --
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+--  Copyright (C) 1995-2014, Free Software Foundation, Inc. --
+--  --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+--  --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.   --
+--  --
+-- You should have received a copy of the GNU General Public License and--
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see--
+-- .  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd (POSIX Threads) version of this package
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
+--  Preelaborate. This package is designed to be a bottom-level (leaf) package
+
+with Interfaces.C;
+with Unchecked_Conversion;
+
+package System.OS_Interface is
+   pragma Preelaborate;
+
+   pragma Linker_Options ("-lpthread");
+   pragma Linker_Options ("-lrt");
+
+   subtype intis Interfaces.C.int;
+   subtype char   is Interfaces.C.char;
+   subtype short  is Interfaces.C.short;
+   subtype long   is Interfaces.C.long;
+   subtype unsigned   is Interfaces.C.unsigned;
+   subtype unsigned_short is Interfaces.C.unsigned_short;
+   subtype unsigned_long  is Interfaces.C.unsigned_long;
+   subtype unsigned_char  is Interfaces.C.unsigned_char;
+   subtype plain_char is Interfaces.C.plain_char;
+   subtype size_t is Interfaces.C.size_t;
+
+   ---
+   -- Errno --
+   ---
+   --  From /usr/include/i386-gnu/bits/errno.h
+
+   function errno return int;
+   pragma Import (C, errno, "__get_errno");
+
+   EAGAIN   : constant := 1073741859;
+   EINTR: constant := 1073741828;
+   EINVAL   : constant := 1073741846;
+   ENOMEM   : constant := 1073741836;
+   EPERM: constant := 1073741825;
+   ETIMEDOUT: constant := 1073741884;
+
+   -
+   -- Signals --
+   -
+   --  From /usr/include/i386-gnu/bits/signum.h
+
+   Max_Interrupt : 

Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-08-20 Thread Svante Signell
On Wed, 2014-05-21 at 10:48 +0200, Samuel Thibault wrote:
 Svante Signell, le Wed 21 May 2014 10:44:54 +0200, a écrit :
  On Wed, 2014-05-21 at 10:33 +0200, Arnaud Charlet wrote:
 I think the majority of work has bee done, Now that patch will change
 slightly for every missing feature added to Hurd.

Then it's all good, it's a matter of what I said above.
   
   Don't forget also the part where general changes are done in GNAT which
   require update to target specific files: these typically require someone
   to regularly test each port to detect any missing update, and report/fix
   them, even if GNU/Hurd hasn't changed itself.
  
  With the help from the dabian-ada people, especially Ludovic Brenta,
  gnat has been running on GNU/Hurd in Debian since gcc/gnat-4.6.3.
 
 Then it's all good.  Just say that you wish to continue maintaining
 things like this, and upstream will be happy.

Attached is the updated ada-hurd.diff patch for GNU/Hurd. It builds fine
with gnat-4.9.1-1 and gcc-4.9.1-7. This patch now has the same amount of
files as the kFreeBSD patch. Hopefully it can be material for upstream,
but at least in Debian the Hurd port would be on par with kFreeBSD.
Regarding remaining code commented out or irrelevant comments in the new
file s-osinte-gnu.ads, please help me to iron out the left-overs.

Ludovic, can you consider using this file as ada-hurd.diff for next
upload of Debian gnat-4.9?

For clarity: I wish to continue to maintain the Ada port for Hurd, with
the help of the Debian Ada and Hurd people, with or without being
imported upstream.

Thanks!
Index: gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
===
--- /dev/null
+++ gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
@@ -0,0 +1,804 @@
+--
+--  --
+--GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--  S p e c --
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+--  Copyright (C) 1995-2014, Free Software Foundation, Inc. --
+--  --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+--  --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.   --
+--  --
+-- You should have received a copy of the GNU General Public License and--
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see--
+-- http://www.gnu.org/licenses/.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd (POSIX Threads) version of this package
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
+--  Preelaborate. This package is designed to be a bottom-level (leaf) package
+
+with Interfaces.C;
+with Unchecked_Conversion;
+
+package System.OS_Interface is
+   pragma Preelaborate;
+
+   pragma Linker_Options (-lpthread);
+   pragma Linker_Options (-lrt);
+
+   subtype intis Interfaces.C.int;
+   subtype char   is Interfaces.C.char;
+   subtype short  is Interfaces.C.short;
+   subtype long

Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Svante Signell
On Mon, 2014-05-19 at 16:25 +0200, Arnaud Charlet wrote:
   That's actually the biggest concern when people submit a new port: they
   submit it, get it approved, commit it and then are no longer available
   for any maintenance when these files need to be updated/become outdated/
   no longer compile or run.
  
  I can try to do that in the near future, then somebody else can take
  over. I think maybe Thomas have an opinion about this being a Hurd
  developer and a GNU person at the same time.
  
  Updated patch attached, OK now?
 
 No, there are still code commented out, and we need to resolve the above
 point first.

Thomas and Samuel: It looks like upstream don't accept patches unless a
Hurd port maintainer commits to it. What's the use of all this job? (Of
course it can at least run on Debian systems if/when accepted.)



Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Svante Signell
On Wed, 2014-05-21 at 10:03 +0200, Samuel Thibault wrote:
 Svante Signell, le Wed 21 May 2014 09:49:59 +0200, a écrit :
  Thomas and Samuel: It looks like upstream don't accept patches unless a
  Hurd port maintainer commits to it. What's the use of all this job?
 
 Well, simply to keep the changes working.  That is not surprising at all.

I might not be interested any longer with this kind of requirements.
What kind of person do you have to be to be accepted, a GNU/Hurd
developer or a GNU/Ada developer having a gnu.org account? Then you or
Thomas can commit to this and I'll try to help out. 

  (Of course it can at least run on Debian systems if/when accepted.)
 
 Sure, but will it continue working on the long term?  That's the concern
 of upstream.

I think the majority of work has bee done, Now that patch will change
slightly for every missing feature added to Hurd.

 In principle it's just a matter of fixing just a few things over the
 coming versions.  But someone has to do it, otherwise the port will just
 die.

I wonder ho the kfreebsd people managed to get accepted upstream?



Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Svante Signell
On Wed, 2014-05-21 at 10:29 +0200, Samuel Thibault wrote:
 Svante Signell, le Wed 21 May 2014 10:20:16 +0200, a écrit :
  On Wed, 2014-05-21 at 10:03 +0200, Samuel Thibault wrote:
   Svante Signell, le Wed 21 May 2014 09:49:59 +0200, a écrit :
Thomas and Samuel: It looks like upstream don't accept patches unless a
Hurd port maintainer commits to it. What's the use of all this job?
   
   Well, simply to keep the changes working.  That is not surprising at all.
  
  I might not be interested any longer with this kind of requirements.
 
 Well, then somebody else will have to if we want to keep the gnat port
 alive.  I for myself don't really have time to do it.

Understood

  What kind of person do you have to be to be accepted, a GNU/Hurd
  developer or a GNU/Ada developer having a gnu.org account?
 
 Nothing special, just like for contributing to any opensource project;
 just someone who checks from times to times (in particular before
 releases) that the port works fine, and submit patches if needed.

I've been working on the Hurd port of gnat since late 2011 including the
toughest: bootstrapping, does that count?

(Of course it can at least run on Debian systems if/when accepted.)
   
   Sure, but will it continue working on the long term?  That's the concern
   of upstream.

If that happens why not just remove support for that architecture? The
same happens for plain C, C++, etc on outdated architectures.




Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Svante Signell
On Wed, 2014-05-21 at 10:33 +0200, Arnaud Charlet wrote:
   I think the majority of work has bee done, Now that patch will change
   slightly for every missing feature added to Hurd.
  
  Then it's all good, it's a matter of what I said above.
 
 Don't forget also the part where general changes are done in GNAT which
 require update to target specific files: these typically require someone
 to regularly test each port to detect any missing update, and report/fix
 them, even if GNU/Hurd hasn't changed itself.

With the help from the dabian-ada people, especially Ludovic Brenta,
gnat has been running on GNU/Hurd in Debian since gcc/gnat-4.6.3.



Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Svante Signell
On Wed, 2014-05-21 at 10:47 +0200, Samuel Thibault wrote:
 Svante Signell, le Wed 21 May 2014 10:40:37 +0200, a écrit :
What kind of person do you have to be to be accepted, a GNU/Hurd
developer or a GNU/Ada developer having a gnu.org account?
   
   Nothing special, just like for contributing to any opensource project;
   just someone who checks from times to times (in particular before
   releases) that the port works fine, and submit patches if needed.
  
  I've been working on the Hurd port of gnat since late 2011 including the
  toughest: bootstrapping, does that count?
 
 Count for what?
 
 Opensource is about patches correctness, not people fame.
 
 If anybody, whoever he is, takes up the work and produces correct
 patches, then they'll be applied.  It's as simple as this.

In this case if long term support can be guaranteed, yes!

  (Of course it can at least run on Debian systems if/when accepted.)
 
 Sure, but will it continue working on the long term?  That's the 
 concern
 of upstream.
  
  If that happens why not just remove support for that architecture? The
  same happens for plain C, C++, etc on outdated architectures.
 
 Uh?  I'm not sure what you mean here.  What I understand is why not
 remove support for GNU/Hurd? which'd mean dropping your patches.

How can they be removed, they are not upstream yet?

  I guess that's not what you want, so I don't know what you meant.

If that happens - means if the port is bitrotting for a long time just
remove support upstream. We were talking upstream here, not Debian ...



Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Svante Signell
On Wed, 2014-05-21 at 11:27 +0200, Samuel Thibault wrote:
 Svante Signell, le Wed 21 May 2014 11:22:44 +0200, a écrit :
  On Wed, 2014-05-21 at 10:47 +0200, Samuel Thibault wrote:
   Svante Signell, le Wed 21 May 2014 10:40:37 +0200, a écrit :
  What kind of person do you have to be to be accepted, a GNU/Hurd
  developer or a GNU/Ada developer having a gnu.org account?
 
 Nothing special, just like for contributing to any opensource project;
 just someone who checks from times to times (in particular before
 releases) that the port works fine, and submit patches if needed.

I've been working on the Hurd port of gnat since late 2011 including the
toughest: bootstrapping, does that count?
   
   Count for what?
   
   Opensource is about patches correctness, not people fame.
   
   If anybody, whoever he is, takes up the work and produces correct
   patches, then they'll be applied.  It's as simple as this.
  
  In this case if long term support can be guaranteed, yes!
 
 I don't understand what you mean.
 
 Guaranteeing long term support *is* about taking up the work of checking
 periodically that the port works fine.  If anybody does it, then it's
 fine.  If nobody does it, then the port will be dropped.  It's as simple
 as this.  You're welcome for doing it of course.

I've been doing this since 2012 and I said I could continue doing it,
but that did not seem to be sufficient.

(Of course it can at least run on Debian systems if/when 
accepted.)
   
   Sure, but will it continue working on the long term?  That's the 
   concern
   of upstream.

If that happens why not just remove support for that architecture? The
same happens for plain C, C++, etc on outdated architectures.
   
   Uh?  I'm not sure what you mean here.  What I understand is why not
   remove support for GNU/Hurd? which'd mean dropping your patches.
  
  How can they be removed, they are not upstream yet?
 
 I even less understand what you meant then.

Well dropping patches not upstream is a nop, right?

I guess that's not what you want, so I don't know what you meant.
  
  If that happens - means if the port is bitrotting for a long time just
  remove support upstream. We were talking upstream here, not Debian ...
 
 What support?  I really don't undestand what you mean.

Remove support for a language for bitrotting architectures (obsolete
ports) like is done for old Solaris 9 (*-*-solaris2.9)
http://www.gnu.org/software/gcc/gcc-4.9/changes.html



Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-19 Thread Svante Signell
On Wed, 2014-05-14 at 12:53 +0200, Eric Botcazou wrote:
  Attached is a patch for support of GNU/Hurd in gnat-4.9. This patch has
  been used and updated in Debian since gnat-4.6, and is currently used to
  build gnat-4.9. Now when the body file s-osinte-posix.adb in gcc-4.9
  defines tv_nsec in timespec POSIX-correctly as long again, we think it
  is time that it goes upstream. The patch contains two parts:
  
  src/gcc/ada/gcc-interface/Makefile.in:
  Defines LIBGNAT_TARGET_PAIRS for GNU/Hurd
  
  src/gcc/ada/s-osinte-gnu.ads:
  A new file giving the OS interface specification for GNU/Hurd. This file
  is a modification of the already existing s-osinte-*.ads files.
 
 It's quite nice that you need only one specific file for GNU/Hurd.  This is 
 mostly OK, but your LIBGNAT_TARGET_PAIRS looks a bit outdated, specifically 
 for the atomic support, see the other *BSD for reference.

Attached is the patch with two added lines:
-+  $(ATOMICS_TARGET_PAIRS) \
-+  $(X86_TARGET_PAIRS) \
and 
+  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o

Now the arch-specific lines are the same as for kFreeBSD except for two
files, in kFreeBSD:
s-osinte.adbs-osinte-kfreebsd-gnu.adb
s-osinte.adss-osinte-kfreebsd-gnu.ads

In Hurd:
s-osinte.adbs-osinte-posix.adb
s-osinte.adss-osinte-gnu.ads

The build went fine. Is something still missing?
Index: gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
===
--- /dev/null
+++ gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
@@ -0,0 +1,816 @@
+--
+--  --
+--GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--  S p e c --
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+--  Copyright (C) 1995-2011, Free Software Foundation, Inc. --
+--  --
+-- GNARL is free software; you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
+-- for  more details.  You should have  received  a copy of the GNU General --
+-- Public License  distributed with GNARL; see file COPYING.  If not, write --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.  --
+--  --
+-- As a special exception,  if other files  instantiate  generics from this --
+-- unit, or you link  this unit with other files  to produce an executable, --
+-- this  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd version of this package
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
+--  Preelaborate. This package is designed to be a bottom-level (leaf) package
+
+with Interfaces.C;
+with Unchecked_Conversion;
+
+package System.OS_Interface is
+   pragma Preelaborate;
+
+   pragma Linker_Options (-lpthread);
+   pragma Linker_Options (-lrt);
+
+   subtype intis Interfaces.C.int;
+   subtype char   is Interfaces.C.char;
+   subtype short  is Interfaces.C.short;
+   subtype long   is Interfaces.C.long;
+   subtype unsigned   is Interfaces.C.unsigned;
+   subtype unsigned_short is Interfaces.C.unsigned_short;

Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-19 Thread Svante Signell
On Mon, 2014-05-19 at 14:50 +0200, Arnaud Charlet wrote:
  The build went fine. Is something still missing?
 
 We never keep commented out code, except with a ??? comment explaining why.

Do you want me to remove all GNU/Hurd specific header file info?

 We don't use 'FIXME', we use ??? instead.

Removed FIXME and the FreeBSD comment section.

 Also, some of the comments seem to be copy/paste from freebsd, which is
 likely not appropriate for GNU Hurd, so need to be revised.

Any more comments I have missed?

 The header is wrong: it should be GPLv3+, not GPLv2+

Fixed. And added 2014 to the Copyright years: 1995-2014
Or should it be 1995-2011, 2014 or only 2014?

 Also:
 
  +   --  1_024 == 1024??
 
 Remove this comment. Yes, 1_024 is the same as 1024 in Ada.

Done

Updated patch attached.

Index: gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
===
--- /dev/null
+++ gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
@@ -0,0 +1,807 @@
+--
+--  --
+--GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--  S p e c --
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+--  Copyright (C) 1995-2014, Free Software Foundation, Inc. --
+--  --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+--  --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.   --
+--  --
+-- You should have received a copy of the GNU General Public License and--
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see--
+-- http://www.gnu.org/licenses/.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd (POSIX Threads) version of this package
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
+--  Preelaborate. This package is designed to be a bottom-level (leaf) package
+
+with Interfaces.C;
+with Unchecked_Conversion;
+
+package System.OS_Interface is
+   pragma Preelaborate;
+
+   pragma Linker_Options (-lpthread);
+   pragma Linker_Options (-lrt);
+
+   subtype intis Interfaces.C.int;
+   subtype char   is Interfaces.C.char;
+   subtype short  is Interfaces.C.short;
+   subtype long   is Interfaces.C.long;
+   subtype unsigned   is Interfaces.C.unsigned;
+   subtype unsigned_short is Interfaces.C.unsigned_short;
+   subtype unsigned_long  is Interfaces.C.unsigned_long;
+   subtype unsigned_char  is Interfaces.C.unsigned_char;
+   subtype plain_char is Interfaces.C.plain_char;
+   subtype size_t is Interfaces.C.size_t;
+
+   ---
+   -- Errno --
+   ---
+   --  From /usr/include/i386-gnu/bits/errno.h
+
+   function errno return int;
+   pragma Import (C, errno, __get_errno);
+
+   EAGAIN   : constant := 1073741859;
+   EINTR: constant := 1073741828;
+   EINVAL   : constant := 1073741846;
+   ENOMEM   : constant := 1073741836;
+   EPERM: constant := 1073741825;
+   ETIMEDOUT: constant := 1073741884;
+
+   -
+   -- Signals --
+   

Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-19 Thread Svante Signell
On Mon, 2014-05-19 at 15:53 +0200, Arnaud Charlet wrote:
  Do you want me to remove all GNU/Hurd specific header file info?
 
 No, I want you to remove commented out code, such as:
 
  +--   SIGLTHRRES : constant := 32; --  GNU/LinuxThreads restart signal
  +--   SIGLTHRCAN : constant := 33; --  GNU/LinuxThreads cancel signal
  +--   SIGLTHRDBG : constant := 34; --  GNU/LinuxThreads debugger signal

OK, done. I did not notice that one.

 Also, can you clarify who will be in charge of maintaining these files?
 
 That's actually the biggest concern when people submit a new port: they
 submit it, get it approved, commit it and then are no longer available
 for any maintenance when these files need to be updated/become outdated/
 no longer compile or run.

I can try to do that in the near future, then somebody else can take
over. I think maybe Thomas have an opinion about this being a Hurd
developer and a GNU person at the same time.

Updated patch attached, OK now?
Index: gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
===
--- /dev/null
+++ gnat-4.9-4.9.0/src/gcc/ada/s-osinte-gnu.ads
@@ -0,0 +1,804 @@
+--
+--  --
+--GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--  S p e c --
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+--  Copyright (C) 1995-2014, Free Software Foundation, Inc. --
+--  --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+--  --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.   --
+--  --
+-- You should have received a copy of the GNU General Public License and--
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see--
+-- http://www.gnu.org/licenses/.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd (POSIX Threads) version of this package
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
+--  Preelaborate. This package is designed to be a bottom-level (leaf) package
+
+with Interfaces.C;
+with Unchecked_Conversion;
+
+package System.OS_Interface is
+   pragma Preelaborate;
+
+   pragma Linker_Options (-lpthread);
+   pragma Linker_Options (-lrt);
+
+   subtype intis Interfaces.C.int;
+   subtype char   is Interfaces.C.char;
+   subtype short  is Interfaces.C.short;
+   subtype long   is Interfaces.C.long;
+   subtype unsigned   is Interfaces.C.unsigned;
+   subtype unsigned_short is Interfaces.C.unsigned_short;
+   subtype unsigned_long  is Interfaces.C.unsigned_long;
+   subtype unsigned_char  is Interfaces.C.unsigned_char;
+   subtype plain_char is Interfaces.C.plain_char;
+   subtype size_t is Interfaces.C.size_t;
+
+   ---
+   -- Errno --
+   ---
+   --  From /usr/include/i386-gnu/bits/errno.h
+
+   function errno return int;
+   pragma Import (C, errno, __get_errno);
+
+   EAGAIN   : constant := 1073741859;
+   EINTR: constant := 1073741828;
+   EINVAL   : constant := 

Re: patch8.diff updated Was: Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-16 Thread Svante Signell
On Wed, 2014-05-07 at 10:18 +0200, Svante Signell wrote:
 On Tue, 2014-05-06 at 15:26 +0200, Samuel Thibault wrote:

Attached is an updated patch8.diff. Arch specific code to
src/libgo/mksysinfo.sh has been added, now other systems are not
affected by the patch except the SYS_FCNTL part.

For that part of the patch without it the build on GNU/Hurd fails. On
the other hand SYS_FCNTL is not defined for e.g. GNU/Linux either. This
is used in gcc-4.9-4.9.0/src/libgo/go/net/fd_unix.go:
func dupCloseOnExec(fd int) (newfd int, err error) {
if atomic.LoadInt32(tryDupCloexec) == 1  syscall.F_DUPFD_CLOEXEC!=0 {
r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd),
syscall.F_DUPFD_CLOEXEC, 0)

It is yet unknown how the build succeeds on Linux without the SYS_FCNTL
being defined? Maybe any the conditions above are not met. 
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -210,6 +210,13 @@
   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 21; then
+  egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+sed -i.bak -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}
@@ -225,6 +232,11 @@
   echo const F_DUPFD_CLOEXEC = 0  ${OUT}
 fi
 
+# Special treatment of SYS_FCNTL for GNU/Hurd
+if ! grep '^const SYS_FCNTL' ${OUT}  /dev/null 21; then
+  echo const SYS_FCNTL = 0  ${OUT}
+fi
+
 # These flags can be lost on i386 GNU/Linux when using
 # -D_FILE_OFFSET_BITS=64, because we see #define F_SETLK F_SETLK64
 # before we see the definition of F_SETLK64.
@@ -528,6 +540,12 @@
 
 # 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 21; then
+  egrep '^type _stat ' gen-sysinfo.go  /dev/null 21| \
+  sed -i.bak -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


patch1.diff updated + test results Was: Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-07 Thread Svante Signell
On Tue, 2014-05-06 at 15:26 +0200, Samuel Thibault wrote:
 Svante Signell, le Tue 06 May 2014 15:25:38 +0200, a écrit :
  On Tue, 2014-05-06 at 15:07 +0200, Samuel Thibault wrote:
   Svante Signell, le Tue 06 May 2014 15:05:20 +0200, a écrit :
On Tue, 2014-05-06 at 14:51 +0200, Samuel Thibault wrote:
 Just to explicitly ask for it:
 
 Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
  For some (yet) unknown reason all libgo tests fails with a segfault 
  when
  run in the build tree: make, sh or something else, the test 
  commands are
  rather hard to track.
 
 Doesn't that dump a core?  Do you have /servers/crash properly 
 pointing
 to /servers/crash-dump-core and ulimit -u set to unlimited?

More good news:
- Installing the modified libpthread.so.0.3 made the segfault go away. I
could now run the check from the build tree :-)

- Adding
#define TARGET_THREAD_SSP_OFFSET 0x14
to patch1.diff and building gcc-4.9.0-2 the test results are summarised
as follows :-)
=== libgo Summary ===

# of expected passes101
# of unexpected failures21

I think some of the remaining failures are rather easy to fix.

Attached is an updated patch1.diff.
Remains to solve the problem with patch8.diff: Adding arch specific code
to: src/libgo/mksysinfo.sh
--- a/src/gcc/config/i386/gnu.h
+++ b/src/gcc/config/i386/gnu.h
@@ -37,11 +37,14 @@
 
 #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_OFFSET0x14
 
+/* 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


Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Svante Signell
On Fri, 2014-05-02 at 12:52 +0200, Samuel Thibault wrote:
 Svante Signell, le Fri 02 May 2014 12:45:56 +0200, a écrit :
  On Fri, 2014-05-02 at 12:00 +0200, Samuel Thibault wrote:
   Samuel Thibault, le Fri 02 May 2014 11:57:53 +0200, a écrit :
So we just need to fix guardsize in our libpthread.
   
   (And I'll have a look at it).
  
  Maybe this can fix the around 40 segfaults (of 50 failures) when split
  stack is disabled too? The segfaults are always around the same place in
  libpthread. 
 
 Possibly, if libgo uses small stacks already.

Status update:
For some (yet) unknown reason all libgo tests fails with a segfault when
run in the build tree: make, sh or something else, the test commands are
rather hard to track.
However, running the tests manually, sigh!, after installing gccgo and
libgo5 from gcc-4.9-4.9.0-1 with split stack support the result is as
follows:

Total: 122
PASS: 95
FAIL: 27
Number of tests succeeding with libpthread's stack guard fixed: 33 (and
the other libc fixes)
Note: In many of the failing tests, only a small subset of each test
fails.

GNU/Hurd should now to be considered for upstream inclusion?
Updated patches will be sent again to gcc-patches for review.




Hurd port for gcc go PATCH 0-3 (9)

2014-05-06 Thread Svante Signell

Hi,

Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-4.9 (4.9-4.9.0-1). With split stack enabled 95 libgo
tests PASS and 27 FAIL. Many of the failed tests do fail only in a few
sub-tests. patch0.diff is debian specific, while the rest are for
upstream.

patch0.diff is Debian specific, 
patch1.diff should be applied now when split-stack works properly.

patch0.diff: debian/rules.defs:
go_no_systems: remove gnu,
with_go: Check for DEB_TARGET_GNU_OS instead of DEB_TARGET_GNU_SYSTEM.
Otherwise kfreebsd-gnu causes go_no_systems to still be true for gnu.

patch1.diff: src/gcc/config/i386/gnu.h: Enables split stack for
GNU/Hurd. TARGET_THREAD_SSP_OFFSET is not yet supported.

patch2.diff: src/libgo/configure.ac:
Add GNU as a supported target OS for go.

patch3.diff: src/libgo/Makefile.am, src/libgo/Makefile.in
Add GNU specific go routines with the LIBGO_IS_GNU conditional.

Note: Creating the Makefile.in is hard (unnecessary) work since
automake is no longer used in the build system. Both (cd
src/libgo;automake-1.11) and (cd src/libgo;autoreconf2.64) fails. The
diff for Makefile.in was patched by hand with the aid of the diff for
Makefile.am :( This file should be possible to generate from
Makefile.am when modifying manually. In my opinion the Debian build
system is broken at least wrt libgo, since the correct version of
libtool (2.2.7a) is not available.


--- a/debian/rules.defs	2014-01-07 11:10:44.0 +0100
+++ b/debian/rules.defs	2014-01-07 11:23:47.0 +0100
@@ -721,7 +721,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
@@ -731,7 +731,7 @@
 ifneq (,$(filter $(DEB_TARGET_ARCH_CPU),$(go_no_cpus)))
   with_go := disabled for cpu $(DEB_TARGET_ARCH_CPU)
 endif
-ifneq (,$(findstring $(DEB_TARGET_GNU_SYSTEM),$(go_no_systems)))
+ifneq (,$(findstring $(DEB_TARGET_ARCH_OS),$(go_no_systems)))
   with_go := disabled for system $(DEB_TARGET_GNU_SYSTEM)
 endif
 ifeq ($(go_no_cross)-$(DEB_CROSS),yes-yes)
--- a/src/gcc/config/i386/gnu.h
+++ b/src/gcc/config/i386/gnu.h
@@ -39,9 +39,16 @@
 
 /* Not supported yet.  */
 # undef TARGET_THREAD_SSP_OFFSET
+/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+/*
+#define TARGET_THREAD_SSP_OFFSET0x14
+ */
 
-/* Not supported yet.  */
-# undef TARGET_CAN_SPLIT_STACK
-# undef TARGET_THREAD_SPLIT_STACK_OFFSET
-
+/* 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
--- a/src/libgo/configure.ac
+++ b/src/libgo/configure.ac
@@ -136,6 +136,7 @@
 is_dragonfly=no
 is_rtems=no
 is_solaris=no
+is_gnu=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -147,6 +148,7 @@
   *-*-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)
@@ -157,6 +159,7 @@
 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)
 AC_SUBST(GOOS)
 
 dnl Test whether we need to use DejaGNU or whether we can use the
--- a/src/libgo/Makefile.am
+++ b/src/libgo/Makefile.am
@@ -418,9 +418,13 @@
 if LIBGO_IS_SOLARIS
 runtime_netpoll_files = runtime/netpoll_select.c
 else
+if LIBGO_IS_GNU
+runtime_netpoll_files = runtime/netpoll_select.c
+else
 runtime_netpoll_files = runtime/netpoll_kqueue.c
 endif
 endif
+endif
 
 runtime_files = \
 	runtime/go-append.c \
@@ -702,6 +706,12 @@
 go_net_sockopt_file = go/net/sockopt_bsd.go
 go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
 else
+if LIBGO_IS_GNU
+go_net_cgo_file = go/net/cgo_linux.go
+go_net_sock_file = go/net/sock_gnu.go
+go_net_sockopt_file = go/net/sockopt_bsd.go
+go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
+else
 go_net_cgo_file = go/net/cgo_bsd.go
 go_net_sock_file = go/net/sock_bsd.go
 go_net_sockopt_file = go/net/sockopt_bsd.go
@@ -711,6 +721,7 @@
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_net_sendfile_file = go/net/sendfile_linux.go
@@ -842,11 +853,15 @@
 if LIBGO_IS_RTEMS
 go_os_sys_file = go/os/sys_uname.go
 else
+if LIBGO_IS_GNU
+go_os_sys_file = go/os/sys_uname.go
+else
 go_os_sys_file = go/os/sys_bsd.go
 endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_SOLARIS
 go_os_stat_file = 

Hurd port for gcc go PATCH 4-6 (9)

2014-05-06 Thread Svante Signell

(continued)

patch4.diff: src/libgo/go/syscall/libcall_posix-1.go: New file, a copy
of libcall_posix.go with the mount, mlockall and munlockall calls
removed. mount/umount functionality exists but is currently part of
Hurd utilities, the outhe two functions are not yet implemented.

patch5.diff: src/libgo/go/net/sock_gnu.go
Create a dummy function for maxListenerBacklog() until implemented.

patch6.diff: src/libgo/go/syscall/libcall_gnu.go
Create a dummy function for raw_ptrace() until implemented.


--- /dev/null
+++ b/src/libgo/go/syscall/libcall_posix-1.go
@@ -0,0 +1,397 @@
+// 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.
+
+// POSIX library calls.
+// Removed the mount call for GNU/Hurd, it exists but use translators.
+// Functionality is not the same as descibed in sys/mount.h
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates library call stubs.
+// Note that sometimes we use a lowercase //sys name and
+// wrap it in our own nicer implementation.
+
+package syscall
+
+import unsafe
+
+/*
+ * Wrapped
+ */
+
+//sysnb	pipe(p *[2]_C_int) (err error)
+//pipe(p *[2]_C_int) _C_int
+func Pipe(p []int) (err error) {
+	if len(p) != 2 {
+		return EINVAL
+	}
+	var pp [2]_C_int
+	err = pipe(pp)
+	p[0] = int(pp[0])
+	p[1] = int(pp[1])
+	return
+}
+
+//sys	utimes(path string, times *[2]Timeval) (err error)
+//utimes(path *byte, times *[2]Timeval) _C_int
+func Utimes(path string, tv []Timeval) (err error) {
+	if len(tv) != 2 {
+		return EINVAL
+	}
+	return utimes(path, (*[2]Timeval)(unsafe.Pointer(tv[0])))
+}
+
+//sys	getcwd(buf *byte, size Size_t) (err error)
+//getcwd(buf *byte, size Size_t) *byte
+
+const ImplementsGetwd = true
+
+func Getwd() (ret string, err error) {
+	for len := Size_t(4096); ; len *= 2 {
+		b := make([]byte, len)
+		err := getcwd(b[0], len)
+		if err == nil {
+			i := 0
+			for b[i] != 0 {
+i++
+			}
+			return string(b[0:i]), nil
+		}
+		if err != ERANGE {
+			return , err
+		}
+	}
+}
+
+func Getcwd(buf []byte) (n int, err error) {
+	err = getcwd(buf[0], Size_t(len(buf)))
+	if err == nil {
+		i := 0
+		for buf[i] != 0 {
+			i++
+		}
+		n = i +1
+	}
+	return
+}
+
+//sysnb	getgroups(size int, list *Gid_t) (nn int, err error)
+//getgroups(size _C_int, list *Gid_t) _C_int
+
+func Getgroups() (gids []int, err error) {
+	n, err := getgroups(0, nil)
+	if err != nil {
+		return nil, err
+	}
+	if n == 0 {
+		return nil, nil
+	}
+
+	// Sanity check group count.  Max is 116 on GNU/Linux.
+	if n  0 || n  120 {
+		return nil, EINVAL
+	}
+
+	a := make([]Gid_t, n)
+	n, err = getgroups(n, a[0])
+	if err != nil {
+		return nil, err
+	}
+	gids = make([]int, n)
+	for i, v := range a[0:n] {
+		gids[i] = int(v)
+	}
+	return
+}
+
+//sysnb	setgroups(n int, list *Gid_t) (err error)
+//setgroups(n Size_t, list *Gid_t) _C_int
+
+func Setgroups(gids []int) (err error) {
+	if len(gids) == 0 {
+		return setgroups(0, nil)
+	}
+
+	a := make([]Gid_t, len(gids))
+	for i, v := range gids {
+		a[i] = Gid_t(v)
+	}
+	return setgroups(len(a), a[0])
+}
+
+type WaitStatus uint32
+
+// The WaitStatus methods are implemented in C, to pick up the macros
+// #defines in sys/wait.h.
+
+func (w WaitStatus) Exited() bool
+func (w WaitStatus) Signaled() bool
+func (w WaitStatus) Stopped() bool
+func (w WaitStatus) Continued() bool
+func (w WaitStatus) CoreDump() bool
+func (w WaitStatus) ExitStatus() int
+func (w WaitStatus) Signal() Signal
+func (w WaitStatus) StopSignal() Signal
+func (w WaitStatus) TrapCause() int
+
+//sys	Mkfifo(path string, mode uint32) (err error)
+//mkfifo(path *byte, mode Mode_t) _C_int
+
+//sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
+//select(nfd _C_int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) _C_int
+
+const nfdbits = int(unsafe.Sizeof(fds_bits_type) * 8)
+
+type FdSet struct {
+	Bits [(FD_SETSIZE +nfdbits - 1) / nfdbits]fds_bits_type
+}
+
+func FDSet(fd int, set *FdSet) {
+	set.Bits[fd/nfdbits] |= (1  (uint)(fd%nfdbits))
+}
+
+func FDClr(fd int, set *FdSet) {
+	set.Bits[fd/nfdbits] ^= (1  (uint)(fd%nfdbits))
+}
+
+func FDIsSet(fd int, set *FdSet) bool {
+	if set.Bits[fd/nfdbits](1(uint)(fd%nfdbits)) != 0 {
+		return true
+	} else {
+		return false
+	}
+}
+
+func FDZero(set *FdSet) {
+	for i := range set.Bits {
+		set.Bits[i] = 0
+	}
+}
+
+//sys	Access(path string, mode uint32) (err error)
+//access(path *byte, mode _C_int) _C_int
+
+//sys	Chdir(path string) (err error)
+//chdir(path *byte) _C_int
+
+//sys	Chmod(path string, mode uint32) (err error)
+//chmod(path *byte, mode Mode_t) _C_int
+
+//sys	Chown(path string, uid int, gid int) (err error)
+//chown(path *byte, uid Uid_t, gid Gid_t) _C_int
+
+//sys	Chroot(path string) (err error)
+//chroot(path *byte) _C_int
+
+//sys	Close(fd int) (err error)
+//close(fd _C_int) _C_int
+
+//sys	Creat(path string, mode 

Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Svante Signell

(continued)

patch7.diff: src/libgo/go/syscall/wait.c
Set WCONTINUED to zero if not defined (same fix as for lto in gcc-4.9)

patch8.diff: src/libgo/mksysinfo.sh
Add special treatment of EWOULDBLOCK, SYS_FCNTL and st_dev since they
are either not defined or defined differently for the script to catch
them. The patch for st_dev by Thomas Schwinge was not liked by Samuel so
I have included a more clumsy version. A better solution is needed.
Thomas version is commented out in the patch.

patch9.diff: src/libgo/runtime/netpoll.goc
Rename errno to errno1 since errno clashes with errno.h included in
that file on Hurd.

--- a/src/libgo/go/syscall/wait.c
+++ b/src/libgo/go/syscall/wait.c
@@ -8,6 +8,9 @@
OS-independent.  */
 
 #include stdint.h
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
 #include sys/wait.h
 
 #include runtime.h
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -210,6 +210,11 @@
   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
+egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/'  ${OUT}
@@ -225,6 +230,11 @@
   echo const F_DUPFD_CLOEXEC = 0  ${OUT}
 fi
 
+# Special treatment of SYS_FCNTL for GNU/Hurd
+if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
+  echo const SYS_FCNTL = 0  ${OUT}
+fi
+
 # These flags can be lost on i386 GNU/Linux when using
 # -D_FILE_OFFSET_BITS=64, because we see #define F_SETLK F_SETLK64
 # before we see the definition of F_SETLK64.
@@ -528,6 +538,15 @@
 
 # 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 21; then
+ grep '^type _stat ' gen-sysinfo.go | \
+ sed -i.bak -e 's/st_fsid\([^;]*\)/st_fsid\1; st_dev\1/' gen-sysinfo.go
+ grep '^type _stat ' ${OUT} | \
+ sed -i.bak -e 's/st_fsid\([^;]*\)/; st_dev\1/' ${OUT}
+fi
+# -e 's/st_fsid/Dev/'
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test $stat != ; then
   grep '^type _stat64 ' gen-sysinfo.go
--- a/src/libgo/runtime/netpoll.goc.orig	2013-11-07 01:23:21.0 +0100
+++ b/src/libgo/runtime/netpoll.goc	2014-03-28 09:07:15.0 +0100
@@ -68,7 +68,7 @@
 	runtime_netpollinit();
 }
 
-func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno int) {
+func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno1 int) {
 	pd = allocPollDesc();
 	runtime_lock(pd);
 	if(pd-wg != nil  pd-wg != READY)
@@ -84,7 +84,7 @@
 	pd-wd = 0;
 	runtime_unlock(pd);
 
-	errno = runtime_netpollopen(fd, pd);
+	errno1 = runtime_netpollopen(fd, pd);
 }
 
 func runtime_pollClose(pd *PollDesc) {


Re: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Svante Signell
On Tue, 2014-05-06 at 11:07 +0200, Samuel Thibault wrote:
 Svante Signell, le Tue 06 May 2014 10:58:38 +0200, a écrit :
  The patch for st_dev by Thomas Schwinge was not liked by Samuel
 
 Uh?
 
 I said “These should be fine, however.” and “a sed rule can't hurt even
 if there is no occurrence...”
 
 So just keep that precise part back as it was, no need for being clumsy.
 
 What I however said was:
 
 “Err, these seem to get applied to all systems, not just GNU/Hurd, isn't
 that a concern?”
 
 By that, I mean this:
 
  +# Special treatment of EWOULDBLOCK for GNU/Hurd
  +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
  +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
  +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
  +

This applies to all systems yes, how to modify?

 and that:
 
  +# Special treatment of SYS_FCNTL for GNU/Hurd
  +if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
  +  echo const SYS_FCNTL = 0  ${OUT}
  +fi

And this applies to systems not defining FCNTL.
How many systems could possibly be affected?
 
 AIUI, the patch you propose does those changes for all systems, not just
 GNU/Hurd.  That most probably will pose a problem.

And you wrote in your reply to the above: see e.g.
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00644.html
 These should be fine, however.

I asked for help with sed but have not obtained any yet, so what to do?



Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Svante Signell
On Tue, 2014-05-06 at 14:51 +0200, Samuel Thibault wrote:
 Just to explicitly ask for it:
 
 Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
  For some (yet) unknown reason all libgo tests fails with a segfault when
  run in the build tree: make, sh or something else, the test commands are
  rather hard to track.
 
 Doesn't that dump a core?  Do you have /servers/crash properly pointing
 to /servers/crash-dump-core and ulimit -u set to unlimited?

fsysopts /servers/crash
ext2fs --writable --no-inherit-dir-group --store-type=typed device:hd0s1
ulimit -u
unlimited

  Number of tests succeeding with libpthread's stack guard fixed: 33 (and
  the other libc fixes)

Additionally 33 test pass with the fixed libpthread (some of them pass
but segfault before finishing). Still manual testing, no successful
tests with make -C ... check.



Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Svante Signell
On Tue, 2014-05-06 at 15:07 +0200, Samuel Thibault wrote:
 Svante Signell, le Tue 06 May 2014 15:05:20 +0200, a écrit :
  On Tue, 2014-05-06 at 14:51 +0200, Samuel Thibault wrote:
   Just to explicitly ask for it:
   
   Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
For some (yet) unknown reason all libgo tests fails with a segfault when
run in the build tree: make, sh or something else, the test commands are
rather hard to track.
   
   Doesn't that dump a core?  Do you have /servers/crash properly pointing
   to /servers/crash-dump-core and ulimit -u set to unlimited?
  
  fsysopts /servers/crash
  ext2fs --writable --no-inherit-dir-group --store-type=typed device:hd0s1
 
 See the type of file, it's a symlink, so just ls -l it.

ls -l /servers/crash
lrw-r--r-- 1 root root 10 May 17  2013 /servers/crash - crash-kill

Should I just ln -sf to change?



Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-02 Thread Svante Signell
On Fri, 2014-05-02 at 00:45 +0200, Samuel Thibault wrote:
 Hello,
 
 Svante Signell, le Thu 24 Apr 2014 10:39:10 +0200, a écrit :
  - Without split stack enabled around 70 libgo tests pass and 50 fails,
  most of them with a segfault.
  - Enabling split stack and using the libc Samuel built all 122 libgo
  tests fail with a segfault.
 
 Please provide segfault backtrace, rpctrace, etc.  Otherwise we won't be
 able to help you.

You already have one in this thread, analysed by Justus:
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01736.html

The full rpctrace and gdb backtrace for that case was published on
paste.debian.net, but are gone now. I can upload again if you need them,
or do you want it attached to a mail?



Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-02 Thread Svante Signell
On Fri, 2014-05-02 at 12:00 +0200, Samuel Thibault wrote:
 Samuel Thibault, le Fri 02 May 2014 11:57:53 +0200, a écrit :
  So we just need to fix guardsize in our libpthread.
 
 (And I'll have a look at it).

Maybe this can fix the around 40 segfaults (of 50 failures) when split
stack is disabled too? The segfaults are always around the same place in
libpthread. 



Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-04-26 Thread Svante Signell
±On Sat, 2014-04-26 at 08:53 +0200, Justus Winter wrote:
 Quoting Svante Signell (2014-04-24 10:39:10)
  On Fri, 2014-04-18 at 10:03 +0200, Samuel Thibault wrote:
   Samuel Thibault, le Thu 17 Apr 2014 00:03:45 +0200, a écrit :
Thomas Schwinge, le Wed 09 Apr 2014 09:36:42 +0200, a écrit :
 Well, the first step is to verify that 
 TARGET_THREAD_SPLIT_STACK_OFFSET
 and similar configury is correct for the Hurd,

I have added the corresponding field, so we can just use the same offset
as on Linux.
   
   I have uploaded packages on http://people.debian.org/~sthibault/tmp/ so
   Svante can try setting TARGET_THREAD_SPLIT_STACK_OFFSET to 0x30 with
   them.
  
  Status report:
  - Without split stack enabled around 70 libgo tests pass and 50 fails,
  most of them with a segfault.
  - Enabling split stack and using the libc Samuel built all 122 libgo
  tests fail with a segfault.
  - In both cases simple go programs work, like hello+sqrt.go below.
  - The segfault seems to be located at the same code piece according to
  gdb (maybe due to exception handling)
  
  cat hello+sqrt.go
  package main
  import (
  fmt
  )
  func main() {
  fmt.Printf(Hello, world.  Sqrt(2) = %v\n, Sqrt(2))
  }
 
 How is that even a valid go program? Sqrt is not defined.

Here is the sqrt.go:
// Package main is a trivial example package.
package main

// Sqrt returns an approximation to the square root of x.
func Sqrt(x float64) float64 {
z := 1.0
for i := 0; i  1000; i++ {
z -= (z*z - x) / (2 * z)
}
return z
}
gccgo-4.9 -g hello+sqrt.go sqrt.go

  I have not been able to use a local go library function, e.g. package
  newmath, and the go frontend is not yet available for GNU/Hurd.
 
 What do you mean exactly by local go library function?

Like having sqrt.go in a separate directory:

cat newmath/sqrt.go
// Package newmath is a trivial example package.
package newmath

// Sqrt returns an approximation to the square root of x.
func Sqrt(x float64) float64 {
z := 1.0
for i := 0; i  1000; i++ {
z -= (z*z - x) / (2 * z)
}
return z
}

  However, it seems that something triggers the segfaults when running
  make -C build/i486-gnu/libgo check (both with and w/o split-stack)
  while setting the keep parameter in ./src/libgo/testsuite/gotest
  and running them manually some of them work?? As a first glance, about
  the same number of tests succeeds with and w/o split stack :) Some of
  the failing tests still seems random, sometimes they pass, sometimes
  they fail.
 
 For reference, here are my notes about one of these crashes (Svante,
 is this still current?):

Yes it is, thanks for your help so far. Is the rpctrace bug you
mentioned that the wrong ports are reported?

 ~~~ snip ~~~
 First, there is a rpctrace bug (or, i'm misinterpreting the output):
 
   93--142(pid1182)-dir_lookup (etc/hostname 1 0) = 0 1 
 158--160(pid1182)
 
 Here, we do a dir_lookup and get port 158.
 
   158--160(pid1182)-io_read_request (-1 255) = 0 hurd-2013\n
   158--160(pid1182)-io_readable_request () = 0 0
 
 Here, we use it to do stuff with that file.
 
 task130(pid1182)-mach_port_deallocate (pn{ 23}) = 0 
 
 Here, we deallocate the port.  Note how the port name (pn?) says 23,
 even though it's clearly port 158 that is getting deallocated, b/c we
 get port 158 back from the next rpc:
 
   93--142(pid1182)-dir_lookup (lib/i386-gnu/libnss_files.so.2 4194305 0) 
 = 0 1 158--157(pid1182)
 
 Now, the get to the real issue.  From the backtrace 
 (http://paste.debian.net/95410/)
 we know that it segfaults in mmap:
 
 Program received signal SIGSEGV, Segmentation fault.
 0x019977b7 in _hurd_intr_rpc_msg_in_trap () at intr-msg.c:132
 132  intr-msg.c: No such file or directory.
 [...]
 Thread 4 (Thread 1205.4):
 #0  0x019977b7 in _hurd_intr_rpc_msg_in_trap () at intr-msg.c:132
 err = optimized out
 err = optimized out
 user_option = 3
 user_timeout = 48
 m = 0x532370
 msgh_bits = 0
 remote_port = 268509186
 msgid = 21118
 save_data = optimized out
 __PRETTY_FUNCTION__ = _hurd_intr_rpc_mach_msg
 #1  0x0005 in ?? ()
 No symbol table info available.
 #2  0x01a7a8dd in __mmap (addr=0x0, len=49880, prot=5, flags=33, fd=8, 
 offset=0)
 at ../sysdeps/mach/hurd/mmap.c:92
 __ulink = {resource = {next = 0x0, prevp = 0x2cfcc}, thread = {next = 
 0x0, 
 prevp = 0x1b81c5c}, cleanup = 0x19a2c70 _hurd_port_cleanup, 
 cleanup_data = 0x99}
 __ctty_ulink = {resource = {next = 0x0, prevp = 0x19fc6bc 
 _int_malloc+12}, thread = {
 next = 0x17, prevp = 0x5}, cleanup = 0x0, cleanup_data = 0x700f2}
 __result = optimized out
 descriptor = 0x1b5e467 __io_map+7
 robj = 0
 wobj = 4608
 err = optimized out
 vmprot = 0
 memobj = optimized out
 mapaddr = 0
 #3

[PATCH] Add support for GNU/Hurd in gnat-4.9

2014-04-25 Thread Svante Signell
Hello,

Attached is a patch for support of GNU/Hurd in gnat-4.9. This patch has
been used and updated in Debian since gnat-4.6, and is currently used to
build gnat-4.9. Now when the body file s-osinte-posix.adb in gcc-4.9
defines tv_nsec in timespec POSIX-correctly as long again, we think it
is time that it goes upstream. The patch contains two parts:

src/gcc/ada/gcc-interface/Makefile.in:
Defines LIBGNAT_TARGET_PAIRS for GNU/Hurd

src/gcc/ada/s-osinte-gnu.ads:
A new file giving the OS interface specification for GNU/Hurd. This file
is a modification of the already existing s-osinte-*.ads files.

Regarding copyright assignment, if needed, I've already signed the
papers for gcc (and other GNU packages).

Thanks!
Index: b/src/gcc/ada/s-osinte-gnu.ads
===
--- /dev/null
+++ b/src/gcc/ada/s-osinte-gnu.ads
@@ -0,0 +1,816 @@
+--
+--  --
+--GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--  S p e c --
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+--  Copyright (C) 1995-2011, Free Software Foundation, Inc. --
+--  --
+-- GNARL is free software; you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
+-- for  more details.  You should have  received  a copy of the GNU General --
+-- Public License  distributed with GNARL; see file COPYING.  If not, write --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.  --
+--  --
+-- As a special exception,  if other files  instantiate  generics from this --
+-- unit, or you link  this unit with other files  to produce an executable, --
+-- this  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd version of this package
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
+--  Preelaborate. This package is designed to be a bottom-level (leaf) package
+
+with Interfaces.C;
+with Unchecked_Conversion;
+
+package System.OS_Interface is
+   pragma Preelaborate;
+
+   pragma Linker_Options (-lpthread);
+   pragma Linker_Options (-lrt);
+
+   subtype intis Interfaces.C.int;
+   subtype char   is Interfaces.C.char;
+   subtype short  is Interfaces.C.short;
+   subtype long   is Interfaces.C.long;
+   subtype unsigned   is Interfaces.C.unsigned;
+   subtype unsigned_short is Interfaces.C.unsigned_short;
+   subtype unsigned_long  is Interfaces.C.unsigned_long;
+   subtype unsigned_char  is Interfaces.C.unsigned_char;
+   subtype plain_char is Interfaces.C.plain_char;
+   subtype size_t is Interfaces.C.size_t;
+
+   ---
+   -- Errno --
+   ---
+   --  From /usr/include/i386-gnu/bits/errno.h
+
+   function errno return int;
+   pragma Import (C, errno, __get_errno);
+
+   EAGAIN   : constant := 1073741859;
+   EINTR: constant := 1073741828;
+   EINVAL   : constant := 1073741846;
+   ENOMEM   : constant := 1073741836;
+   EPERM: constant := 1073741825;
+   ETIMEDOUT: constant := 1073741884;
+
+   

Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-04-24 Thread Svante Signell
On Fri, 2014-04-18 at 10:03 +0200, Samuel Thibault wrote:
 Samuel Thibault, le Thu 17 Apr 2014 00:03:45 +0200, a écrit :
  Thomas Schwinge, le Wed 09 Apr 2014 09:36:42 +0200, a écrit :
   Well, the first step is to verify that TARGET_THREAD_SPLIT_STACK_OFFSET
   and similar configury is correct for the Hurd,
  
  I have added the corresponding field, so we can just use the same offset
  as on Linux.
 
 I have uploaded packages on http://people.debian.org/~sthibault/tmp/ so
 Svante can try setting TARGET_THREAD_SPLIT_STACK_OFFSET to 0x30 with
 them.

Status report:
- Without split stack enabled around 70 libgo tests pass and 50 fails,
most of them with a segfault.
- Enabling split stack and using the libc Samuel built all 122 libgo
tests fail with a segfault.
- In both cases simple go programs work, like hello+sqrt.go below.
- The segfault seems to be located at the same code piece according to
gdb (maybe due to exception handling)

cat hello+sqrt.go
package main
import (
fmt
)
func main() {
fmt.Printf(Hello, world.  Sqrt(2) = %v\n, Sqrt(2))
}

I have not been able to use a local go library function, e.g. package
newmath, and the go frontend is not yet available for GNU/Hurd.

However, it seems that something triggers the segfaults when running
make -C build/i486-gnu/libgo check (both with and w/o split-stack)
while setting the keep parameter in ./src/libgo/testsuite/gotest
and running them manually some of them work?? As a first glance, about
the same number of tests succeeds with and w/o split stack :) Some of
the failing tests still seems random, sometimes they pass, sometimes
they fail.



Re: Hurd port for gcc go PATCH 0-3 (9)

2014-04-14 Thread Svante Signell
On Fri, 2014-04-11 at 22:52 +0200, Samuel Thibault wrote:
 Svante Signell, le Fri 11 Apr 2014 14:47:21 +0200, a écrit :
   #ifdef TARGET_LIBC_PROVIDES_SSP
  +/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
  +#define TARGET_THREAD_SSP_OFFSET   0x14
 
 Err, not the Hurd variant, no.  Is it really needed?

Don't know. Removed anyway.

  @@ -682,7 +686,7 @@
   go_net_cgo_file = go/net/cgo_linux.go
   go_net_sock_file = go/net/sock_linux.go
   go_net_sockopt_file = go/net/sockopt_linux.go
  -go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_posix.go
  +go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_bsd.go
   else
 
 This seems doubtful, isn't that the Linux case?

It was the Irix case. Fixed.



Re: Hurd port for gcc go PATCH 7-9 (9)

2014-04-14 Thread Svante Signell
On Fri, 2014-04-11 at 22:55 +0200, Samuel Thibault wrote:
 Svante Signell, le Fri 11 Apr 2014 14:57:35 +0200, a écrit :
  --- a/src/libgo/mksysinfo.sh
  +++ b/src/libgo/mksysinfo.sh
 
 Err, these seem to get applied to all systems, not just GNU/Hurd, isn't
 that a concern?
 
  @@ -210,6 +210,11 @@
 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
  +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
  +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
  +
   # The O_xxx flags.
   egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
 sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/'  ${OUT}
  @@ -225,6 +230,11 @@
 echo const F_DUPFD_CLOEXEC = 0  ${OUT}
   fi
   
  +# Special treatment of SYS_FCNTL for GNU/Hurd
  +if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
  +  echo const SYS_FCNTL = 0  ${OUT}
  +fi
  +
   # These flags can be lost on i386 GNU/Linux when using
   # -D_FILE_OFFSET_BITS=64, because we see #define F_SETLK F_SETLK64
   # before we see the definition of F_SETLK64.
 
 These should be fine, however.

OK!

  @@ -528,6 +538,8 @@
   
   # 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
   stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
   if test $stat != ; then
 grep '^type _stat64 ' gen-sysinfo.go
  @@ -536,6 +548,7 @@
   fi | sed -e 's/type _stat64/type Stat_t/' \
-e 's/type _stat/type Stat_t/' \
-e 's/st_dev/Dev/' \
  + -e 's/st_fsid/Dev/' \
-e 's/st_ino/Ino/g' \
-e 's/st_nlink/Nlink/' \
-e 's/st_mode/Mode/' \

Don't know if any other system defines st_fsid as st_dev like Hurd does.
If not this one would be fine too?




Re: Hurd port for gcc go PATCH 7-9 (9)

2014-04-14 Thread Svante Signell
On Mon, 2014-04-14 at 11:03 +0200, Samuel Thibault wrote:
 Svante Signell, le Mon 14 Apr 2014 09:59:03 +0200, a écrit :
@@ -528,6 +538,8 @@
 
 # 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
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test $stat != ; then
   grep '^type _stat64 ' gen-sysinfo.go
@@ -536,6 +548,7 @@
 fi | sed -e 's/type _stat64/type Stat_t/' \
  -e 's/type _stat/type Stat_t/' \
  -e 's/st_dev/Dev/' \
+ -e 's/st_fsid/Dev/' \
  -e 's/st_ino/Ino/g' \
  -e 's/st_nlink/Nlink/' \
  -e 's/st_mode/Mode/' \
  
  Don't know if any other system defines st_fsid as st_dev like Hurd does.
  If not this one would be fine too?
 
 I don't know any other system doing it, but a sed rule can't hurt even
 if there is no occurrence...

The current code was written by Thomas. I had the following in an older,
not so elegant patch: (I'm in no way fluent in sed, I need help here):
(indentation modified)

if grep 'define st_dev st_fsid' gen-sysinfo.go /dev/null 21; then
 grep '^type _stat ' gen-sysinfo.go | \
 sed -i.bak -e 's/st_fsid\([^;]*\)/st_fsid\1; st_dev\1/' gen-sysinfo.go
 grep '^type _stat ' ${OUT} | \
 sed -i.bak -e 's/st_fsid\([^;]*\)/; st_dev\1/' ${OUT}
fi




Re: Hurd port for gcc go PATCH 0-3 (9)

2014-04-12 Thread Svante Signell
On Fri, 2014-04-11 at 07:48 -0700, Ian Lance Taylor wrote:
 On Fri, Apr 11, 2014 at 5:47 AM, Svante Signell
 svante.sign...@gmail.com wrote:
 
  Attached are patches to enable gccgo to build properly on Debian
  GNU/Hurd on gcc-4.9 (4.9-20140406).
 
 Thanks.  Will review after 4.9 has branched.

Thanks! Modified patches will follow soon based on the comments made by
Samuel and some other changes.

  Note: Creating the Makefile.in is hard (unnecessary) work since automake
  is no longer used in the build system.
  Both (cd src/libgo;automake-1.11) and (cd src/libgo;autoreconf2.64)
  fails. The diff for Makefile.in has to be patched by hand with the aid
  of the diff for Makefile.am :( This file should be possible to generate
  from Makefile.am when modifying manually. In my opinion the build system
  is broken wrt libgo.
 
 I don't understand this comment.  The GCC libraries do still use
 automake.  I regularly use automake to regenerate the libgo
 Makefile.in file.  What fails when you try it?

(cd src/libgo;automake-1.11)
aclocal.m4:16: warning: this file was generated for autoconf 2.64.
You have another version of autoconf.  It may work, but is not
guaranteed to.
If you have problems, you may need to regenerate the build system
entirely.
To do so, use the procedure documented by the package, typically
`autoreconf'.
config/go.m4:10: error: m4_copy: won't overwrite defined macro:
AC_LANG_CONFTEST(Go)
config/go.m4:10: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
automake-1.11: autoconf failed with exit status: 1

(cd src/libgo;autoreconf2.64)
configure.ac:22: error: Autoconf version 2.65 or higher is required
/usr/share/aclocal-1.14/init.m4:29: AM_INIT_AUTOMAKE is expanded from...
configure.ac:22: the top level
autom4te2.64: /usr/bin/m4 failed with exit status: 63
aclocal: error: echo failed with exit status: 63
autoreconf2.64: aclocal failed with exit status: 63

Installing autoconf2.65 does not work either :(
dpkg -i autoconf_2.65-4_all.deb'
dpkg: warning: downgrading autoconf from 2.69-6 to 2.65-4
(Reading database ... 183400 files and directories currently installed.)
Preparing to unpack .../autoconf_2.65-4_all.deb ...
Unpacking autoconf (2.65-4) over (2.69-6) ...
Setting up autoconf (2.65-4) ...

(cd src/libgo;autoreconf)
configure.ac:10: error: Please use exactly Autoconf 2.64 instead of
2.65.
../config/override.m4:12: _GCC_AUTOCONF_VERSION_CHECK is expanded
from...
configure.ac:10: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1





Re: Hurd port for gcc go PATCH 0-3 (9)

2014-04-12 Thread Svante Signell
On Sat, 2014-04-12 at 16:04 +0200, Svante Signell wrote:
 On Fri, 2014-04-11 at 07:48 -0700, Ian Lance Taylor wrote:
  On Fri, Apr 11, 2014 at 5:47 AM, Svante Signell
  svante.sign...@gmail.com wrote:

  
  I don't understand this comment.  The GCC libraries do still use
  automake.  I regularly use automake to regenerate the libgo
  Makefile.in file.  What fails when you try it?

It seems that it is a Debian problem, they don't use automake any more,
they use */Makefile.in for building. (and creating Makefile.in from
Makefile.am is broken). Sorry for the noise, I'll file a bug in Debian
BTS about this.



Hurd port for gcc go PATCH 0-3 (9)

2014-04-11 Thread Svante Signell
Hi,

Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-4.9 (4.9-20140406). With split stack disabled around 70
libgo tests PASS and 50 FAIL (result seems to be somewhat random,
alignment problems there too?). With split stack enabled _all_ tests
fail, see
https://lists.gnu.org/archive/html/bug-hurd/2013-06/msg00100.html

patch0.diff is Debian specific, patch1.diff should be applied when
split-stack works properly while the rest are available for upstream.

patch0.diff: debian/rules.defs:
go_no_systems: remove gnu,
with_go: Check for DEB_TARGET_GNU_OS instead of DEB_TARGET_GNU_SYSTEM.
Otherwise kfreebsd-gnu causes go_no_systems to still be true for gnu.

patch1.diff: src/gcc/config/i386/gnu.h:
Enables split stack for GNU/Hurd. Until split-stack works properly with
the pthread library of Hurd this patch should not be applied. Maybe the
offsets should change, but that has to be synchronized with the
src/libgcc/config/i386/morestack.S assembly routine (unfortunately asm
is not my piece of cake).

patch2.diff: src/libgo/configure.ac:
Add GNU as a supported target OS for go.

patch3.diff: src/libgo/Makefile.am, src/libgo/Makefile.in
Add GNU specific go routines with the LIBGO_IS_GNU conditional.

Note: Creating the Makefile.in is hard (unnecessary) work since automake
is no longer used in the build system. 
Both (cd src/libgo;automake-1.11) and (cd src/libgo;autoreconf2.64)
fails. The diff for Makefile.in has to be patched by hand with the aid
of the diff for Makefile.am :( This file should be possible to generate
from Makefile.am when modifying manually. In my opinion the build system
is broken wrt libgo.

--- a/debian/rules.defs	2014-01-07 11:10:44.0 +0100
+++ b/debian/rules.defs	2014-01-07 11:23:47.0 +0100
@@ -721,7 +721,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd-gnu
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
@@ -731,7 +731,7 @@
 ifneq (,$(filter $(DEB_TARGET_ARCH_CPU),$(go_no_cpus)))
   with_go := disabled for cpu $(DEB_TARGET_ARCH_CPU)
 endif
-ifneq (,$(findstring $(DEB_TARGET_GNU_SYSTEM),$(go_no_systems)))
+ifneq (,$(findstring $(DEB_TARGET_ARCH_OS),$(go_no_systems)))
   with_go := disabled for system $(DEB_TARGET_GNU_SYSTEM)
 endif
 ifeq ($(go_no_cross)-$(DEB_CROSS),yes-yes)
--- a/src/gcc/config/i386/gnu.h.orig	2014-01-05 20:58:22.0 +0100
+++ b/src/gcc/config/i386/gnu.h	2014-04-07 11:21:00.0 +0200
@@ -36,12 +36,14 @@
 #endif
 
 #ifdef TARGET_LIBC_PROVIDES_SSP
+/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+#define TARGET_THREAD_SSP_OFFSET	0x14
 
-/* Not supported yet.  */
-# undef TARGET_THREAD_SSP_OFFSET
-
-/* Not supported yet.  */
-# undef TARGET_CAN_SPLIT_STACK
-# undef TARGET_THREAD_SPLIT_STACK_OFFSET
-
+/* 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
--- a/src/libgo/configure.ac
+++ b/src/libgo/configure.ac
@@ -136,6 +136,7 @@
 is_dragonfly=no
 is_rtems=no
 is_solaris=no
+is_gnu=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -147,6 +148,7 @@
   *-*-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)
@@ -157,6 +159,7 @@
 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)
 AC_SUBST(GOOS)
 
 dnl Test whether we need to use DejaGNU or whether we can use the
--- a/src/libgo/Makefile.am
+++ b/src/libgo/Makefile.am
@@ -418,9 +418,13 @@
 if LIBGO_IS_SOLARIS
 runtime_netpoll_files = runtime/netpoll_select.c
 else
+if LIBGO_IS_GNU
+runtime_netpoll_files = runtime/netpoll_select.c
+else
 runtime_netpoll_files = runtime/netpoll_kqueue.c
 endif
 endif
+endif
 
 runtime_files = \
 	runtime/go-append.c \
@@ -682,7 +686,7 @@
 go_net_cgo_file = go/net/cgo_linux.go
 go_net_sock_file = go/net/sock_linux.go
 go_net_sockopt_file = go/net/sockopt_linux.go
-go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_posix.go
+go_net_sockoptip_file = go/net/sockoptip_linux.go go/net/sockoptip_bsd.go
 else
 if LIBGO_IS_SOLARIS
 go_net_cgo_file = go/net/cgo_linux.go
@@ -702,6 +706,12 @@
 go_net_sockopt_file = go/net/sockopt_bsd.go
 go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
 else
+if 

[Fwd: Hurd port for gcc go PATCH 4-6 (9)]

2014-04-11 Thread Svante Signell

---BeginMessage---
(continued)

patch4.diff: src/libgo/go/syscall/libcall_posix-1.go:
New file, a copy of libcall_posix.go with the mount call removed.
mount/umount functionality exists but is currently part of Hurd
utilities.

patch5.diff: src/libgo/go/net/sock_gnu.go
Create a dummy function for maxListenerBacklog() until implemented.

patch6.diff: src/libgo/go/syscall/libcall_gnu.go
Create a dummy function for raw_ptrace() until implemented.

--- a/src/libgo/go/syscall/libcall_posix.go
+++ b/src/libgo/go/syscall/libcall_posix.go
@@ -3,6 +3,8 @@
 // license that can be found in the LICENSE file.
 
 // POSIX library calls.
+// Removed the mount call for GNU/Hurd, it exists but use translators.
+// Functionality is not the same as descibed in sys/mount.h
 // This file is compiled as ordinary Go code,
 // but it is also input to mksyscall,
 // which parses the //sys lines and generates library call stubs.
@@ -271,9 +273,6 @@
 //sys	Mknod(path string, mode uint32, dev int) (err error)
 //mknod(path *byte, mode Mode_t, dev _dev_t) _C_int
 
-//sys	Mount(source string, target string, fstype string, flags uintptr, data string) (err error)
-//mount(source *byte, target *byte, fstype *byte, flags _C_long, data *byte) _C_int
-
 //sys	Nanosleep(time *Timespec, leftover *Timespec) (err error)
 //nanosleep(time *Timespec, leftover *Timespec) _C_int
 
--- /dev/null
+++ b/src/libgo/go/net/sock_gnu.go
@@ -0,0 +1,14 @@
+// Copyright 2014 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.
+
+// +build gnu
+
+package net
+
+import syscall
+
+func maxListenerBacklog() int {
+   // TODO: Implement this
+   return syscall.SOMAXCONN
+}
--- /dev/null
+++ b/src/libgo/go/syscall/libcall_gnu.go
@@ -0,0 +1,11 @@
+// Copyright 2014 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.
+//FIXME: Try with libcall_irix.go
+
+package syscall
+
+// Dummy function
+func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+return ENOSYS
+}
---End Message---


[Fwd: Hurd port for gcc go PATCH 7-9 (9)]

2014-04-11 Thread Svante Signell

---BeginMessage---
(continued)

patch7.diff: src/libgo/go/syscall/wait.c
Set WCONTINUED to zero if not defined (same fix as for lto in gcc-4.9)

patch8.diff: src/libgo/mksysinfo.sh
Add special treatment of EWOULDBLOCK, SYS_FCNTL and st_dev since they
are either not defined or defined differently for the script to catch
them. 

patch9.diff: src/libgo/runtime/netpoll.goc
Rename errno to errno1 since errno clashes with errno.h included in
that file on Hurd.
--- a/src/libgo/go/syscall/wait.c
+++ b/src/libgo/go/syscall/wait.c
@@ -8,6 +8,9 @@
OS-independent.  */
 
 #include stdint.h
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
 #include sys/wait.h
 
 #include runtime.h
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -210,6 +210,11 @@
   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
+egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/'  ${OUT}
@@ -225,6 +230,11 @@
   echo const F_DUPFD_CLOEXEC = 0  ${OUT}
 fi
 
+# Special treatment of SYS_FCNTL for GNU/Hurd
+if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
+  echo const SYS_FCNTL = 0  ${OUT}
+fi
+
 # These flags can be lost on i386 GNU/Linux when using
 # -D_FILE_OFFSET_BITS=64, because we see #define F_SETLK F_SETLK64
 # before we see the definition of F_SETLK64.
@@ -528,6 +538,8 @@
 
 # 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
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test $stat != ; then
   grep '^type _stat64 ' gen-sysinfo.go
@@ -536,6 +548,7 @@
 fi | sed -e 's/type _stat64/type Stat_t/' \
  -e 's/type _stat/type Stat_t/' \
  -e 's/st_dev/Dev/' \
+ -e 's/st_fsid/Dev/' \
  -e 's/st_ino/Ino/g' \
  -e 's/st_nlink/Nlink/' \
  -e 's/st_mode/Mode/' \
--- a/src/libgo/runtime/netpoll.goc.orig	2013-11-07 01:23:21.0 +0100
+++ b/src/libgo/runtime/netpoll.goc	2014-03-28 09:07:15.0 +0100
@@ -68,7 +68,7 @@
 	runtime_netpollinit();
 }
 
-func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno int) {
+func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno1 int) {
 	pd = allocPollDesc();
 	runtime_lock(pd);
 	if(pd-wg != nil  pd-wg != READY)
@@ -84,7 +84,7 @@
 	pd-wd = 0;
 	runtime_unlock(pd);
 
-	errno = runtime_netpollopen(fd, pd);
+	errno1 = runtime_netpollopen(fd, pd);
 }
 
 func runtime_pollClose(pd *PollDesc) {
---End Message---


Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-04-09 Thread Svante Signell
On Fri, 2014-04-04 at 21:14 +0200, Samuel Thibault wrote:
 Hello,
 
 Thomas Schwinge, le Wed 26 Jun 2013 23:30:03 +0200, a écrit :
  On Sat, 22 Jun 2013 08:15:46 -0700, Ian Lance Taylor i...@google.com 
  wrote:
   Go can work without split stack.  In that case libgo will use much
   larger stacks for goroutines, to reduce the chance of running out of
   stack space (see StackMin in libgo/runtime/proc.c).  So the number of
   simultaneous goroutines that can be run will be limited.  This is
   usually OK on x86_64 but it does hamper Go programs running on 32-bit
   x86.
  
  OK, but that's not the most pressing issue we're having right now.
  Anyway, as it stands, the split-stack code doesn't work on Hurd, so I
  disabled it in r200434 as follows:
 
 Maybe you'd want to re-enable it, now that we have got rid of threadvars :)

I don't think it is a good idea. I've patched gcc-4.9-20140406 to make
gccgo build and tested with -fsplit-stack enabled (with and without the
gold linker). Without split stack around 70 libgo tests pass and 50
fails. With it enabled all tests fail. Simple examples are the following
C code (from Thomas) and GO code:

1)
cat test_split_stack.c 
#include mach.h
#include stdio.h

int main(void)
{
  int err;
  vm_address_t addr = 0;

  int i;
  for (i = 0; i  3; ++i)
{
  err = vm_allocate(mach_task_self(), addr, 4096, 1);
  printf(%u %p\n, err, (void *) addr);
}
  return 0;
}
$ gcc-4.9 test_split_stack.c -fsplit-stack
$ ./a.out
0 (nil)
0 0x102c000
0 0x1027800

$ gcc-4.9 test_split_stack.c
$ ./a.out
0 0x102c000
0 0x125b000
0 0x125c000

2)
cat hello.go:
package main

import fmt

func main() {
fmt.Printf(Hello, world.\n)
}

gccgo-4.9 -g hello.go
 ./a.out
Hello, world.

LD_PRELOAD=../gcc-4.9-4.9-20140406/build/i486-gnu/libgo/.libs/libgo.so.5.0.0 
./a.out
mmap errno 1073741846
fatal error: mmap

runtime stack:
^C

Something is still not OK with the treads library?

Patches for gccgo on GNU/Hurd will be submitted to the Debian BTS.



Re: Please revert the patches in bug #54040 and #59346 and special case x32

2014-04-09 Thread Svante Signell
On Wed, 2014-04-09 at 14:41 +0200, Arnaud Charlet wrote:
  What do you think, Arno?  I think that the POSIX breakage (and its fallout 
  for
  the other Unices) is ugly and worth the additional complication.
 
 Yes, your patch looks good to me.

Would it be possible to have s-osinte-posix.adb also for x32 and in
s-osinte-x32.ads use the following construct:
...
   type timespec is private;
...
   type timespec is record
  tv_sec  : time_t;
  tv_nsec : long log;
   end record;
   pragma Convention (C, timespec);

and similiar for timeval if needed?

That's the construct other unices use now when s-osinte-posix.adb
defines tv_nsec as time_t?



Re: Please revert the patches in bug #54040 and #59346 and special case x32

2014-04-09 Thread Svante Signell
On Wed, 2014-04-09 at 16:24 +0200, Eric Botcazou wrote:
  Would it be possible to have s-osinte-posix.adb also for x32 and in
  s-osinte-x32.ads use the following construct:
  ...
 type timespec is private;
  ...
 type timespec is record
tv_sec  : time_t;
tv_nsec : long long;
 end record;
 pragma Convention (C, timespec);
  
  and similiar for timeval if needed?
  
  That's the construct other unices use now when s-osinte-posix.adb
  defines tv_nsec as time_t?
 
 Not sure what the now is referring to, but if you want to revert the 
 original POSIX breakage in s-osinte-posix.adb, you need to define timespec 
 according to the POSIX spec, there is no other way.

I thought of creating a new type for x32: 

type nanosec_t is private; 
type nanosec_t is new long long;

  type timespec is record
  tv_sec  : time_t;
  tv_nsec : nanosec_t;
   end record;

Having the correct definition of tv_nsec in s-osinte-posix.adb
   type timespec is record
  tv_sec  : time_t;
  tv_nsec : long;
   end record;
   pragma Convention (C, timespec);




Re: Please revert the patches in bug #54040 and #59346 and special case x32

2014-04-08 Thread Svante Signell
On Tue, 2014-04-08 at 09:26 +0200, Eric Botcazou wrote:
  Attached is a patch reverting the two commits for PR ada/54040:
  http://gcc.gnu.org/git/?p=gcc.gita=searchh=HEADst=commits=PR+ada%
  2F54040
 
 I don't think that's sufficient though, IIRC there were followup changes, so 
 you'd better diff the current code with the revision just prior to the change.

The only changes I've found are: (in the previously attached patch)
(the other commits refer to 
2014-01-26: lynxos
2014-01-24: android
2014-01-20: linux
2013-01-29 : vms
and they are not related to the patches needing a revert.

(I did make a diff from current to the version before and did not find
anything new). I have also built the reverted version on GNU/Linux
x86-64 out of the box. The only thing needed to change after the revert
might be copyright years.

commit d2a4f256f9bc035ef2d6874c4e4c20c83ebf00b4
Author: ebotcazou ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4
Date:   Fri Nov 29 16:19:36 2013 +

PR ada/54040
PR ada/59346
* s-osinte-hpux.ads (timespec): Change type of tv_nsec field to
time_t.
* s-osinte-kfreebsd-gnu.ads (timespec): Likewise.
* s-osinte-solaris-posix.ads (timespec): Li2014-01-24kewise.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205532
138bc75d-0d04-0410-961f-82ee72b0

commit e3a1f6b50495473f677f413d8740808a3fde5a9a
Author: hjl hjl@138bc75d-0d04-0410-961f-82ee72b054a4
Date:   Fri Nov 15 12:06:25 2013 +

Add and use System.Linux.time_t for time_t

PR ada/54040
* s-linux-x32.ads: New file.
* s-osprim-x32.adb: Likewise.
* s-linux.ads (time_t): New type.
* s-linux-alpha.ads (time_t):  Likewise.
* s-linux-hppa.ads (time_t):  Likewise.
* s-linux-mipsel.ads (time_t):  Likewise.
* s-linux-sparc.ads (time_t):  Likewise.
* s-osinte-linux.ads (time_t): Mark it private.  Replace long
with System.Linux.time_t.
(timespec): Replace long with time_t.
* s-osinte-posix.adb (To_Timespec): Likewise.
* s-taprop-linux.adb (timeval): Replace C.long with
System.OS_Interface.time_t.
* gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS): Replace
s-linux.ads with s-linux-x32.ads, s-osprim-posix.adb with
s-osprim-x32.adb for x32.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204840
138bc75d-0d04-0410-961f-82ee72b0

Then we have but this one was before adding x32-specific files:

commit 70d595c8e41c9a7fdf5049c5a48c3b50304c8cbe
Author: hjl hjl@138bc75d-0d04-0410-961f-82ee72b054a4
Date:   Sat Mar 3 17:04:49 2012 +

Add Linux/x32 support to Ada

2012-03-03  H.J. Lu  hongjiu...@intel.com

* init.c (__gnat_adjust_context_for_raise): Also check
orq $0x0,(%esp) for x32.

* link.c (__gnat_default_libgcc_subdir): set to libx32 for x32.

* gcc-interface/Makefile.in (arch): Set to x32 if MULTISUBDIR
is /x32.
Support x32.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184859
138bc75d-0d04-0410-961f-82ee72b0






Re: Please revert the patches in bug #54040 and #59346 and special case x32

2014-04-01 Thread Svante Signell
On Wed, 2014-03-26 at 00:25 +0100, Eric Botcazou wrote:
  Should I file a bug to get feedback on this issue? I know Ada is not the
  most prioritized language for gcc, but anyway. The current
  implementation is not POSIX-compliant.
 
 Can you post a complete patch doing the reversion?  Breaking POSIX and every 
 Unix for the sake of x32 is definitely too much in my opinion.

Attached is a patch reverting the two commits for PR ada/54040:
http://gcc.gnu.org/git/?p=gcc.gita=searchh=HEADst=commits=PR+ada%
2F54040

I will try to create a patch for x32, but need to get such an image
built and running to do that. Until then, it is better that x32 is
broken and all other architectures are not (at least in my opinion).

diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 352d655..935c6c3 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -2231,11 +2231,11 @@ ifeq ($(strip $(filter-out %x32 linux%,$(target_cpu) $(target_os))),)
   a-synbar.adsa-synbar-posix.ads \
   s-inmaop.adbs-inmaop-posix.adb \
   s-intman.adbs-intman-posix.adb \
-  s-linux.adss-linux-x32.ads \
+  s-linux.adss-linux.ads \
   s-mudido.adbs-mudido-affinity.adb \
   s-osinte.adss-osinte-linux.ads \
   s-osinte.adbs-osinte-posix.adb \
-  s-osprim.adbs-osprim-x32.adb \
+  s-osprim.adbs-osprim-posix.adb \
   s-taprop.adbs-taprop-linux.adb \
   s-tasinf.adss-tasinf-linux.ads \
   s-tasinf.adbs-tasinf-linux.adb \
diff --git a/gcc/ada/s-linux-alpha.ads b/gcc/ada/s-linux-alpha.ads
index 1a9f37a..a700c97 100644
--- a/gcc/ada/s-linux-alpha.ads
+++ b/gcc/ada/s-linux-alpha.ads
@@ -38,12 +38,6 @@
 package System.Linux is
pragma Preelaborate;
 
-   
-   -- time_t --
-   
-
-   type time_t is new Long_Integer;
-
---
-- Errno --
---
diff --git a/gcc/ada/s-linux-hppa.ads b/gcc/ada/s-linux-hppa.ads
index 9046150..d25dceb 100644
--- a/gcc/ada/s-linux-hppa.ads
+++ b/gcc/ada/s-linux-hppa.ads
@@ -38,12 +38,6 @@
 package System.Linux is
pragma Preelaborate;
 
-   
-   -- time_t --
-   
-
-   type time_t is new Long_Integer;
-
---
-- Errno --
---
diff --git a/gcc/ada/s-linux-mipsel.ads b/gcc/ada/s-linux-mipsel.ads
index 028ea7c..f1b119d 100644
--- a/gcc/ada/s-linux-mipsel.ads
+++ b/gcc/ada/s-linux-mipsel.ads
@@ -37,12 +37,6 @@
 package System.Linux is
pragma Preelaborate;
 
-   
-   -- time_t --
-   
-
-   type time_t is new Long_Integer;
-
---
-- Errno --
---
diff --git a/gcc/ada/s-linux-sparc.ads b/gcc/ada/s-linux-sparc.ads
index db3b4ea..3ba20da 100644
--- a/gcc/ada/s-linux-sparc.ads
+++ b/gcc/ada/s-linux-sparc.ads
@@ -38,12 +38,6 @@
 package System.Linux is
pragma Preelaborate;
 
-   
-   -- time_t --
-   
-
-   type time_t is new Long_Integer;
-
---
-- Errno --
---
diff --git a/gcc/ada/s-linux-x32.ads b/gcc/ada/s-linux-x32.ads
deleted file mode 100644
index 9dc0e83..000
--- a/gcc/ada/s-linux-x32.ads
+++ /dev/null
@@ -1,110 +0,0 @@
---
---  --
---GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
---  --
---  S Y S T E M .  L I N U X--
---  --
---  S p e c --
---  --
---  Copyright (C) 2013, Free Software Foundation, Inc.  --
---  --
--- GNARL is free software; you can  redistribute it  and/or modify it under --
--- terms of the  GNU General Public License as published  by the Free Soft- --
--- ware  Foundation;  either version 3,  or (at your option) any later ver- --
--- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
--- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE. --
---  --
--- As a special exception under Section 7 of GPL version 3, you are granted --
--- additional permissions described in the GCC Runtime Library Exception,   --
--- version 3.1, as published by the Free Software Foundation.   --
---  --
--- You should have received a copy of the GNU General Public License and--
--- a copy of the GCC Runtime Library Exception along with this program; --
--- see the files COPYING3 and 

Re: Please revert the patches in bug #54040 and #59346 and special case x32

2014-03-26 Thread Svante Signell
On Wed, 2014-03-26 at 00:25 +0100, Eric Botcazou wrote:
  Should I file a bug to get feedback on this issue? I know Ada is not the
  most prioritized language for gcc, but anyway. The current
  implementation is not POSIX-compliant.
 
 Can you post a complete patch doing the reversion?  Breaking POSIX and every 
 Unix for the sake of x32 is definitely too much in my opinion.

The commits are:
http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e3a1f6b50495473f677f413d8740808a3fde5a9a

http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d2a4f256f9bc035ef2d6874c4e4c20c83ebf00b4

I think doing special casing for x32 as indicated in the previous mail
could solve the problem also for that architecture.

Add/modify gcc/ada/{s-linux-x32.ads,s-osprim-x32.ads} according to:
   type tv_nsec_t is private;
   type tv_nsec_t is new Long_Long_Integer;
   type timespec is record
  tv_sec  : time_t;
  tv_nsec : tv_nsec_t;
   end record;
   pragma Convention (C, timespec);



Re: Please revert the patches in bug #54040 and #59346 and special case x32

2014-03-25 Thread Svante Signell
Hi, 

Should I file a bug to get feedback on this issue? I know Ada is not the
most prioritized language for gcc, but anyway. The current
implementation is not POSIX-compliant.

On Mon, 2014-03-24 at 14:37 +0100, Svante Signell wrote:
 In reply to the thread ending with:
 http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02069.html
 
 and bugs:
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54040
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59346
 
 Changing s-osinte-posix.adb
 
 -  tv_nsec = long (Long_Long_Integer (F * 10#1#E9)));
 +  tv_nsec = time_t (Long_Long_Integer (F * 10#1#E9)));
 
 breaks the build for kFreeBSD and Hurd too (in addition to hpux and solaris).
 
 Note that POSIX specified tv_nsec to be long (i.e. 64 bit), see:
 http://pubs.opengroup.org/onlinepubs/009695299/basedefs/time.h.html
 The time.h header shall declare the structure timespec, which has at
 least the following members:
 time_t  tv_secSeconds. 
 longtv_nsec   Nanoseconds.
 
 Additionally Linux/kFreeBSD/Hurd all defines struct timespec in time.h as 
 follows:
 /* POSIX.1b structure for a time value.  This is like a `struct timeval'
 but
has nanoseconds instead of microseconds.  */
 struct timespec
   {
 __time_t tv_sec;/* Seconds.  */
 __syscall_slong_t tv_nsec;  /* Nanoseconds.  */
   };
 
 So defining tv_nsec to be time_t is completely wrong. The problem seems
 to be present only for the x32 architecture, so why not make a special-case
 solution for that arch. Obviously x32 is non-POSIX compliant since long
 is 32 bits, resulting in tv_nsec being 32 bits where it needs to be 64
 bits. Isn't it possible to handle the differences for x32 with a
 s-osinte-linux-x32.ads file, even with s-osinte-posix.adb stays intact?
 
 Then ther changes would be limited to:
 * s-linux-x32.ads: New file.
 * s-osprim-x32.adb: Likewise.
 * gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS): Replace
 s-linux.ads with s-linux-x32.ads, s-osprim-posix.adb with
 s-osprim-x32.adb for x32.
 and the rest would be obsolete:
 * s-linux.ads (time_t): New type.
 * s-linux-alpha.ads (time_t):  Likewise.
 * s-linux-hppa.ads (time_t):  Likewise.
 * s-linux-mipsel.ads (time_t):  Likewise.
 * s-linux-sparc.ads (time_t):  Likewise.
 * s-osinte-linux.ads (time_t): Mark it private.  Replace long
 with System.Linux.time_t.
 (timespec): Replace long with time_t.
 * s-osinte-posix.adb (To_Timespec): Likewise.
 * s-taprop-linux.adb (timeval): Replace C.long with
 System.OS_Interface.time_t.
 and
* s-osinte-hpux.ads (timespec): Change type of tv_nsec field to time_t.
* s-osinte-kfreebsd-gnu.ads (timespec): Likewise.
* s-osinte-solaris-posix.ads (timespec): Likewise.
 
 Possible content in s-osinte-linux-x32.ads would be:
type tv_nsec_t is private;
type tv_nsec_t is new Long_Long_Integer;
type timespec is record
   tv_sec  : time_t;
   tv_nsec : tv_nsec_t;
end record;
pragma Convention (C, timespec);
 
 




Please revert the patches in bug #54040 and #59346 and special case x32

2014-03-24 Thread Svante Signell
In reply to the thread ending with:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02069.html

and bugs:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54040
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59346

Changing s-osinte-posix.adb

-  tv_nsec = long (Long_Long_Integer (F * 10#1#E9)));
+  tv_nsec = time_t (Long_Long_Integer (F * 10#1#E9)));

breaks the build for kFreeBSD and Hurd too (in addition to hpux and solaris).

Note that POSIX specified tv_nsec to be long (i.e. 64 bit), see:
http://pubs.opengroup.org/onlinepubs/009695299/basedefs/time.h.html
The time.h header shall declare the structure timespec, which has at
least the following members:
time_t  tv_secSeconds. 
longtv_nsec   Nanoseconds.

Additionally Linux/kFreeBSD/Hurd all defines struct timespec in time.h as 
follows:
/* POSIX.1b structure for a time value.  This is like a `struct timeval'
but
   has nanoseconds instead of microseconds.  */
struct timespec
  {
__time_t tv_sec;/* Seconds.  */
__syscall_slong_t tv_nsec;  /* Nanoseconds.  */
  };

So defining tv_nsec to be time_t is completely wrong. The problem seems
to be present only for the x32 architecture, so why not make a special-case
solution for that arch. Obviously x32 is non-POSIX compliant since long
is 32 bits, resulting in tv_nsec being 32 bits where it needs to be 64
bits. Isn't it possible to handle the differences for x32 with a
s-osinte-linux-x32.ads file, even with s-osinte-posix.adb stays intact?

Then ther changes would be limited to:
* s-linux-x32.ads: New file.
* s-osprim-x32.adb: Likewise.
* gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS): Replace
s-linux.ads with s-linux-x32.ads, s-osprim-posix.adb with
s-osprim-x32.adb for x32.
and the rest would be obsolete:
* s-linux.ads (time_t): New type.
* s-linux-alpha.ads (time_t):  Likewise.
* s-linux-hppa.ads (time_t):  Likewise.
* s-linux-mipsel.ads (time_t):  Likewise.
* s-linux-sparc.ads (time_t):  Likewise.
* s-osinte-linux.ads (time_t): Mark it private.  Replace long
with System.Linux.time_t.
(timespec): Replace long with time_t.
* s-osinte-posix.adb (To_Timespec): Likewise.
* s-taprop-linux.adb (timeval): Replace C.long with
System.OS_Interface.time_t.
and
   * s-osinte-hpux.ads (timespec): Change type of tv_nsec field to time_t.
   * s-osinte-kfreebsd-gnu.ads (timespec): Likewise.
   * s-osinte-solaris-posix.ads (timespec): Likewise.

Possible content in s-osinte-linux-x32.ads would be:
   type tv_nsec_t is private;
   type tv_nsec_t is new Long_Long_Integer;
   type timespec is record
  tv_sec  : time_t;
  tv_nsec : tv_nsec_t;
   end record;
   pragma Convention (C, timespec);




Re: [PATCH] GCC Ada/GNAT configuration for GNU/Hurd

2012-06-18 Thread Svante Signell
On Mon, 2012-06-18 at 12:23 +0200, Arnaud Charlet wrote:
  Here is a patch that adds a basic GCC Ada/GNAT configuration for x86
  GNU/Hurd.  This has originally been created by Svante Signell for use
  with Debian's GCC 4.6 package, and now I have ported it to trunk, and
  also applied some further changes.
  
  2012-06-16  Svante Signell  svante.sign...@telia.com
  Thomas Schwinge  tho...@codesourcery.com
  
  gcc/ada/
  * gcc-interface/Makefile.in: Add configuration for x86 GNU/Hurd.
  * gsocket.h [__GNU__] (Has_Sockaddr_Len): #define to 1.
  * s-oscons-tmplt.c: Add checks for __GNU__ next to several __linux__
  and linux conditionals.
  * terminals.c [__GNU__]: Don't #include termio.h.  #define USE_GETPT.
  * s-osinte-gnu.ads: New file.
  * s-taprop-gnu.adb: Likewise.
 
 Well, the main question is: who is volunteering to maintain this code
 and fix it when things break?
 
 Also, is s-taprop-gnu.adb really necessary? Assuming GNU Hurd provides
 a posix pthread interface, then you should be using s-taprop-posix.adb,
 NOT s-taprop-gnu.adb

Hi, I tried with s-taprop-posix.adb earlier (among many tries), but
GNU/Hurd does not seem to be fully POSIX pthread compliant yet,
unfortunately. At least to my findings.