amperka / ino

Command line toolkit for working with Arduino hardware
http://inotool.org
MIT License
1.08k stars 232 forks source link

Compilation fails with avr-gcc > 4.8 #180

Open maharifu opened 10 years ago

maharifu commented 10 years ago

Hi, I installed ino on Arch Linux, with avr-gcc 4.9.0

I'm trying to compile a simple sketch:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(6, 7);

void setup() {
  mySerial.begin(9600);
}

void loop(){
}

But the compilation fails with:

.build/uno/src/sketch.o: In function `_GLOBAL__sub_I_mySerial':
/fail/src/sketch.ino:3: undefined reference to `__dso_handle'
/fail/src/sketch.ino:3: undefined reference to `__dso_handle'
/fail/src/sketch.ino:3: undefined reference to `__cxa_atexit'
/usr/bin/avr-ld: .build/uno/firmware.elf: hidden symbol `__dso_handle' isn't defined
/usr/bin/avr-ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
.build/uno/Makefile:201: recipe for target '.build/uno/firmware.elf' failed
make: *** [.build/uno/firmware.elf] Error 1
Make failed with code 2

From what I understand, this comes from gcc > 4.8 including -fuse-cxa-atexit by default. So, compiling with: ino build --cppflags="-fno-use-cxa-atexit -ffunction-sections -fdata-sections -g -Os -w" works fine.

I see the change in README, in v0.3.4 that perhaps was to prevent these kind of things, however, the AUR arduino package does not ship with avr gcc. Instead, the maintainer patched the boards.txt file to include a new option (https://github.com/WarheadsSE/PKGs/blob/master/arduino/arduino-gcc-4.8-no-use-cxa-atexit.patch).

I think the better option with ino would be to detect the avr-gcc version and add the -fno-use-cxa-atexit flag.

Would this be feasible?

NicoHood commented 4 years ago

This has been fixed on archlinux https://bugs.archlinux.org/task/50848