"Optimize for Debugging" results in link errors

Environment:

Macbook Air; Apple M2; Sequoia 15.5
Version: 2.3.6
Date: 2025-04-09T11:22:51.016Z
CLI Version: 1.2.0

I am compiling OnStepX (GitHub - hjd1964/OnStepX) and uploading to an ESP32S3 Devkit.
You need to make only one change for the ESP32S3 hardware in the config.h file: Line25:#define SERIAL_B_BAUD_DEFAULT OFF
It runs successfully on the hardware.

To prepare for JTAG debugging, I select the "Optimize for Debugging" in the Sketch dropdown.
This results in the following errors in linking:

/Users/jarchbold/Library/Arduino15/packages/esp32/tools/esp-x32/2411/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/jarchbold/Library/Caches/arduino/sketches/73C5D897EE8597E32A48D0086FB30EE2/sketch/src/lib/nv/NvBase.cpp.o:(.rodata._ZTV18NonVolatileStorage[_ZTV18NonVolatileStorage]+0x18): undefined reference to `_ZN18NonVolatileStorage15readFromStorageEt'
/Users/jarchbold/Library/Arduino15/packages/esp32/tools/esp-x32/2411/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /Users/jarchbold/Library/Caches/arduino/sketches/73C5D897EE8597E32A48D0086FB30EE2/sketch/src/lib/nv/NvBase.cpp.o:(.rodata._ZTV18NonVolatileStorage[_ZTV18NonVolatileStorage]+0x1c): undefined reference to `_ZN18NonVolatileStorage14writeToStorageEth'
collect2: error: ld returned 1 exit status

If I turn off the "Optimize for Linking" option, it compiles and downloads.

To enable the NonVolatileStorage class on ESP32, it seems necessary to define NV_DRIVER to NV_ESP32 instead of NV_DEFAULT.

Thanks for that hint.

It worked.

I did this sometime ago as per your suggestion, but for some reason (old age maybe) my solution click and reply did not work.

Glad to hear that.
Thank you for coming back!