A follow up question, If the smallest stack size between linux, windows and macos, is 512KB on macos, does that mean if I make the binary use less than 512KB of stack, it’s good to go on all three platforms?
It depends on the operating system loader.
For windows the stack size is in the .exe and the microsoft linker default value is 1MB.
For various unix systems you can get (and set) the value with ulimit -s (or the getrlimit/setrlimit C call and the RLIMIT_STACK option).
My macos system gives me 8176 and my linux system 16384.
This is for the initial stack size of the main thread, the program is free to create other threads with different stack sizes, or move main thread stack elsewhere.
For your follow up question: you can use ulimit -s to increase the available stack size for your process.
My guess is that virtual memory makes it easy to allocate more pages for the stack ? Plus the fact that we have access to a lot of RAM these days even on laptops.