[cfe-dev] Stack space consumption query
Dallman, John
john.dallman at siemens.com
Fri Jan 13 06:00:31 PST 2012
I'm using Clang 2.1 from Xcode 4.1 on Mac OS X 10.7, porting software
which was previously built with GCC to Clang. I'm using an obsolete
version because the software is libraries, which my customers need
to code against, and they'll feel more secure if they have access to
a GCC that appears to correspond to the Clang I'm using.
Mostly, this has worked very well, with only a few problems. The
latest is interesting: I'm finding that 32-bit Clang code needs rather
more stack space than 32-bit GCC code did. This makes a difference to
the stack sizes I need to set up for POSIX threads. This isn't
a problem, and allocating 25% more stack space seems to handle it -
I haven't run all the testing yet.
I had been using 1MB stacks for 32-bit and 2MB for 64-bit, before I
found these needed to be increased. The scaling between 32-bit and
64-bit is, of course, variable according to the mixture of types in
local variables and the stack layouts the respective compilers chose.
The threads are definitely not confined to leaf functions, but execute
some pretty complex algorithms, so needing significant stack space is
expected. The default stack sizes on Mac OS X are too small for us,
but that is true on many other platforms.
I'm not finding that 64-bit code needs more stack space than GCC did,
but since I don't know very much about how spare space I had on the
thread stacks with GCC, this isn't very surprising.
So this is not a complaint, or a bug report, but I would be interested
to know if Clang is deliberately free with stack space, or is meant not
to be, or anything else that is unexpected or interesting about the
behaviour I'm seeing.
thanks in advance,
--
John Dallman
More information about the cfe-dev
mailing list