Setting Stack Size from gnatlink (GNAT User’s Guide for Native Platforms)

#### 7.4.8.28 Setting Stack Size from `gnatlink` ¶

You can specify the program stack size at link time. On most versions of Windows, starting with XP, this is mostly useful to set the size of the main stack (environment task). The other task stacks are set with pragma Storage_Size or with the ‘gnatbind -d’ command. The specified size will become the reserved memory size of the underlying thread.

Since very old versions of Windows (2000, NT4, etc.) don’t allow setting the reserve size of individual tasks, for those versions the link-time stack size applies to all tasks, and pragma Storage_Size has no effect. In particular, Stack Overflow checks are made against this link-time specified size.

You can set this with `gnatlink` using either of the following:

- `-Xlinker` linker switch

      $ gnatlink hello -Xlinker --stack=0x10000,0x1000

  This sets the stack reserve size to 0x10000 bytes and the stack commit size to 0x1000 bytes.

- `-Wl` linker switch

      $ gnatlink hello -Wl,--stack=0x1000000

  This sets the stack reserve size to 0x1000000 bytes. Note that with `-Wl` switch, you can’t also set the stack commit size because the comma is a separator for this switch.