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

2016-12-18 Thread Samuel Thibault
Samuel Thibault, on Mon 19 Dec 2016 00:25:35 +0100, wrote:
> as the attached patch does, which should really be applied or done
> any other way.

Or rather this patch, which makes it more like the test above.

Matthias, I'm committing this to Debian's gcc-6, along the other go
patches from Svante.

Samuel
Index: gcc/src/libgo/runtime/go-caller.c
===
--- gcc/src/libgo/runtime/go-caller.c   (révision 235086)
+++ gcc/src/libgo/runtime/go-caller.c   (copie de travail)
@@ -93,7 +93,7 @@
 argv[0] (http://gcc.gnu.org/PR61895).  It would be nice to
 have a better check for whether this file is the real
 executable.  */
-   if (stat (filename, ) < 0 || s.st_size < 1024)
+   if (filename != NULL && (stat (filename, ) < 0 || s.st_size < 1024))
filename = NULL;
 
   back_state = backtrace_create_state (filename, 1, error_callback, NULL);



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

2016-12-18 Thread Samuel Thibault
Hello,

Svante Signell, on Fri 25 Nov 2016 20:57:26 +0100, wrote:
> 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)

I've had a quick look by adding printfs in go-main.c and further to see
up to where it goes before crashing.  It crashes in

src/libgo/runtime/go-caller.c

in function __go_get_backtrace_state, inside the stat() call in:

if (__builtin_strchr (filename, '/') == NULL)
  filename = NULL;

if (stat (filename, ) < 0 || s.st_size < 1024)
  filename = NULL;

filename of course doesn't start with '/' (it's argv[0]), and thus NULL
is passed to stat(). It happens that by luck on Linux this just returns
an EFAULT error, but that's sheer luck :) This should probably be turned
into e.g.:

if (!filename || stat (filename, ) < 0 || s.st_size < 1024)
  filename = NULL;

as the attached patch does, which should really be applied or done
any other way.



Then calling go-6 brings this:

  fatal error: libbacktrace could not find executable to open

That's inside src/libbacktrace/fileline.c, the fileline_initialize
function, which tries the above filename (and thus fails), then
getexecname() (which is not implemented), then /proc/self/exe, which is
not implemented, then /proc/curproc/file which is even less implemented.

So here it'd be "just" a matter of implementing /proc/self/exe.

Samuel
Index: runtime/go-caller.c
===
--- runtime/go-caller.c (révision 235086)
+++ runtime/go-caller.c (copie de travail)
@@ -93,7 +93,7 @@
 argv[0] (http://gcc.gnu.org/PR61895).  It would be nice to
 have a better check for whether this file is the real
 executable.  */
-  if (stat (filename, ) < 0 || s.st_size < 1024)
+  if (!filename || stat (filename, ) < 0 || s.st_size < 1024)
filename = NULL;
 
   back_state = backtrace_create_state (filename, 1, error_callback, NULL);



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

2016-12-07 Thread Ian Lance Taylor
On Wed, Dec 7, 2016 at 2:02 PM, Svante Signell  wrote:
>
> 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

As you know, the name "linux" in those files means that the files are
only compiled on GNU/Linux systems.  The files in os and crypto are
copied from the master library in the gc repository.  Those names are
not going to change.  The file syscall/errstr_linux.go is specific to
gccgo, and that name could change easily enough.

> 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.

Making those changes is fine.

> 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.

Yes, I'm sorry that this never gets high enough on my list for a serious review.

The best way to contribute to gccgo is to use the process described at
https://golang.org/doc/gccgo_contribute.html.  That explains how to
send changes to Gerrit in a way that is easy for me to review and
apply (Gerrit is itself free software).  You are much more likely to
get a response if you are able to follow that approach.

Ian


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 Samuel Thibault
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.

Samuel


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 Samuel Thibault
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.

Samuel


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 Samuel Thibault
Svante Signell, on Sun 27 Nov 2016 18:17:17 +0100, wrote:
> On Sun, 2016-11-27 at 18:02 +0100, Samuel Thibault wrote:
> > > 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?

For instance.  See how it is done in the rest of the code.

> > > 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? 

I mean proposing explicitly to upstream, yes, so they don't have to
take the time to explain.

> > Then ask upstream how they think it can and should be done.
> 
> Upstream would be Ian Lance Taylor, right?

I don't know.

> > > > > -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?

Yes.

> > > > 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?

See spec_abbrevs in utils/ps.c, I guess it's a matter of adding
{"Comm=args"} in the list.

Samuel


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.



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

2016-11-27 Thread Samuel Thibault
Hello,

Svante Signell, on Sun 27 Nov 2016 17:33:52 +0100, wrote:
> > > 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"
> > 
> > That looks odd at best: WCONTINUED can't be defined at this place
> > anyway, so it'll get defined to 0. Fortunately the sys/wait.h
> > definition
> > would override this. But then wait.c will define something which does
> > not make sense since WCONTINUED is not implemented. Better use #ifdef
> > WCONTINUED inside the Continued function, to always return 0 when
> > it's
> > not defined.
> > 
> 
> I've been implementing that version too, with no visible differences.

"no visible differences" doesn't mean there is none :)

> 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.



> 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.



> > 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.



> > > @@ -4431,7 +4505,7 @@ mostlyclean-local:
> > >   find . -name '*-testsum' -print | xargs rm -f
> > >   find . -name '*-testlog' -print | xargs rm -f
> > >  
> > > -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.

> > Svante Signell, on Fri 25 Nov 2016 21:04:58 +0100, wrote:
> > > * 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:  
> > 
> > I can't find these in the patches you sent.
> 
> It is in the last mail: patch 19-23(23)

Ah, sorry, mutt had pasted the content of the attached files without
putting the file names.

> > > Index: gcc-6-6.2.1-4.1/src/libgo/testsuite/gotest
> > > ===
> > > --- gcc-6-6.2.1-4.1.orig/src/libgo/testsuite/gotest
> > > +++ gcc-6-6.2.1-4.1/src/libgo/testsuite/gotest
> > > @@ -618,7 +618,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" = "gnu"; 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
> > 
> > 
> > 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 :)

