use gcc for linker instead of ld
This commit is contained in:
parent
e37c884463
commit
54ddaa142d
55
Makefile
55
Makefile
@ -38,28 +38,20 @@ MERGED_FILE = $(OUT_FILE)_$(SD_NAME)_$(SD_VERSION)
|
|||||||
# Toolchain commands
|
# Toolchain commands
|
||||||
# Should be added to your PATH
|
# Should be added to your PATH
|
||||||
CROSS_COMPILE = arm-none-eabi-
|
CROSS_COMPILE = arm-none-eabi-
|
||||||
CC := $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
AS := $(CROSS_COMPILE)as
|
AS = $(CROSS_COMPILE)as
|
||||||
AR := $(CROSS_COMPILE)ar -r
|
AR = $(CROSS_COMPILE)ar -r
|
||||||
LD := $(CROSS_COMPILE)ld
|
NM = $(CROSS_COMPILE)nm
|
||||||
NM := $(CROSS_COMPILE)nm
|
OBJDUMP = $(CROSS_COMPILE)objdump
|
||||||
OBJDUMP := $(CROSS_COMPILE)objdump
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
OBJCOPY := $(CROSS_COMPILE)objcopy
|
SIZE = $(CROSS_COMPILE)size
|
||||||
SIZE := $(CROSS_COMPILE)size
|
GDB = $(CROSS_COMPILE)gdb
|
||||||
GDB := $(CROSS_COMPILE)gdb
|
|
||||||
|
|
||||||
NRFUTIL = adafruit-nrfutil
|
NRFUTIL = adafruit-nrfutil
|
||||||
NRFJPROG = nrfjprog
|
NRFJPROG = nrfjprog
|
||||||
|
|
||||||
MK := mkdir -p
|
MK = mkdir -p
|
||||||
RM := rm -rf
|
RM = rm -rf
|
||||||
|
|
||||||
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
|
|
||||||
ifeq ("$(V)","2")
|
|
||||||
QUIET =
|
|
||||||
else
|
|
||||||
QUIET = @
|
|
||||||
endif
|
|
||||||
|
|
||||||
# auto-detect BMP on macOS, otherwise have to specify
|
# auto-detect BMP on macOS, otherwise have to specify
|
||||||
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
|
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
|
||||||
@ -226,7 +218,7 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|||||||
|
|
||||||
# keep every function in separate section. This will allow linker to dump unused functions
|
# keep every function in separate section. This will allow linker to dump unused functions
|
||||||
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||||
CFLAGS += -fno-builtin --short-enums -fstack-usage
|
CFLAGS += -fno-builtin -fshort-enums -fstack-usage
|
||||||
|
|
||||||
# Defined Symbol (MACROS)
|
# Defined Symbol (MACROS)
|
||||||
CFLAGS += -D__HEAP_SIZE=0
|
CFLAGS += -D__HEAP_SIZE=0
|
||||||
@ -248,17 +240,13 @@ CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)
|
|||||||
#
|
#
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
|
||||||
# keep every function in separate section. This will allow linker to dump unused functions
|
LDFLAGS += \
|
||||||
LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUT_FILE).map
|
$(CFLAGS) \
|
||||||
LDFLAGS += -mthumb -mabi=aapcs -Llinker -T$(LD_FILE)
|
-Wl,-L,linker -Wl,-T,$(LD_FILE) \
|
||||||
LDFLAGS += -mcpu=cortex-m4
|
-Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections \
|
||||||
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
-specs=nosys.specs -specs=nano.specs
|
||||||
|
|
||||||
# let linker to dump unused sections
|
LIBS += -lm -lc
|
||||||
LDFLAGS += -Wl,--gc-sections
|
|
||||||
|
|
||||||
# use newlib in nano version
|
|
||||||
LDFLAGS += --specs=nano.specs -lc -lnosys
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# Assembler flags
|
# Assembler flags
|
||||||
@ -290,6 +278,7 @@ OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
|
|||||||
# BUILD TARGETS
|
# BUILD TARGETS
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
|
||||||
|
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
|
||||||
ifeq ("$(V)","1")
|
ifeq ("$(V)","1")
|
||||||
$(info CFLAGS $(CFLAGS))
|
$(info CFLAGS $(CFLAGS))
|
||||||
$(info )
|
$(info )
|
||||||
@ -299,6 +288,12 @@ $(info ASMFLAGS $(ASMFLAGS))
|
|||||||
$(info )
|
$(info )
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ("$(V)","2")
|
||||||
|
QUIET =
|
||||||
|
else
|
||||||
|
QUIET = @
|
||||||
|
endif
|
||||||
|
|
||||||
.phony: all clean size flash sd erase
|
.phony: all clean size flash sd erase
|
||||||
|
|
||||||
# default target to build
|
# default target to build
|
||||||
@ -359,7 +354,7 @@ $(BUILD)/%.o: %.S
|
|||||||
# Link
|
# Link
|
||||||
$(BUILD)/$(OUT_FILE)-nosd.out: $(BUILD) $(OBJECTS)
|
$(BUILD)/$(OUT_FILE)-nosd.out: $(BUILD) $(OBJECTS)
|
||||||
@echo LD $(OUT_FILE)-nosd.out
|
@echo LD $(OUT_FILE)-nosd.out
|
||||||
$(QUIET)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -lm -o $@
|
$(QUIET)$(CC) -o $@ $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||||
|
|
||||||
size: $(BUILD)/$(OUT_FILE)-nosd.out
|
size: $(BUILD)/$(OUT_FILE)-nosd.out
|
||||||
-@echo ''
|
-@echo ''
|
||||||
|
Loading…
Reference in New Issue
Block a user