all: Use += rather than = everywhere for CFLAGS/LDFLAGS/LIBS.

This avoids a surprise where an = can cancel out an earlier +=.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2022-10-08 23:08:53 +11:00 committed by Damien George
parent 8e912a501a
commit 17f2783e4a
16 changed files with 34 additions and 34 deletions

View File

@ -98,8 +98,8 @@ We also need a Makefile at this point for the port:
include $(TOP)/extmod/extmod.mk include $(TOP)/extmod/extmod.mk
# Set CFLAGS and libraries. # Set CFLAGS and libraries.
CFLAGS = -I. -I$(BUILD) -I$(TOP) CFLAGS += -I. -I$(BUILD) -I$(TOP)
LIBS = -lm LIBS += -lm
# Define the required source files. # Define the required source files.
SRC_C = \ SRC_C = \

View File

@ -1,6 +1,6 @@
MPTOP = ../.. MPTOP = ../..
CFLAGS = -std=c99 -I. -I$(MPTOP) -DNO_QSTR CFLAGS += -std=c99 -I. -I$(MPTOP) -DNO_QSTR
LDFLAGS = -L./build LDFLAGS += -L./build
hello-embed: hello-embed.o -lmicropython hello-embed: hello-embed.o -lmicropython

View File

@ -20,7 +20,7 @@ INC += -I$(BUILD)
# compiler settings # compiler settings
CWARN = -Wall -Werror CWARN = -Wall -Werror
CWARN += -Wpointer-arith -Wuninitialized CWARN += -Wpointer-arith -Wuninitialized
CFLAGS = $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
# Some systems (eg MacOS) need -fno-common so that mp_state_ctx is placed in the BSS. # Some systems (eg MacOS) need -fno-common so that mp_state_ctx is placed in the BSS.
CFLAGS += -fno-common CFLAGS += -fno-common
@ -70,7 +70,7 @@ else
# Use gcc syntax for map file # Use gcc syntax for map file
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
endif endif
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
ifeq ($(MICROPY_FORCE_32BIT),1) ifeq ($(MICROPY_FORCE_32BIT),1)
# Note: you may need to install i386 versions of dependency packages, # Note: you may need to install i386 versions of dependency packages,

View File

@ -20,7 +20,7 @@ include ../../py/mkenv.mk
CROSS_COMPILE ?= arm-none-eabi- CROSS_COMPILE ?= arm-none-eabi-
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -march=armv7e-m -mabi=aapcs -mcpu=cortex-m4 -msoft-float -mfloat-abi=soft -fsingle-precision-constant -Wdouble-promotion CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -march=armv7e-m -mabi=aapcs -mcpu=cortex-m4 -msoft-float -mfloat-abi=soft -fsingle-precision-constant -Wdouble-promotion
CFLAGS = -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) -Os CFLAGS += -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) -Os
CFLAGS += -g -ffunction-sections -fdata-sections -fno-common -fsigned-char -mno-unaligned-access CFLAGS += -g -ffunction-sections -fdata-sections -fno-common -fsigned-char -mno-unaligned-access
CFLAGS += -Iboards/$(BOARD) CFLAGS += -Iboards/$(BOARD)
CFLAGS += $(CFLAGS_MOD) CFLAGS += $(CFLAGS_MOD)
@ -28,7 +28,7 @@ CFLAGS += $(CFLAGS_MOD)
# Workaround gcc 12.1 bug. # Workaround gcc 12.1 bug.
CFLAGS += -Wno-array-bounds CFLAGS += -Wno-array-bounds
LDFLAGS = -Wl,-nostdlib -Wl,--gc-sections -Wl,-Map=$@.map LDFLAGS += -Wl,-nostdlib -Wl,--gc-sections -Wl,-Map=$@.map
FLASH_SIZE_WIPY = 2M FLASH_SIZE_WIPY = 2M
FLASH_SIZE_LAUNCHXL = 1M FLASH_SIZE_LAUNCHXL = 1M

View File

