This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: using split stacks
- From: Ian Lance Taylor <iant at google dot com>
- To: "Oliver Kowalke" <oliver dot kowalke at gmx dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 28 Mar 2012 16:52:21 -0700
- Subject: Re: using split stacks
- References: <20120328064115.244820@gmx.net>
"Oliver Kowalke" <oliver.kowalke@gmx.de> writes:
> I'd like to use split stacks for my coroutine implementation.
> I found a website from Ian describing how split stack could be
> implemented in gcc but not how to use it in an application.
To use it in an application, compile and link with the -fsplit-stack
option.
> I assume I have to apply the command line option -fsplit-stack and gcc
> must be compiled with --enable-gold (as described in Ians blog).
For best effect you should in general use the gold linker, but simply
configuring GCC with --enable-gold is not enough to cause that to
happen. You should either install gold as your default linker, or you
should configure GCC using --with-ld=/PATH/TO/GOLD.
> Are some macros defined I can use in the code in order to detect that
> split stacks are available?
Not at present. If you look in libgo/configure.ac you will see a couple
of simple autoconf tests.
> I assume I've to call a special function similiar to malloc()/calloc()
> in order to get a new split stack?!
I'm not sure exactly what you are asking. When your program needs a new
split stack, it will get one automatically, via the libgcc routine
__generic_morestack. You don't have to do anything to make that work.
If you are asking how to get a new split stack for a new coroutine, the
answer is to call __splitstack_makecontext. See that function and other
helpful functions in libgcc/generic-morestack.c.
Ian