Skip to content

Commit

Permalink
[Core] Enable linker relaxation for AVR targets
Browse files Browse the repository at this point in the history
This can save some bytes for by using RJMP instructions to
memory location that are +-2k relative to the current
program counter position. Unfortunately this is only possible
when LTO is disabled.
  • Loading branch information
KarlK90 committed Feb 7, 2022
1 parent a86d6ff commit 73c128c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion platforms/avr/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ COMPILEFLAGS += -fdata-sections
COMPILEFLAGS += -fpack-struct
COMPILEFLAGS += -fshort-enums

# Linker relaxation is only possible if
# link time optimizations are not enabled.
ifeq ($(strip $(LTO_ENABLE)), no)
COMPILEFLAGS += -mrelax
endif

ASFLAGS += $(AVR_ASFLAGS)

CFLAGS += $(COMPILEFLAGS) $(AVR_CFLAGS)
Expand All @@ -28,7 +34,7 @@ CFLAGS += -fno-strict-aliasing
CXXFLAGS += $(COMPILEFLAGS)
CXXFLAGS += -fno-exceptions -std=c++11

LDFLAGS +=-Wl,--gc-sections
LDFLAGS += -Wl,--gc-sections

OPT_DEFS += -DF_CPU=$(F_CPU)UL

Expand Down

0 comments on commit 73c128c

Please sign in to comment.