diff --git a/platforms/m3/prc_v17/software/Makefile b/platforms/m3/prc_v17/software/Makefile index dc9fcc24..73eea390 100644 --- a/platforms/m3/prc_v17/software/Makefile +++ b/platforms/m3/prc_v17/software/Makefile @@ -5,6 +5,7 @@ ################################################################################ CFLAGS := +CLDFLAGS := ASFLAGS := ########################## @@ -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) @@ -78,7 +78,7 @@ LSTS := $(foreach var,$(DIRS),$(var)/$(var).lst) .PHONY: all -all: $(HEXS) $(LSTS) +all: libs/memmap $(HEXS) $(LSTS) $(DIRS): $(MAKE) $@/$@.hex @@ -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 ########## diff --git a/platforms/m3/prc_v17/software/include/mbus.h b/platforms/m3/prc_v17/software/include/mbus.h index 736cd494..590fe550 100755 --- a/platforms/m3/prc_v17/software/include/mbus.h +++ b/platforms/m3/prc_v17/software/include/mbus.h @@ -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, diff --git a/platforms/m3/prc_v17/software/libs/mbus.c b/platforms/m3/prc_v17/software/libs/mbus.c index 8708d8dc..12796a2a 100755 --- a/platforms/m3/prc_v17/software/libs/mbus.c +++ b/platforms/m3/prc_v17/software/libs/mbus.c @@ -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,