GCC compiler segmentation fault (?!)

I didn't know I could do it. Achievement get?

Code is latest dev branch of GitHub - MarginallyClever/Makelangelo-firmware: CNC firmware for many different control boards and kinematic systems. Originally the brain of the Makelangelo art robot.
Arduino 1.8.7 64bit with all updates installed.
Windows 10.
Compiling for MEGA2560.

full error message(s):

C:\Users\Admin\Documents\GitHub\Makelangelo-firmware\motor.ino: In function 'setPenAngle':

C:\Users\Admin\Documents\GitHub\Makelangelo-firmware\motor.ino:278:1: internal compiler error: Segmentation fault

 }

 ^

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.

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

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.15.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

Multiple libraries were found for "SD.h"
 Used: C:\Users\Admin\Documents\Arduino\libraries\SD
 Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\libraries\SD
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

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:

Here's the workaround:

  • 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".

Due to a bug, this workaround doesn't work with Arduino IDE 1.8.6, but it will work with any other version of the Arduino IDE.

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.

You were helpful, thorough, fast, and correct! Thank you - Kudos!

You're welcome. I'm glad if I was able to be of assistance.
Regards, Per

I've been suffering from an error much like this one. For me it was triggered by a comment in my code. Adding the comment it caused the error, removing it fixed it. Bizarre. The downgrade to 6.1.21 worked for me, but since this was posted last October, I'm wondering if this issue is any closer to being fixed permanently?

Every day surely gets us closer to the day when the next release of Arduino AVR Boards comes out. When that day will be, I can't say. I've been beta testing the new toolchain for probably the last 9 months without encountering a single problem so I'm in favor of it.

I had this same problem on 2/4/2020 and this fix worked. I believe I was using version 23 instead of 21.

The instructions I provided above are now outdated. Instead of rolling back to Arduino AVR Boards 1.6.21 for a good compiler version, we can now update Arduino AVR Boards to the latest version instead. It's much better to use a modern version of the compiler than a super old one. Here are the updated instructions:

  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • From the list of available packages, click on “Arduino AVR Boards”.
  • Click "Update".
  • Wait for the update to finish.
  • Click "Close".