Skip to content

Commit

Permalink
Move AVR compile options to chips defs files
Browse files Browse the repository at this point in the history
Make these options common across all ports instead of copy/pasting
them into each port Makefile. Also use the distro version of avr-gcc
for nano-every as it has been updated.

Signed-off-by: Keith Packard <[email protected]>
  • Loading branch information
keith-packard committed Nov 13, 2024
1 parent 274c6b8 commit 79cd805
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
14 changes: 14 additions & 0 deletions chips/atmega/snek-atmega.defs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ SNEK_ATMEGA_BUILTINS = \
snek-atmega.builtin

SNEK_NO_FILE = 1

OPT=-Os \
-mrelax \
-flto \
-Wno-array-bounds \
-frename-registers \
-funsigned-char \
-mcall-prologues \
-fno-move-loop-invariants \
-fno-move-loop-stores \
-fno-split-loops \
-fno-unswitch-loops \
-fno-unroll-loops \
-fno-peel-loops
20 changes: 17 additions & 3 deletions chips/avr/snek-avr.defs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,31 @@ SNEK_AVR_BUILTINS = \

SNEK_NO_FILE = 1

OPT=-Os -frename-registers -funsigned-char -fno-jump-tables -mcall-prologues
#OPT=-Os -frename-registers -funsigned-char -fno-jump-tables -mcall-prologues

OPT=-Os \
-mrelax \
-flto \
-Wno-array-bounds \
-frename-registers \
-funsigned-char \
-mcall-prologues \
-fno-move-loop-invariants \
-fno-move-loop-stores \
-fno-split-loops \
-fno-unswitch-loops \
-fno-unroll-loops \
-fno-peel-loops

SNEK_CFLAGS = $(SNEK_MOST_WARNINGS) $(SNEK_BASE_CFLAGS)

AO_CFLAGS=\
-std=c99 $(OPT) -g
$(OPT) -g

AVR_CFLAGS=-DF_CPU=$(AVR_CLOCK) -mmcu=atmega32u4 -g $(SNEK_CFLAGS) -Waddr-space-convert \
-I. -I$(SNEK_PORT) -I$(SNEK_AVR) -I$(SNEK_AO) -I$(SNEK_ROOT) $(AO_CFLAGS)

CFLAGS = $(AVR_CFLAGS) $(SNEK_CFLAGS)
CFLAGS = $(SNEK_CFLAGS) $(AVR_CFLAGS)

LDSCRIPT=$(SNEK_AVR)/snek-avr51.x

Expand Down
4 changes: 1 addition & 3 deletions ports/duemilanove/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ HEX=$(BASE).hex
MAP=$(BASE).map
CC=avr-gcc

OPT=-Os -frename-registers -funsigned-char -fno-jump-tables -mcall-prologues

CFLAGS=$(OPT) -DUART_BAUD=$(BAUD) -DF_CPU=$(CLOCK)UL -mmcu=atmega328p -I. -I$(SNEK_LOCAL_VPATH) -g $(SNEK_CFLAGS) -Waddr-space-convert
CFLAGS=-DUART_BAUD=$(BAUD) -DF_CPU=$(CLOCK)UL -mmcu=atmega328p -I. -I$(SNEK_LOCAL_VPATH) $(SNEK_CFLAGS) $(OPT) -g -Waddr-space-convert
LDFLAGS=$(SNEK_LDFLAGS) \
-Wl,-uvfprintf -lprintf_flt -lm \
-Wl,--defsym -Wl,__TEXT_REGION_LENGTH__=$(ATMEGA_FLASH_SIZE) \
Expand Down
4 changes: 1 addition & 3 deletions ports/grove/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ HEX=$(BASE).hex
MAP=$(BASE).map
CC=avr-gcc

OPT=-Os -frename-registers -funsigned-char -fno-jump-tables -mcall-prologues

CFLAGS=$(OPT) -DF_CPU=16000000UL -mmcu=atmega328p -I. -I$(SNEK_LOCAL_VPATH) -g $(SNEK_CFLAGS) -Waddr-space-convert
CFLAGS=-DF_CPU=16000000UL -mmcu=atmega328p -I. -I$(SNEK_LOCAL_VPATH) -g $(SNEK_CFLAGS) $(OPT) -Waddr-space-convert
LDFLAGS=$(SNEK_LDFLAGS) \
-Wl,-uvfprintf -lprintf_flt -lm \
-Wl,--defsym -Wl,__TEXT_REGION_LENGTH__=0x7e00 \
Expand Down
2 changes: 1 addition & 1 deletion ports/mega/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ELF=$(BASE).elf
HEX=$(BASE).hex
MAP=$(BASE).map
CC=avr-gcc
CFLAGS=-Os -DF_CPU=16000000UL -mmcu=atmega2560 -I. -I$(SNEK_LOCAL_VPATH) -g -fno-jump-tables $(SNEK_CFLAGS) -mcall-prologues -Waddr-space-convert
CFLAGS=-DF_CPU=16000000UL -mmcu=atmega2560 -I. -I$(SNEK_LOCAL_VPATH) -g $(SNEK_CFLAGS) $(OPT) -Waddr-space-convert
LDFLAGS=$(SNEK_LDFLAGS) \
-Wl,-uvfprintf -lprintf_flt -lm \
-Wl,-Map=$(MAP)
Expand Down
6 changes: 2 additions & 4 deletions ports/nano-every/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ BASE=snek-$(BOARD)-$(SNEK_VERSION)
ELF=$(BASE).elf
HEX=$(BASE).hex
MAP=$(BASE).map
CC=$(AVR_ROOT)/bin/avr-gcc
CC=avr-gcc

OPT=-Os -frename-registers -funsigned-char -fno-jump-tables -mcall-prologues

CFLAGS=$(OPT) -DF_CPU=20000000UL -mmcu=atmega4809 -I. -I$(SNEK_LOCAL_VPATH) -g $(SNEK_CFLAGS) -Waddr-space-convert
CFLAGS=-DF_CPU=20000000UL -mmcu=atmega4809 -I. -I$(SNEK_LOCAL_VPATH) -g $(SNEK_CFLAGS) $(OPT) -Waddr-space-convert
LDFLAGS=$(SNEK_LDFLAGS) \
-Wl,-uvfprintf -lprintf_flt -lm \
-Wl,-Map=$(MAP)
Expand Down
2 changes: 1 addition & 1 deletion ports/narrow-1284/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ELF=$(BASE).elf
HEX=$(BASE).hex
MAP=$(BASE).map
CC=avr-gcc
CFLAGS=-Os -DF_CPU=16000000UL -mmcu=atmega1284 -I. -I$(SNEK_LOCAL_VPATH) -g -fno-jump-tables $(SNEK_CFLAGS) -mcall-prologues -Waddr-space-convert
CFLAGS=-DF_CPU=16000000UL -mmcu=atmega1284 -I. -I$(SNEK_LOCAL_VPATH) -g -fno-jump-tables $(SNEK_CFLAGS) $(OPT) -Waddr-space-convert
LDFLAGS=$(SNEK_LDFLAGS) \
-Wl,-uvfprintf -lprintf_flt -lm \
-Wl,-Map=$(MAP)
Expand Down

0 comments on commit 79cd805

Please sign in to comment.