Samuel


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
 

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 Samuel Thibault
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}
 +

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

AIUI, the patch you propose does those changes for all systems, not just
GNU/Hurd.  That most probably will pose a problem.

Samuel


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: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Samuel Thibault
Svante Signell, le Tue 06 May 2014 14:13:54 +0200, a écrit :
   +# 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?

Well, either explicitly test for the system, or find a way to make it
actually do things only for the systems which need it. You could for
instance grep for #define EWOULDBLOCK EAGAIN.

  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?

I misread it indeed, I'm sorry about that.  So it adds SYS_FCNTL = 0 to
any system which does not have it already.  What is the consequence of
this?  Where is this used?  (I can't find any go reference to SYS_FCNTL
in the gcc source)

Samuel


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 Samuel Thibault
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...

Samuel


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.



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

2014-04-12 Thread Ian Lance Taylor
On Sat, Apr 12, 2014 at 7:04 AM, Svante Signell
svante.sign...@gmail.com wrote:

 (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.

To rebuild any of the GCC configuration generated files, you must
build and install the appropriate versions of autoconf, automake, and
libtool yourself, all using the same --prefix, and put the install bin
directory first on your PATH.  You can't use the system versions.

The current versions are automake 1.11, autoconf 2.64, libtool 2.2.7a.

Ian


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: Hurd port for gcc go PATCH 0-3 (9)

2014-04-11 Thread Ian Lance Taylor
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.

 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?

Ian


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

2014-04-11 Thread Samuel Thibault
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?

 @@ -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?

Samuel


Re: Hurd port for GCC Go

2013-06-26 Thread Thomas Schwinge
Hi!

On Fri, 14 Jun 2013 16:42:06 +0200, I wrote:
 I have now pushed my working branch to tschwinge/t/hurd/go, and will
 update this from time to time, both for integrating further changes (my
 own as well as those that you send me), and merge in GCC trunk changes.
 On that branch, use something like »git diff :/refs/top-bases/baseline«
 to diff your working tree against the branch's base.  When reviewing the
 commit history on that branch, it may be helpful to exclude any bulk
 merges from trunk, so use something like »git log HEAD ^origin/trunk«.
 
 Fotis and Svante, please base any futher work for the Hurd port for GCC
 Go on that branch.  Send patches by email, for now.
 
  I got as far as having GCC Go compiling with GCC trunk sources; more to
  come later.

I have just updated tschwinge/t/hurd/go with some further patches, and we
now got a usable baseline, hooray:

$ grep -v ^PASS:  gcc/testsuite/go/go.sum 
Test Run By thomas on Wed Jun 26 15:40:55 2013
Native configuration is i686-unknown-gnu0.3

=== go tests ===

Schedule of variations:
unix

Running target unix
Running [...]/gcc/testsuite/go.dg/dg.exp ...
Running [...]/gcc/testsuite/go.go-torture/execute/execute.exp ...
Running [...]/gcc/testsuite/go.test/go-test.exp ...
FAIL: go.test/test/chan/doubleselect.go execution,  -O2 -g 
FAIL: go.test/test/chan/nonblock.go execution,  -O2 -g 
UNTESTED: go.test/test/chan/select2.go
FAIL: go.test/test/chan/select3.go execution,  -O2 -g 
FAIL: go.test/test/chan/select5.go execution
UNTESTED: go.test/test/closure.go
FAIL: go.test/test/fixedbugs/bug147.go execution,  -O2 -g 
FAIL: go.test/test/fixedbugs/bug347.go execution,  -O0 -g 
FAIL: go.test/test/fixedbugs/bug348.go execution,  -O0 -g 
XFAIL: bug429.go  -O2 -g  execution test
FAIL: go.test/test/goprint.go execution
UNTESTED: go.test/test/goprint.go compare
UNTESTED: go.test/test/init1.go
FAIL: go.test/test/mallocfin.go execution,  -O2 -g 
FAIL: go.test/test/nil.go execution,  -O2 -g 
FAIL: go.test/test/recover3.go execution,  -O2 -g 
UNTESTED: go.test/test/rotate.go
UNTESTED: go.test/test/stack.go

=== go Summary ===

# of expected passes5069
# of unexpected failures11
# of expected failures  1
# of untested testcases 6
[...]/gcc/testsuite/go/../../gccgo  version 4.9.0 20130606 (experimental) 
(GCC) 

The patches are:

  * Disable -fsplit-stack (as just pushed to GCC trunk, too).

  * Hack in support in libgo for requesting heap memory with alignment
requirements.  Any stack used on Hurd must currently have a 2 MiB
size, and also be aligned accordingly.  This patch is probably not
suitable/wanted for upstream.

  * Use the patch before to use accordingly-sized stacks on Hurd.  This
patch is probably not suitable/wanted for upstream.  The Hurd
eventually will support arbitrarily-sized and aligned stacks.

  * Revert a hack by Svante, which is now no longer needed, as the
autodetection now works fine.

  * Disable the sigchld.go test, which busy-loops on GNU/Hurd, causing
the test harness to hang.

  * Disable in libgo on Hurd the setup of an alternate signal stack.
This patch is probably not suitable/wanted for upstream.  The Hurd
eventually will support sigaltstack.

  * Disable in libgo on Hurd the use of SA_ONSTACK.  This looks like a
bug in Hurd's glibc: signal handling breaks down (SIGILL) if no
alternate signal stack has been set and SA_ONSTACK is used.  The
standard says about SA_ONSTACK: »If set *and an alternate signal
stack has been declared with sigaltstack()*, the signal shall be
delivered to the calling process on that stack.  Otherwise, the
signal shall be delivered on the current stack.«

  * Re-enable the sigchld.go test, which now passes.

commit 397bf49a65468084df39b3208971e53e0b166c65
Author: Thomas Schwinge tho...@codesourcery.com
AuthorDate: Tue Jun 25 16:32:02 2013 +0200
Commit: Thomas Schwinge tho...@codesourcery.com
CommitDate: Tue Jun 25 18:13:47 2013 +0200

gcc/
* config/i386/gnu.h [TARGET_LIBC_PROVIDES_SSP]
(TARGET_CAN_SPLIT_STACK, TARGET_THREAD_SPLIT_STACK_OFFSET):
Undefine.
---
 gcc/config/i386/gnu.h |6 ++
 1 file changed, 6 insertions(+)

diff --git gcc/config/i386/gnu.h gcc/config/i386/gnu.h
index 35063e6..4a91c84 100644
--- gcc/config/i386/gnu.h
+++ gcc/config/i386/gnu.h
@@ -36,6 +36,12 @@ along with GCC.  If not, see http://www.gnu.org/licenses/.
 #endif
 
 #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
+
 #endif

commit 540a787bfe48ad434c1e44d425e287b7ac91af2f
Author: Thomas Schwinge tho...@codesourcery.com
AuthorDate: Tue Jun 25 17:59:28 2013

Re: Hurd port for GCC Go

2013-06-16 Thread Thomas Schwinge
Hi!

On Fri, 14 Jun 2013 22:37:03 +0200, Svante Signell svante.sign...@gmail.com 
wrote:
 On Fri, 2013-06-14 at 16:42 +0200, Thomas Schwinge wrote:
  On Thu, 13 Jun 2013 10:39:58 +0200, I wrote:
   On Wed, 12 Jun 2013 15:36:39 +0200, Svante Signell 
   svante.sign...@gmail.com wrote:
On Tue, 2013-06-11 at 10:31 +0200, Thomas Schwinge wrote:
 On Fri, 07 Jun 2013 11:14:31 +0200, Svante Signell 
 svante.sign...@gmail.com wrote:
  Attached are patches to enable gccgo to build properly on Debian
  GNU/Hurd on gcc-4.7 (4.7.3-4).
 
 Thanks!  I've begun integrating them into my GCC tree (based on 
 upstream
 GCC trunk, so some changes to be done to your patches), and get it in 
 a
 state for Fotis to base his GSoC work on.
 ...
  I have now pushed my working branch to tschwinge/t/hurd/go, and will
  update this from time to time, both for integrating further changes (my
  own as well as those that you send me), and merge in GCC trunk changes.
  On that branch, use something like »git diff :/refs/top-bases/baseline«
  to diff your working tree against the branch's base.  When reviewing the
  commit history on that branch, it may be helpful to exclude any bulk
  merges from trunk, so use something like »git log HEAD ^origin/trunk«.
  
  Fotis and Svante, please base any futher work for the Hurd port for GCC
  Go on that branch.  Send patches by email, for now.
  
   I got as far as having GCC Go compiling with GCC trunk sources; more to
   come later.
 
 Sorry, I'm not fluent in git. Which command to use to check out your
 branch tschwinge/t/hurd/go? Cannot find it at
 http://git.savannah.gnu.org/cgit/hurd/glibc.git/

