Unfortunately, I don't have much knowledge about the ESP32, and nothing at this depth. I didn't even recognize it's main.cpp, though I could see that it wasn't from any of the cores I'm more familiar with.
I do have a trick I use when I want to track down the location of a macro definition. I set it to a value I know is different from the original in order to trigger a warning, which shows the location of the previous definition:
C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\main.cpp:6:0: warning: "CONFIG_ARDUINO_LOOP_STACK_SIZE" redefined
#define CONFIG_ARDUINO_LOOP_STACK_SIZE asdf
In file included from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/spi_flash/esp_spi_flash.h:22:0,
C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/config/sdkconfig.h:175:0: note: this is the location of the previous definition
#define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192
Yes, that is the location I needed, thanks! And changing the stack size there works.
It certainly makes sense to have all config settings in one place, but now I have to remember always to change this file when an update comes through. I hope there will come an option to make such changes specific to a certain sketch.