[Teensy 4.1/PlatformIO] TEENSY_OPT_FASTEST_LTO build flags breaks USB serial function

tgtakaoka

New member
Using minimum platform project with -D TEENSY_OPT_FASTEST_LTO build flags breaks USB serial functionality.

[src/blink.ino]
Code:
static constexpr auto LED = 13;
void setup() {
  pinMode(LED, OUTPUT);
}
void loop() {
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
}

[platformio.ini]
Code:
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
build_flags = -D TEENSY_OPT_FASTEST_LTO

Note that
  • TEENSY_OPT_FASTEST (without _LTO) works fine and USB serial exists.
  • Adding -D USB_SERIAL has no effect
  • Teensy 3.5 works fine with TEENSY_OPT_FASTEST_LTO and do not lose USB serial.

I'm consulting this page but no luck so far.
https://docs.platformio.org/en/latest/platforms/teensy.html
 
Indeed, Using LTO with the 1062 seems to have issues.

Was observed in Beta that what worked on 3.x's was not making usable builds for the 4.x's.

Resolution to date has been to avoid doing LTO builds.
 
Where is that documented?

As noted, Beta - and since like above post #2 ... it hasn't shown up much for being tried so not made much of an issue with all else ongoing ...

Not sure PJRC every officially addressed it - indeed LTO build option still present, but as p#1 reports it generally if not always fails AFAIK
 
Normally, nothing is wrong with LTO. It works good.
But LTO will produces crashes earlier if there are existing issues or bugs in the software - it just makes makes them more visible. Its not a fault of LTO.
 
Back
Top