That's no surprise, as I've talking about the GCC Git repository,
http://gcc.gnu.org/wiki/GitMirror.  Clone it, and then create a local
branch based on the one I pushed, so something like:

$ git clone git://gcc.gnu.org/git/gcc.git
$ cd gcc/
$ git checkout -b tschwinge/t/hurd/go origin/tschwinge/t/hurd/go


As I'm still occasionally seeing file corruption as described on
http://www.gnu.org/software/hurd/open_issues/git-core-2.html and
http://www.gnu.org/software/hurd/open_issues/git_duplicated_content.html,
I suggest you either pass the --quiet flag to any Git command you use, or
clone on a GNU/Linux box and then use rsync or something similar for
copying the repository and working directory to your GNU/Hurd system.


Grüße,
 Thomas


pgpeMhTIQeNMx.pgp
Description: PGP signature


Re: Hurd port for GCC Go

2013-06-14 Thread Thomas Schwinge
Hi!

On Thu, 13 Jun 2013 10:39:58 +0200, I wrote:
 On Wed, 12 Jun 2013 15:36:39 +0200, Svante Signell svante.sign...@gmail.com 
 wrote:
  On Tue, 2013-06-11 at 10:31 +0200, Thomas Schwinge wrote:
   On Fri, 07 Jun 2013 11:14:31 +0200, Svante Signell 
   svante.sign...@gmail.com wrote:
Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-4.7 (4.7.3-4).
   
   Thanks!  I've begun integrating them into my GCC tree (based on upstream
   GCC trunk, so some changes to be done to your patches), and get it in a
   state for Fotis to base his GSoC work on.
  
  Where to find your GCC tree?
 
 Only locally at the moment; will find a place to publish it.  As the .git
 directory weighs in the order of 1 GiB, I don't just want to push that
 onto darnassus (for example); even if we told people to first clone the
 upstream Git repository and only then add darnassus as an additional
 remote, I bet some would forget doing that.  Hmm, it seems that I might
 be able to host Git branches upstream, so I'll explore that:
 http://gcc.gnu.org/wiki/GitMirror#Git-only_branches.

