Global constructor bug in GCC 4.5.1

I’ve recently returned to programming my Seeeduino Mega (ATmega1280) for my tricopter. Yesterday I discovered that every time I included serial code in the sketch, the sketch seemed to freeze as if it was not running the loop(). After several hours, I identified the source of the bug to be in the gcc-avr compiler that Linux uses. Note that this bug does not affect the ATmega328p of the Duemilanove.

I am compiling and uploading sketches from the command line (another small adventure I will post about later) with Arduino 0018 on 64-bit Arch Linux.

This blog post explains the bug pretty well. Until an official patch comes out, there are two workarounds: downgrade to GCC 4.3.3 or make the proposed patch. I tried installing the 4.3.3 version from archived sources but ran into other bugs that did not let me compile.

This GCC Bugzilla report describes the patch with proper line numbers. After building the patched source and installing the package, I was able to compile and upload fully-functioning ATmega1280 sketches.

Here is the compiled package for 64-bit Arch Linux.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: