Build flag for execution speed problem


I am trying to reduce my code execution time speed with the -Ofast build flag for some test and im always having an error. I could use the help from this forum. Heres my .ini :

platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
lib_deps =
board_build.partitions = default_16MB.csv
build_flags = -Ofast

Error :
Assembler messages:
Fatal error: can’t create .pio\build\esp-wrover-kit\src\wifi_setup.cpp.o: No such file or directory
*** [.pio\build\esp-wrover-kit\src\wifi_setup.cpp.o] Error 1

Thank you

Are you saying this error only occurs if you add build_flags = -Ofast? And if you remove it, it builds successfully?

Yes, i removed the build flag line, and build with the error, i rebuild and no error
Its seems the error correct itself after a few building try