I have now pushed my working branch to tschwinge/t/hurd/go, and will
update this from time to time, both for integrating further changes (my
own as well as those that you send me), and merge in GCC trunk changes.
On that branch, use something like »git diff :/refs/top-bases/baseline«
to diff your working tree against the branch's base.  When reviewing the
commit history on that branch, it may be helpful to exclude any bulk
merges from trunk, so use something like »git log HEAD ^origin/trunk«.

Fotis and Svante, please base any futher work for the Hurd port for GCC
Go on that branch.  Send patches by email, for now.

 I got as far as having GCC Go compiling with GCC trunk sources; more to
 come later.


  Also I had problems to tracing this commit:
  http://git.savannah.gnu.org/cgit/hurd/glibc.git/commit/?h=t/context_functionsid=018259d791f1ced4b2ced88c393cc74de15006ed.
  I did not find anything related to context_functions at
  http://git.savannah.gnu.org/cgit/hurd/glibc.git/
 
 Follow »[...]« in the Branches section to see all branches.  Anyway, it's
 a TopGit branch,
 http://www.gnu.org/software/hurd/source_repositories/glibc.html, so for
 getting a patch out of that, you'll need to diff the top of that branch
 against its base branch, using »tg patch t/context_functions« if you have
 TopGit installed, or something like »git diff
 top-bases/t/context_functions t/context_functions« manually.
 
  Furthermore, for testing purposes, is it straight-forward to add the new
  functions getcontext/setcontext/makecontext*/movecontext to the debian
  sources, e.g. 2.13-39+hurd.3 or 2.17-6 (when that is released?).
 
 It is, and Samuel is already building 2.17-3+hurd.4 packages, so you
 might just wait for these to appear on debian-ports.

