Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: turn on Link-Time-Optimization #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions platforms/m3/prc_v17/software/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
################################################################################

CFLAGS :=
CLDFLAGS :=
ASFLAGS :=

##########################
Expand All @@ -13,14 +14,13 @@ ASFLAGS :=
#CFLAGS += -Wall -Wextra -Werror -mthumb -mcpu=cortex-m0 -ffreestanding
# Don't care about the warnings not compiling. It's annoying.
CFLAGS += -Os -Wall -Wextra -mthumb -mcpu=cortex-m0 -ffreestanding -fdata-sections -ffunction-sections -g
LDFLAGS += -Os -static -S -nostartfiles --gc-sections -e _start #-dead_strip #-why_live read_mbus_register_RADv4
#LDFLAGS += -Os -static -S -nostartfiles -nodefaultlibs -nostdlib --gc-sections -e _start #-dead_strip #-why_live read_mbus_register_RADv4
# turn on Link-time-optimization
CFLAGS += -flto
CLDFLAGS = -static -nostdlib -Wl,--gc-sections --entry=_start
# no longer usling standard linker, as it can't do LTO, using gcc instead
#LDFLAGS += -Os -static -S -nostartfiles --gc-sections -e _start #-dead_strip #-why_live read_mbus_register_RADv4
ASFLAGS += -mthumb --warn -mcpu=cortex-m0

# Experiments in not linking unused sections
#CFLAGS += -fvtable-gc -fdata-sections -ffunction-sections -Wl,-static -Wl,--gc-sections -s
#LDFLAGS += -nostartfiles -nodefaultlibs -nostdlib

# Attempt to divine ARM toolchain
SHELL=/bin/bash
CROSS_COMPILE=$(shell if `hash arm-linux-gnueabi-gcc >& /dev/null`; then echo arm-linux-gnueabi; elif `hash arm-linux-gnu-gcc >& /dev/null`; then echo arm-linux-gnu; elif `hash arm-none-linux-gnueabi-gcc >& /dev/null`; then echo arm-none-linux-gnueabi; elif `hash arm-none-eabi-gcc >& /dev/null`; then echo arm-none-eabi; else echo -n ""; fi)
Expand Down Expand Up @@ -78,7 +78,7 @@ LSTS := $(foreach var,$(DIRS),$(var)/$(var).lst)

.PHONY: all

all: $(HEXS) $(LSTS)
all: libs/memmap $(HEXS) $(LSTS)

$(DIRS):
$(MAKE) $@/[email protected]
Expand All @@ -103,12 +103,16 @@ $(DIRS):
%.bin: %.elf
$(OBJCOPY) -O binary $< $@

#Uses GCC (not LD) to do the linking to make use of LTO
# Mind the order here to align -T$^
%.elf: libs/memmap $(LIBS) %.o
$(LD) $(LDFLAGS) -T$^ "$$(echo $$(arm-none-eabi-gcc -print-libgcc-file-name) | tr -d '\r')" -o $@
%.elf: COBJ=$(patsubst %.c,%.o,$(wildcard $(dir $@)*.c))
%.elf: SOBJ=$(patsubst %.s,%.o,$(wildcard $(dir $@)*.s))
%.elf: $(LIBS) $$(COBJ) $$(SOBJ)
$(CC) $(CFLAGS) $(CLDFLAGS) -Tlibs/memmap \
-Wl,--start-group $^ -Wl,--end-group -o $@
$(OBJDUMP) -Sd $@ > $*.asm

.PRECIOUS: %.elf
.PRECIOUS: %.elf %.o


##########
Expand Down
1 change: 0 additions & 1 deletion platforms/m3/prc_v17/software/include/mbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ void mbus_remote_register_write(
* @param remote_reg_addr The register to read on the remote
* @param local_reg_addr The register to save the value to on this node
*/
inline
void mbus_remote_register_read(
uint8_t remote_prefix,
uint8_t remote_reg_addr,
Expand Down
1 change: 0 additions & 1 deletion platforms/m3/prc_v17/software/libs/mbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ void mbus_remote_register_write(
mbus_write_message(address, &data, 1);
}

inline
void mbus_remote_register_read(
uint8_t remote_prefix,
uint8_t remote_reg_addr,
Expand Down