Open Foaly opened 2 years ago
As a quick test, I tried -ffast-math on Arduino 1.8.19 with Teensduino 1.56. I edited boards.txt, changing this line:
teensy41.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
to this:
teensy41.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -ffast-math
Then I restarted the Arduino IDE, because it doesn't re-read boards.txt automatically when it changes.
Quick upload and opening the Arduino Serial Monitor seems like it's working fine.
This is the code I tested:
I can't say why it's not working for you. But hopefully this test with these screenshots is detailed and specific enough for you or anyone to reproduce and see for yourself -ffast-math working.
Quick note - you'll see the screenshot shows I used CPU speed 528 MHz. I also tested at 600 MHz. Then I changed the CPU speed and tested again, just to force the Arduino IDE to recompile all files. All other settings were at their default values.
Hey Paul! First of all thank you very much for taking the time and trying it out for yourself! 🙂
I think you might have misunderstood the problem I was describing, sorry it I was a bit unclear. As I write above I was also able to compile and upload code that uses the -ffast-math
flag. I was even able to measure the expected performance increase. The problem I am having is if I use pio test
instead of platformio run --target upload
using the exact same code my Teensy hangs in a non-responsive state. I am suspecting that this is a platformio issue more than an issue with the Teensy.
Hey there!
I am observing some weird behaviour that looks like a bug to me. I have a
main.cpp
and atest.cpp
file, which both compile and execute fine on my Teensy 4.1. They both produce the expected output. As soon as I add the linebuild_flags = -ffast-math
to myplatformio.ini
my test breaks, while my main file still executes as expected (I can even measure the expected performance increase). Now the way the test breaks is what strikes me as odd. It compiles and uploads just fine. But then the Teensy seems to be just dead. It does not connect to the serial monitor or produce any other sort of output. I can still press the button and set it into bootloader mode and flash a new firmware, but other than that there is no response.I know
-ffast-math
is considered an unsafe option, but what makes me wonder is that the behaviour between compile+upload and compile+upload+test is so different. It feel a lot like a weird bug.Does anybody have an idea what could be causing this?
I did some more testing and here are my findings. For my setup I am running a minimal example like this:
test/test.cpp
platformio.ini
build_flags = -ffast-math
to the bottom of theplatformio.ini
the described breakage occures when running the test usingpio test -v
. Since according to the GCC Optimize Options-ffast-math
is a combination of flags I tested the individual flags and this is the result:Thanks a lot to maxgerhardt who helped me on the platformio community forum. For more info see this thread: https://community.platformio.org/t/test-fails-to-start-with-build-option-ffast-math/25342