[build] Support libgo on Solaris 2

Ian Lance Taylor iant@google.com
Wed Jan 12 08:41:00 GMT 2011


> From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
> Date: Mon, 10 Jan 2011 16:23:05 +0100

> 	* runtime/go-go.c (__go_go) [!LINKER_SUPPORTS_SPLIT_STACK &&
> 	__sun__ && __svr4__]: Reduce default thread stack size.

> diff -r 72fce0443d71 libgo/runtime/go-go.c
> --- a/libgo/runtime/go-go.c	Sat Jan 08 12:30:04 2011 +0100
> +++ b/libgo/runtime/go-go.c	Sun Jan 09 12:31:06 2011 +0100
> @@ -196,7 +196,21 @@
>  #endif
>    i = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
>    __go_assert (i == 0);
> +
> +#else /* !LINKER_SUPPORTS_SPLIT_STACK */
> +
> +#if defined __sun__ && defined __svr4__
> +  /* Reduce the thread stack size from the Solaris 2 default of 1 MB
> +     (32-bit) or 2 MB (64-bit) to allow go.test/test/chan/goroutines.go to
> +     work.  The value is just a guess.  */
> +#ifndef PTHREAD_STACK_MIN
> +#define PTHREAD_STACK_MIN (128*1024)
>  #endif
> +  i = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
> +  __go_assert (i == 0);
> +#endif /* __sun__ && __svr4__ */
> +
> +#endif /* !LINKER_SUPPORTS_SPLIT_STACK */

I don't think this is the way to go.  What this does is reduce the
default stack size of a thread in order to permit more threads to run.
But the effect will be that more threads will overrun their stacks and
crash.  I think it's more likely that a thread will need a lot of stack
than it is that a Go program will need a lot of goroutines.  The
goroutines.go test creates 10000 goroutines.  It should work, of course,
but I don't think we should make it work by sacrificing the size of the
stack for ordinary goroutines.  We should instead let goroutines.go fail
until split stack is implemented.

Ian



More information about the Gcc-patches mailing list