Issue |
127651
|
Summary |
[AVR] clang LTO causes Arduino blink example to break
|
Labels |
clang
|
Assignees |
|
Reporter |
dakkshesh07
|
When compiling the Blink example from the Arduino IDE for AVR using Clang with LTO enabled, the program fails to function correctly. The LED blinks once and then remains stuck in the ON position indefinitely. Disabling LTO for `wiring.c` from Arduino AVR core resolves the issue.
### Blink example code:
```cpp
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
```
### Compiler flags used (other than -flto -fno-fat-lto-objects):
```bash
--target=avr -c -g -Os -Wall -Wextra --sysroot=/home/dakkshesh/.arduino15/packages/ClangBuiltArduino/tools/cba-avr-sysroot/12022025 -std=gnu11 -ffunction-sections -fdata-sections -MMD -mmcu=atmega2560 -DF_CPU=16000000L
```
### Expected Behavior
The LED should continue blinking at a 1-second interval indefinitely.
### Attachments
LLVM IR files for wiring.c with LTO turned on and off.
[wiring.c-lto.ll.txt](https://github.com/user-attachments/files/18847521/wiring.c-lto.ll.txt)
[wiring.c-nonlto.ll.txt](https://github.com/user-attachments/files/18847522/wiring.c-nonlto.ll.txt)
`wiring.c`: https://github.com/ClangBuiltArduino/core_arduino_avr/blob/8b327d7bede1c1245db99daeba4e168c92c11194/cores/arduino/wiring.c
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs