Hi,
I’m trying to use LTO in my project, even a blank project, with a main.cpp with setup and loop functions, when I add the flag -flto to build_flags I receive this error:
Linking .pio/build/core2foraws/firmware.elf
/Users/user/.platformio/packages/framework-arduinoespressif32@3.10006.210326/tools/sdk/lib/libesp32.a(cpu_start.o):(.literal.main_task+0x14): undefined reference to `app_main'
/Users/user/.platformio/packages/framework-arduinoespressif32@3.10006.210326/tools/sdk/lib/libesp32.a(cpu_start.o): In function `main_task':
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/cpu_start.c:545: undefined reference to `app_main'
My platformio.ini
[env:core2foraws]
platform = espressif32@3.2.0
framework = arduino
board = m5stack-core2
monitor_speed = 115200
upload_speed = 2000000
board_build.f_flash = 80000000L
board_build.flash_mode = dio
build_unflags = -mfix-esp32-psram-cache-issue
build_flags =
-O2
-flto
-pipe
-Wall
My main.cpp
void setup()
{
}
void loop()
{
}
What I’m missing or doing wrong?