This would seem to be a problem with VisualMicro emulation of IDE build. Under the IDE 1.8.1 I get the following results with no problem compiled on a T_3.6 at 180 MHz.
With NO USB the PJRC yield() brings in 10KB of code - but taking yield() out compiles and runs fine from the IDE and much smaller, qBlink and USB with void yield() is only 4KB::
//
compiled FASTER with LTO
// with PJRC yield():: Sketch uses
11472 bytes
// void yield():: Sketch uses
2440 bytes
// void yield() with qBlink & delayMicroseconds:: Sketch uses
3304 bytes
//
compiled Smallest with LTO
// with PJRC yield() qBlink & delayMicroseconds:: Sketch uses
12928 bytes
// void yield():: Sketch uses 1132 bytes
// void yield() qBlink & delayMicroseconds:: Sketch uses
1804 bytes
//
compiled Smallest with LTO :: USB Serial
// with PJRC yield() qBlink & delayMicroseconds:: Sketch uses
16040 bytes
// void yield() qBlink & delayMicroseconds:: Sketch uses
4412 bytes
Code:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
#define qBlink() (digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN) ))
void loop() {
qBlink();
delayMicroseconds(100000);
}
void yield() {}
BTW - I think this is an issue FrankB noted - in creating this test with LTO I did run into this from the IDE (with or without USB Serial):
I:\arduino-1.8.1\hardware\teensy\avr\cores\teensy3/mk66fx1m0.ld:45 cannot move location counter backwards (from 00000408 to 00000400)
collect2.exe: error: ld returned 1 exit status
Error compiling for board Teensy 3.6.
Code:
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // removing this extraneous line (or haing qBlink in loop) removes the above ERROR
}
void loop() {
}
void yield() {}