stm32/Makefile: Workaround LTO linker order bug in binutils <2.35.

Assembly files with weak symbols need to be linked first to avoid issues
with the weak symbols being incorrectly linked instead of strong ones.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83967 and
https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966

This is the workaround suggested in comment 10 of the gcc-arm-embedded bug.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton 2022-07-15 15:13:42 +10:00 committed by Damien George
parent a1ef5ac65d
commit 1d23c01dd6
1 changed files with 3 additions and 1 deletions

View File

@ -534,6 +534,9 @@ endif
endif
# SRC_O should be placed first to work around this LTO bug with binutils <2.35:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83967
OBJ += $(addprefix $(BUILD)/, $(SRC_O))
OBJ += $(PY_O)
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
OBJ += $(LIBM_O)
@ -544,7 +547,6 @@ OBJ += $(addprefix $(BUILD)/, $(HAL_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(USBDEV_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_O))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
OBJ += $(BUILD)/pins_$(BOARD).o