@ -57,12 +57,12 @@ CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
-Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 \ -Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 \
-DLWIP_OPEN_SRC -DLWIP_OPEN_SRC
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \ CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -I$(BOARD_DIR) $(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -I$(BOARD_DIR)
LD_FILES ?= boards/esp8266_2m.ld LD_FILES ?= boards/esp8266_2m.ld
LDFLAGS = -nostdlib -T $(LD_FILES) -Map=$(@:.elf=.map) --cref LDFLAGS += -nostdlib -T $(LD_FILES) -Map=$(@:.elf=.map) --cref
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD) LIBS += -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc

View File

@ -393,7 +393,7 @@ CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
# Linker Flags # Linker Flags
# ============================================================================= # =============================================================================
LDFLAGS = \ LDFLAGS += \
--cref \ --cref \
--gc-sections \ --gc-sections \
--print-memory-usage \ --print-memory-usage \

View File

@ -23,12 +23,12 @@ ifeq ($(CROSS), 1)
DFU = $(TOP)/tools/dfu.py DFU = $(TOP)/tools/dfu.py
PYDFU = $(TOP)/tools/pydfu.py PYDFU = $(TOP)/tools/pydfu.py
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT) CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections LDFLAGS += -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
else else
LD = gcc LD = gcc
CFLAGS = $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT) CFLAGS += $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
LDFLAGS = -Wl,-Map=$@.map,--cref -Wl,--gc-sections LDFLAGS += -Wl,-Map=$@.map,--cref -Wl,--gc-sections
endif endif
CSUPEROPT = -Os # save some code space CSUPEROPT = -Os # save some code space

View File

@ -129,7 +129,7 @@ CFLAGS += -fno-strict-aliasing
CFLAGS += -Iboards/$(BOARD) CFLAGS += -Iboards/$(BOARD)
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>' CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
LDFLAGS = $(CFLAGS) LDFLAGS += $(CFLAGS)
LDFLAGS += -Xlinker -Map=$(@:.elf=.map) LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
LDFLAGS += -mthumb -mabi=aapcs $(addprefix -T,$(LD_FILES)) -L boards/ LDFLAGS += -mthumb -mabi=aapcs $(addprefix -T,$(LD_FILES)) -L boards/

View File

@ -21,7 +21,7 @@ INC += -I$(XC16)/include
INC += -I$(XC16)/support/$(PARTFAMILY)/h INC += -I$(XC16)/support/$(PARTFAMILY)/h
CFLAGS_PIC16BIT = -mcpu=$(PART) -mlarge-code CFLAGS_PIC16BIT = -mcpu=$(PART) -mlarge-code
CFLAGS = $(INC) -Wall -Werror -std=gnu99 -nostdlib $(CFLAGS_PIC16BIT) $(COPT) CFLAGS += $(INC) -Wall -Werror -std=gnu99 -nostdlib $(CFLAGS_PIC16BIT) $(COPT)
#Debugging/Optimization #Debugging/Optimization
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
@ -30,8 +30,8 @@ else
CFLAGS += -O1 -DNDEBUG CFLAGS += -O1 -DNDEBUG
endif endif
LDFLAGS = --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART) LDFLAGS += --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART)
LIBS = -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30 LIBS += -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30
SRC_C = \ SRC_C = \
main.c \ main.c \

View File

@ -21,14 +21,14 @@ INC += -I.
INC += -I$(TOP) INC += -I$(TOP)
INC += -I$(BUILD) INC += -I$(BUILD)
CFLAGS = $(INC) -g -Wall -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT) CFLAGS += $(INC) -g -Wall -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
CFLAGS += -mno-string -mno-multiple -mno-vsx -mno-altivec -nostdlib CFLAGS += -mno-string -mno-multiple -mno-vsx -mno-altivec -nostdlib
CFLAGS += -mlittle-endian -mstrict-align -msoft-float CFLAGS += -mlittle-endian -mstrict-align -msoft-float
CFLAGS += -Os CFLAGS += -Os
CFLAGS += -fdata-sections -ffunction-sections -fno-stack-protector -ffreestanding CFLAGS += -fdata-sections -ffunction-sections -fno-stack-protector -ffreestanding
CFLAGS += -U_FORTIFY_SOURCE CFLAGS += -U_FORTIFY_SOURCE
LDFLAGS = -N -T powerpc.lds -nostdlib LDFLAGS += -N -T powerpc.lds -nostdlib
LIBS = LIBS =

