Notes on building avr-gcc 4.2.3.

Again, mostly so I find them when I encounter the same problem later and Google for it.

When I tried to build avr-gcc 4.2.3 (against binutils 2.18), I got the following error:

../.././gcc/config/avr/libgcc.S: Assembler messages: ../.././gcc/config/avr/libgcc.S:280: Error: illegal opcode movw for mcu avr3 ../.././gcc/config/avr/libgcc.S:282: Error: illegal opcode movw for mcu avr3

It looks like there's an incompatibility between the microcontroller definitions in avr-gcc and the assembler (gas) which is part of binutils. In particular, for the "avr35" chips, gcc thinks they have the movw instruction, but gas doesn't - so instructions get included in the assembler source that can't be compiled. This is in the gcc bug database.

To fix it, I changed line 146 in gcc/config/avr/avr.c from: { 0, 0, 1, 1, "AVR_ARCH=35"}, to: { 0, 0, 1, 0, "AVR_ARCH=35"},

For completeness, the commands I then used to compile were: ./configure --target=avr --disable-libssp --enable-languages=c,c++ --prefix=/usr/local/avr make sudo make install

For binutils (which you do first), it was: ./configure --target=avr --disable-nls --enable-languages=c,c++ CFLAGS="-arch i386 -arch ppc" LDFLAGS="-arch i386 -arch ppc" --prefix=/usr/local/avr make sudo make install

And for avr-libc (last): ./configure --prefix=/usr/local/avr --build=./config.guess --host=avr make sudo make install