dritcey / optiboot

Automatically exported from code.google.com/p/optiboot
0 stars 0 forks source link

Doesn't compile with gcc4.7 or gcc4.8 #101

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Optiboot doesn't compile at all when using gcc 4.7 or 4.8.
This seems mostly because of changes to optimization switches.

4.8:
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types 
-mshort-calls -mmcu=atmega328p -DF_CPU=16000000L  -DBAUD_RATE=115200 
-DLED_START_FLASHES=3      '-DVIRTUAL_BOOT'   -c -o optiboot.o optiboot.c
avr-gcc: error: unrecognized command line option '-mshort-calls'
make: *** [optiboot.o] Error 1

Original issue reported on code.google.com by wes...@gmail.com on 8 May 2014 at 6:27

GoogleCodeExporter commented 8 years ago
Makefile line 106:
#  -mshort-calls is obsolete use -mrelax (see 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54854)
OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mrelax

Original comment by ronald.s...@gmail.com on 9 May 2014 at 5:11

GoogleCodeExporter commented 8 years ago
-mrelax doesn't quite produce the same code as -mshort-calls.
Also, without additional optimization switches, A 4.8-compiled version doesn't 
fit:

BillW-MacOSX-2<10006> make atmega328
avr-gcc (GCC) 4.3.3
avr-size optiboot_atmega328.elf
   text    data     bss     dec     hex filename
    500       0       0     500     1f4 optiboot_atmega328.elf

BillW-MacOSX-2<10009> make clean;make atmega328
avr-gcc (GCC) 4.6.2
   text    data     bss     dec     hex filename
    504       0       0     504     1f8 optiboot_atmega328.elf

make clean;make atmega328
avr-gcc (GCC) 4.8.1
avr-size optiboot_atmega328.elf
   text    data     bss     dec     hex filename
    518       0       0     518     206 optiboot_atmega328

So a patch that produces a working optiboot in 4.3 and 4.8 is going to be 
somewhat more complicated.

Original comment by wes...@gmail.com on 13 May 2014 at 10:34

GoogleCodeExporter commented 8 years ago
I have run into this problem as well using avr-gcc 4.8.1 on linux.

Using old WinAvr, I was getting normal size (my own target, slightly modified 
source):
   text    data     bss     dec     hex filename
      0     504       0     504     1f8 optiboot_atmega328_4MHz.hex

Using original makefile with avr-gcc 4.8.1 on linux I got image too big:
   text    data     bss     dec     hex filename
    522       0       0     522     20a optiboot_atmega328_4MHz.elf

After changing compilation flags, I achieved working image again:

   text    data     bss     dec     hex filename
    500       0       0     500     1f4 optiboot_atmega328_4MHz.elf

The flags I am using are:
OPTIMIZE   = -Os -ffunction-sections -fno-move-loop-invariants
override LDFLAGS = $(LDSECTIONS) -Wl,--relax -nostartfiles -nostdlib 
-Wl,--gc-sections

Everything else is left intact.

Hope this helps...

Original comment by Tomas.Ko...@gmail.com on 17 Jun 2014 at 2:46

GoogleCodeExporter commented 8 years ago

Original comment by wes...@gmail.com on 28 Jun 2014 at 1:29

GoogleCodeExporter commented 8 years ago
Issue 95 has been merged into this issue.

Original comment by wes...@gmail.com on 28 Jun 2014 at 2:30

GoogleCodeExporter commented 8 years ago
https://code.google.com/p/optiboot/source/detail?r=a10ef5c935a11a0e656927cd5e9b3
06937203f52
(Version 6.0)
Adjust optimization switches: use -mrelax instead of -mshort-calls.
Make various functions explicitly "noinline", because 4.8 was inlining them in 
spite of -Os and "-fno-inline-small-functions."  (sigh.)

Original comment by wes...@gmail.com on 28 Jun 2014 at 9:07

GoogleCodeExporter commented 8 years ago
I can confirm that the latest version produces small enough binary even with 
new avr-gcc:

   text    data     bss     dec     hex filename
    492       2       0     494     1ee optiboot_atmega328.elf

However, adding -fno-move-loop-invariants option to the OPTIMIZE variable 
reduces the size even more, so I still suggest to consider adding it:

   text    data     bss     dec     hex filename
    484       2       0     486     1e6 optiboot_atmega328.elf

Original comment by Tomas.Ko...@gmail.com on 3 Jul 2014 at 12:35

GoogleCodeExporter commented 8 years ago
Confirm on AtmelStudio 6.2, latest toolchain:
avr-gcc -g -Wall -Os -ffunction-sections -fno-move-loop-invariants 
-mmcu=atmega328p -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3    
  -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe 
-Wl,--relax -nostartfiles -nostdlib -Wl,--gc-sections -o optiboot_atmega328.elf 
optiboot.o 
        avr-size optiboot_atmega328.elf
           text    data     bss     dec     hex filename
            482       0       0     482     1e2 optiboot_atmega328.elf

Original comment by speednpo...@gmail.com on 23 Aug 2014 at 9:38