In OSX during C++ program compilation with g++ I use
LD_FLAGS= -Wl,-stack_size,0x100000000
Instead of stack_size, use --stack like so:
gcc -Wl,--stack,4194304 -o program program.c
This example should give you 4 MB of stack space. Works on MinGW's GCC, but as the manpage says, "This option is specific to the i386 PE targeted port of the linker" (i.e. only works for outputting Windows binaries). Seems like there isn't an option for ELF binaries.