These packages are available now.  Thanks Samuel!


Grüße,
 Thomas


pgp93l2K5nxkI.pgp
Description: PGP signature


Re: Hurd port for GCC Go

2013-06-14 Thread Svante Signell
On Fri, 2013-06-14 at 16:42 +0200, Thomas Schwinge wrote:
 Hi!
 
 On Thu, 13 Jun 2013 10:39:58 +0200, I wrote:
  On Wed, 12 Jun 2013 15:36:39 +0200, Svante Signell 
  svante.sign...@gmail.com wrote:
   On Tue, 2013-06-11 at 10:31 +0200, Thomas Schwinge wrote:
On Fri, 07 Jun 2013 11:14:31 +0200, Svante Signell 
svante.sign...@gmail.com wrote:
 Attached are patches to enable gccgo to build properly on Debian
 GNU/Hurd on gcc-4.7 (4.7.3-4).

Thanks!  I've begun integrating them into my GCC tree (based on upstream
GCC trunk, so some changes to be done to your patches), and get it in a
state for Fotis to base his GSoC work on.
...
 I have now pushed my working branch to tschwinge/t/hurd/go, and will
 update this from time to time, both for integrating further changes (my
 own as well as those that you send me), and merge in GCC trunk changes.
 On that branch, use something like »git diff :/refs/top-bases/baseline«
 to diff your working tree against the branch's base.  When reviewing the
 commit history on that branch, it may be helpful to exclude any bulk
 merges from trunk, so use something like »git log HEAD ^origin/trunk«.
 
 Fotis and Svante, please base any futher work for the Hurd port for GCC
 Go on that branch.  Send patches by email, for now.
 
  I got as far as having GCC Go compiling with GCC trunk sources; more to
  come later.

Sorry, I'm not fluent in git. Which command to use to check out your
branch tschwinge/t/hurd/go? Cannot find it at
http://git.savannah.gnu.org/cgit/hurd/glibc.git/



Re: Hurd port for GCC Go

2013-06-13 Thread Thomas Schwinge
Hi!

On Wed, 12 Jun 2013 15:36:39 +0200, Svante Signell svante.sign...@gmail.com 
wrote:
 On Tue, 2013-06-11 at 10:31 +0200, Thomas Schwinge wrote:
  On Fri, 07 Jun 2013 11:14:31 +0200, Svante Signell 
  svante.sign...@gmail.com wrote:
   Attached are patches to enable gccgo to build properly on Debian
   GNU/Hurd on gcc-4.7 (4.7.3-4).
  
  Thanks!  I've begun integrating them into my GCC tree (based on upstream
  GCC trunk, so some changes to be done to your patches), and get it in a
  state for Fotis to base his GSoC work on.
 
 Where to find your GCC tree?

