Compiling poblems at simple DigitalReadSerial example

Hi, I have just started to work with Arduino. I have an UNO and have tested the first Built-In examples Basics like BLINK which ran without any problems (also with externally connected LED etc.).
However, trying DigitalReadSerial example it doesn’t compile. My PC has Windows 10.

First the code:


Reads a digital input on pin 2, prints the result to the Serial Monitor

This example code is in the public domain.


// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
// make the pushbutton’s pin an input:
pinMode(pushButton, INPUT);

// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
delay(1); // delay in between reads for stability

I get this error message:

Arduino: 1.8.9 (Windows Store (Windows 10), Board: “Arduino/Genuino Uno”

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial0.cpp: In function ‘_GLOBAL__sub_I___vector_18’:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial0.cpp:77:1: internal compiler error: Segmentation fault



Please submit a full bug report,

with preprocessed source if appropriate.

See for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/…/lib/gcc/avr/5.4.0/…/…/…/…/avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

What does it mean? It would be helpful if someone can answer my issue.


This bug is specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 and newer. It has been reported here:

The workaround is to roll back to the newest version of Arduino AVR Boards that still used the previous compiler version:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".

If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.

Thank you very much for a very quick answer!
I followed your instructions and it worked perfect:)

(although alot of red "avrdude" text in the 'compilation window')

Now I know where to post my coming issues :wink:
(I hope it will not be that many)

Best regards
Björn E (bjornee)

I’m glad to hear it’s working now!

It’s normal for the avrdude output to be in red. The Arduino IDE displays all output that’s printed to stdout in white and all output that’s printed to stderr in red. avrdude prints all its output to stderr for some reason, so it ends up being colored red. Ideally, red would only be used for warnings or error messages, but there isn’t an elegant way to accomplish that, since output may come from any number of arbitrary tools depending on which board you have selected (which includes an ever-increasing number of 3rd party boards).

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.