From 79cd80596f7d9bad1d7df45c7338e31adad78fd2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 12 Nov 2024 20:01:44 -0800 Subject: [PATCH] Move AVR compile options to chips defs files 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 --- chips/atmega/snek-atmega.defs | 14 ++++++++++++++ chips/avr/snek-avr.defs | 20 +++++++++++++++++--- ports/duemilanove/Makefile | 4 +--- ports/grove/Makefile | 4 +--- ports/mega/Makefile | 2 +- ports/nano-every/Makefile | 6 ++---- ports/narrow-1284/Makefile | 2 +- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/chips/atmega/snek-atmega.defs b/chips/atmega/snek-atmega.defs index 59dd411..0958e69 100644 --- a/chips/atmega/snek-atmega.defs +++ b/chips/atmega/snek-atmega.defs @@ -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 diff --git a/chips/avr/snek-avr.defs b/chips/avr/snek-avr.defs index c5e8662..f9a974b 100644 --- a/chips/avr/snek-avr.defs +++ b/chips/avr/snek-avr.defs @@ -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 diff --git a/ports/duemilanove/Makefile b/ports/duemilanove/Makefile index 036206e..1984b47 100644 --- a/ports/duemilanove/Makefile +++ b/ports/duemilanove/Makefile @@ -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) \ diff --git a/ports/grove/Makefile b/ports/grove/Makefile index 608eae1..26706fa 100644 --- a/ports/grove/Makefile +++ b/ports/grove/Makefile @@ -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 \ diff --git a/ports/mega/Makefile b/ports/mega/Makefile index 5763030..ce661e6 100644 --- a/ports/mega/Makefile +++ b/ports/mega/Makefile @@ -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) diff --git a/ports/nano-every/Makefile b/ports/nano-every/Makefile index 125d766..9d688d8 100644 --- a/ports/nano-every/Makefile +++ b/ports/nano-every/Makefile @@ -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) diff --git a/ports/narrow-1284/Makefile b/ports/narrow-1284/Makefile index c0ad653..6977a4a 100644 --- a/ports/narrow-1284/Makefile +++ b/ports/narrow-1284/Makefile @@ -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)