Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#56613 closed defect (invalid)

avr-gcc fails to compile elf file

Reported by: chrisjogorman Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.5.2
Keywords: Cc: g5pw@…
Port: avr-gcc

Description

this code use to build with avr-gcc @4.9.1_0+lto and now fails to compile.

Chris-Gormans-Mac-mini:firmware chrisgorman$ make
avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=atmega162 -c clock.c -o clock.o
clock.c:11:0: warning: "F_CPU" redefined
 #define F_CPU = 8000000UL
 
<command-line>:0:0: note: this is the location of the previous definition
avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=atmega162 -o clock.elf clock.o
/opt/local/lib/gcc/avr/7.2.0/../../../../avr/bin/ld: cannot find crtatmega162.o: No such file or directory
/opt/local/lib/gcc/avr/7.2.0/../../../../avr/bin/ld: cannot find -latmega162
collect2: error: ld returned 1 exit status
make: *** [clock.elf] Error 1

Not sure where crtatmega162.o should be. Perhaps this is a bug with using old build steps?

Change History (5)

comment:1 Changed 6 years ago by chrisjogorman

This can be closed as a bug with the old build steps.

avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=avr5 -D__AVR_ATmega162__ -D__AVR_DEVICE_NAME__=atmega162 -c main.c -o main.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=avr5 -D__AVR_ATmega162__ -D__AVR_DEVICE_NAME__=atmega162 -o main.elf main.o
avrdude -c usbtiny -P usb -p m162 -U flash:w:main.hex:i

Builds and flashes a working binary.

comment:2 Changed 6 years ago by raimue (Rainer Müller)

Do you also have the avr-libc port installed?

$ port provides /opt/local/avr/lib/avr5/crtatmega162.o
/opt/local/avr/lib/avr5/crtatmega162.o is provided by: avr-libc

comment:3 Changed 6 years ago by chrisjogorman

Yes avr-libc is installed. I panicked when I couldn't compile some old source with the new avr-gcc and blamed the compiler not the old code. I should have run find /opt/local -name crtatmega162.o or port provides as you have done. The problem was with my Makefile and the old build steps. Reading /opt/local/lib/gcc/avr/7.2.0/device-specs/specs-atmega162 gave me enough tips to get the code built. Now to change over a few Makefiles...

comment:4 Changed 6 years ago by g5pw (Aljaž Srebrnič)

Resolution: invalid
Status: newclosed

Everything is working as expected, from what I understand. Thanks for keeping an eye out!

comment:5 Changed 6 years ago by mf2k (Frank Schima)

Keywords: avr-gcc snowleopard removed
Note: See TracTickets for help on using tickets.