From d37f8def8814586f00c1f860019538f41fc5cf7d Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Sat, 5 Sep 2020 18:23:03 +0300 Subject: [PATCH 1/2] Fix FTBFS due to LTO being more sensitive to file order When a symbol is used from inline assembly, LTO compiling and linking process becomes more picky with regard to the order of compile/linking units. Specifically, when FreeRTOS/Source/portable/GCC/ARM_CM3/port.c comes before FreeRTOS/Source/tasks.c in find results, the build fails with undefined reference to `pxCurrentTCB' error. To workaround the issue, do the same as we already have for vTaskSwitchContext. Note: different order affects resulting binary (.text section) size: 39924 with the wrong order and 39884 with the correct. Fixes #685. --- workspace/TS100/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/workspace/TS100/Makefile b/workspace/TS100/Makefile index 20c43f58..31aec7e0 100644 --- a/workspace/TS100/Makefile +++ b/workspace/TS100/Makefile @@ -95,7 +95,9 @@ LINKER_FLAGS=-Wl,--gc-sections \ -Wl,--wrap=free \ -o$(OUT_HEXFILE).elf \ -Wl,-Map=$(OUT_HEXFILE).map \ - -lm -Wl,--undefined=vTaskSwitchContext \ + -lm \ + -Wl,--undefined=vTaskSwitchContext \ + -Wl,--undefined=pxCurrentTCB \ -Wl,--defsym=__FLASH_SIZE__=$(flash_size) \ -Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \ --specs=nano.specs From e6e0a0f280cc551643b2f8bed4c569667ca0caa9 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Sat, 5 Sep 2020 18:39:49 +0300 Subject: [PATCH 2/2] Makefile: remove -ffat-lto-objects "Fat" LTO objects are only needed if future linking _without_ LTO is planned. Not using this option gives about 1.5x building time advantage without affecting the final binary. An unused variable is removed along the way. --- workspace/TS100/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/workspace/TS100/Makefile b/workspace/TS100/Makefile index 31aec7e0..175c1547 100644 --- a/workspace/TS100/Makefile +++ b/workspace/TS100/Makefile @@ -10,7 +10,6 @@ endif # Discover the source files to build SOURCE := $(shell find . -type f -name '*.c') SOURCE_CPP := $(shell find . -type f -name '*.cpp') -SOURCES := $(shell find . -type f -name '*.c*') S_SRCS := $(shell find . -type f -name '*.s') APP_INC_DIR = ./Core/Inc @@ -47,7 +46,7 @@ HEXFILE_DIR=Hexfile OUTPUT_DIR=Objects # code optimisation ------------------------------------------------------------ -OPTIM=-Os -flto -ffat-lto-objects -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections +OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections flash_size=64k bootldr_size=0x4000 @@ -64,7 +63,7 @@ DEBUG=-g3 # Without debug code #DEBUG= - + # libs ------------------------------------------------------------------------- LIBS=