diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index f1c22c2a9a..bab62eaae9 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -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