View File

@ -139,7 +139,7 @@ CFLAGS += -fsingle-precision-constant
endif endif
endif endif
LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref LDFLAGS += -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref
LDFLAGS += --defsym=_estack_reserve=8 LDFLAGS += --defsym=_estack_reserve=8
LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)" LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)"

View File

@ -58,15 +58,15 @@ GEN_PINS_HDR = $(BUILD)/pins.h
CFLAGS_MCU_SAMD21 = -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float CFLAGS_MCU_SAMD21 = -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float
CFLAGS_MCU_SAMD51 = -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard CFLAGS_MCU_SAMD51 = -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__ CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA) CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS += -DMPCONFIG_MCU_H='<boards/mpconfig_$(MCU_SERIES_LOWER).h>' CFLAGS += -DMPCONFIG_MCU_H='<boards/mpconfig_$(MCU_SERIES_LOWER).h>'
LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
LDFLAGS += $(LDFLAGS_MOD) LDFLAGS += $(LDFLAGS_MOD)
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
# Tune for Debugging or Optimization # Tune for Debugging or Optimization
CFLAGS += -g # always include debug info in the ELF CFLAGS += -g # always include debug info in the ELF

View File

@ -99,7 +99,7 @@ CFLAGS += -fsingle-precision-constant
endif endif
endif endif
LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Wl,-Map=$(@:.elf=.map) -Wl,--cref LDFLAGS += -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Wl,-Map=$(@:.elf=.map) -Wl,--cref
LDFLAGS += -Wl,--defsym=_estack_reserve=8 LDFLAGS += -Wl,--defsym=_estack_reserve=8
LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)" LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)"

View File

@ -58,7 +58,7 @@ INC += -I../$(USBDEV_DIR)/core/inc -I../$(USBDEV_DIR)/class/inc
# the compiler does not optimise these functions in terms of themselves. # the compiler does not optimise these functions in terms of themselves.
CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto
CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA) CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS += -D$(CMSIS_MCU) CFLAGS += -D$(CMSIS_MCU)
CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES)) CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
CFLAGS += $(COPT) CFLAGS += $(COPT)
@ -75,8 +75,8 @@ CFLAGS += -DMICROPY_HW_STM32WB_FLASH_SYNCRONISATION=0
CFLAGS += -DBOOTLOADER_DFU_USB_VID=$(BOOTLOADER_DFU_USB_VID) -DBOOTLOADER_DFU_USB_PID=$(BOOTLOADER_DFU_USB_PID) CFLAGS += -DBOOTLOADER_DFU_USB_VID=$(BOOTLOADER_DFU_USB_VID) -DBOOTLOADER_DFU_USB_PID=$(BOOTLOADER_DFU_USB_PID)
MBOOT_LD_FILES ?= stm32_memory.ld stm32_sections.ld MBOOT_LD_FILES ?= stm32_memory.ld stm32_sections.ld
LDFLAGS = -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES)) -Map=$(@:.elf=.map) --cref LDFLAGS += -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES)) -Map=$(@:.elf=.map) --cref
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
# Remove uncalled code from the final image. # Remove uncalled code from the final image.
CFLAGS += -fdata-sections -ffunction-sections CFLAGS += -fdata-sections -ffunction-sections

View File

@ -75,8 +75,8 @@ INC += -I$(TOP)/ports/stm32
INC += -I$(BUILD) INC += -I$(BUILD)
INC += -Icore INC += -Icore
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4)
LDFLAGS = -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft LDFLAGS += -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft
ifeq ($(USE_ARDUINO_TOOLCHAIN),1) ifeq ($(USE_ARDUINO_TOOLCHAIN),1)

View File

@ -32,8 +32,8 @@ INC += -I$(BUILD)
INC += -I$(VARIANT_DIR) INC += -I$(VARIANT_DIR)
# compiler settings # compiler settings
CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
LDFLAGS = $(LDFLAGS_MOD) -lm -lbcrypt $(LDFLAGS_EXTRA) LDFLAGS += -lm -lbcrypt $(LDFLAGS_EXTRA)
# Debugging/Optimization # Debugging/Optimization
ifdef DEBUG ifdef DEBUG