Skip to content

[AVR] clang: Arduino program breaks when Serial functions are used #128536

@beakthoven

Description

@beakthoven

LLVM Version: 20.1.0-rc2

Description:
I'm trying to compile Arduino AVR programs using Clang, but I’ve encountered an issue with the Blink example sketch. When Serial functions are used, the LED remains stuck in the ON position, even with LTO disabled globally. Removing the serial-related code allows the LED to blink normally.

Test Code:

Failing Example (LED stuck ON):

#include <Arduino.h>

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     
  Serial.begin(9600);               
  Serial.println();                
  Serial.println("Hello world. I was built with clang!");
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);                  
  digitalWrite(LED_BUILTIN, LOW);   
  delay(1000);                  
}

Working Example (without Serial functions):

#include <Arduino.h>

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);                  
  digitalWrite(LED_BUILTIN, LOW);   
  delay(1000);                  
}

Additional Info:

Please let me know if any additional information would be helpful for diagnosing this issue — I can provide assembly files, compiler flags, or any other relevant details as needed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions