Hi,
I am trying to run a fortran makefile with the command
make -f release.makefile OUT=foo
but I get the error
ld: -stack_size must be <= 512MB
I did run the same code on my old Macbook Pro 2017 with the intel fortran compiler and it ran without any issues. However, using gfortran on the 2021 MacBook Pro now yields this problem. Is there anything I can do to get rid of this error? The code is a replication file obtained from an economic journal. I am new to fortran and am happy about any help I can get.
Thank you!
1 Like
Hi Josie, welcome to Discourse!
You can check the stack size using the command ulimit -s
. The ld
error is originating from the linker (a program which takes objects and libraries/archives and combines them into an executable), which apparently has a hard limit on the maximum allowable stack size.
It might be that the Intel build was using the flag -heap-arrays [size]
, or the stack size was simply larger on your old MacBook. The GNU Fortran compiler has a similar flag -fmax-stack-var-size=n
where n
should be a size in bytes. It seems like your Makefile might also be explicitly passing a value for the -stack_size
. It would be easier to comment if we could see the Makefile (and potentially also code).
For an overview of what the stack and heap are, I have found this nice blog post: Memory in C – the stack, the heap, and static – The Craft of Coding
Silverfrost Fortran compiler for win X64 has introduced an 8 GByte “Vstack”, which appears to overcome the 512 MB stack size limit.
I have not been able to find any reference to this much larger stack option.
Basically, given the virtual memory address space available in Win X64, the stack pool could be a terrabyte, as physical memory is only allocated to what is used. This can be seen in Gfortran and Ifort load maps with the memory addresses allocated to heap.
Is this VStack a known feature of Win X64 architecture ?
Is 512 MB a stack size limit for only Gfortran or all Win X64 OS ?