Only locally at the moment; will find a place to publish it.  As the .git
directory weighs in the order of 1 GiB, I don't just want to push that
onto darnassus (for example); even if we told people to first clone the
upstream Git repository and only then add darnassus as an additional
remote, I bet some would forget doing that.  Hmm, it seems that I might
be able to host Git branches upstream, so I'll explore that:
http://gcc.gnu.org/wiki/GitMirror#Git-only_branches.

I got as far as having GCC Go compiling with GCC trunk sources; more to
come later.


 Also I had problems to tracing this commit:
 http://git.savannah.gnu.org/cgit/hurd/glibc.git/commit/?h=t/context_functionsid=018259d791f1ced4b2ced88c393cc74de15006ed.
 I did not find anything related to context_functions at
 http://git.savannah.gnu.org/cgit/hurd/glibc.git/

Follow »[...]« in the Branches section to see all branches.  Anyway, it's
a TopGit branch,
http://www.gnu.org/software/hurd/source_repositories/glibc.html, so for
getting a patch out of that, you'll need to diff the top of that branch
against its base branch, using »tg patch t/context_functions« if you have
TopGit installed, or something like »git diff
top-bases/t/context_functions t/context_functions« manually.

 Furthermore, for testing purposes, is it straight-forward to add the new
 functions getcontext/setcontext/makecontext*/movecontext to the debian
 sources, e.g. 2.13-39+hurd.3 or 2.17-6 (when that is released?).

It is, and Samuel is already building 2.17-3+hurd.4 packages, so you
might just wait for these to appear on debian-ports.  (The patch already
was in his last night's 2.17-3+hurd.3 build, but that one turned out to
be missing another important patch (DNS resolving), as he told in his
recent email.)

 Where
 should these be placed in the tree: hurd/, sysdeps/mach/hurd/,
 elsewhere?

As indidacted in the patch.

 And how to avoid the stubs at stdlib/ being compiled in?

As soon as there are more specific implementation files (that is, these
added by me), the stub ones will no longer be considered by glibc's build
system.


Grüße,
 Thomas


pgpoErpGhI2ot.pgp
Description: PGP signature


Re: Hurd port for GCC Go (was: [PATCH] gccgo patch 0-2 (9))

2013-06-12 Thread Svante Signell
Hi Thomas,

On Tue, 2013-06-11 at 10:31 +0200, Thomas Schwinge wrote:
 Hi!
 
 On Fri, 07 Jun 2013 11:14:31 +0200, Svante Signell svante.sign...@gmail.com 
 wrote:
  Attached are patches to enable gccgo to build properly on Debian
  GNU/Hurd on gcc-4.7 (4.7.3-4).
 
 Thanks!  I've begun integrating them into my GCC tree (based on upstream
 GCC trunk, so some changes to be done to your patches), and get it in a
 state for Fotis to base his GSoC work on.

Where to find your GCC tree? Also I had problems to tracing this commit:
http://git.savannah.gnu.org/cgit/hurd/glibc.git/commit/?h=t/context_functionsid=018259d791f1ced4b2ced88c393cc74de15006ed.
I did not find anything related to context_functions at
http://git.savannah.gnu.org/cgit/hurd/glibc.git/

Furthermore, for testing purposes, is it straight-forward to add the new
functions getcontext/setcontext/makecontext*/movecontext to the debian
sources, e.g. 2.13-39+hurd.3 or 2.17-6 (when that is released?). Where
should these be placed in the tree: hurd/, sysdeps/mach/hurd/,
elsewhere? And how to avoid the stubs at stdlib/ being compiled in?



Hurd port for GCC Go (was: [PATCH] gccgo patch 0-2 (9))

2013-06-11 Thread Thomas Schwinge
Hi!

On Fri, 07 Jun 2013 11:14:31 +0200, Svante Signell svante.sign...@gmail.com 
wrote:
 Attached are patches to enable gccgo to build properly on Debian
 GNU/Hurd on gcc-4.7 (4.7.3-4).

Thanks!  I've begun integrating them into my GCC tree (based on upstream
GCC trunk, so some changes to be done to your patches), and get it in a
state for Fotis to base his GSoC work on.


Grüße,
 Thomas


pgppcer9GgoKJ.pgp
Description: PGP signature