Makefile: use clang and GNU ld instead of ELLCC because it doesn't provide malloc
This commit is contained in:
parent
2f05b2d5cb
commit
39100c53b6
49
Makefile
49
Makefile
|
@ -51,19 +51,17 @@ DEPENDENCIES = $(patsubst %,%.inc,$(FIRMWARE))
|
|||
-include $(DEPENDENCIES)
|
||||
|
||||
# executables for linking, compiling, debugging, ...
|
||||
# use ELLCC cross-compiling chain (based on clang/llvm + musl)
|
||||
ELLCC := /opt/ellcc/
|
||||
# use clang to compile, GNU ARM toolchain for the rest
|
||||
PREFIX ?= arm-none-eabi
|
||||
# use ELLCC as compile
|
||||
CC := $(ELLCC)bin/ecc -target arm-none-eabi
|
||||
CC := clang -target $(PREFIX)
|
||||
LD := $(PREFIX)-ld
|
||||
LD := $(ELLCC)bin/ecc-ld -m armelf
|
||||
AR := $(ELLCC)bin/ecc-ar
|
||||
AS := $(ELLCC)bin/ecc-as
|
||||
OBJCOPY := $(ELLCC)bin/ecc-objcopy
|
||||
OBJDUMP := $(ELLCC)bin/ecc-objdump
|
||||
GDB := $(ELLCC)bin/ecc-gdb
|
||||
# ecc-gdb (0.13.3) is buggy (crash on kill, can't load elf)
|
||||
GDB := arm-none-eabi-gdb
|
||||
LD := $(PREFIX)-ld
|
||||
AR := $(PREFIX)-ar
|
||||
AS := $(PREFIX)-as
|
||||
OBJCOPY := $(PREFIX)-objcopy
|
||||
OBJDUMP := $(PREFIX)-objdump
|
||||
GDB := $(PREFIX)-gdb
|
||||
|
||||
# device micro-controller and board
|
||||
DEFS += -DSTM32F1 -D$(BOARD)
|
||||
|
@ -79,16 +77,14 @@ CFLAGS += -std=c99
|
|||
CFLAGS += -Wpedantic -Wall -Werror -Wundef -Wextra -Wshadow -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wstrict-overflow=5
|
||||
# add options for better code optimization
|
||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
||||
# use variable size enum (opencm3, gcc, and compiler-rt do)
|
||||
#CFLAGS += -fshort-enums
|
||||
# use variable size enum (clang doesn't but opencm3, and gcc do)
|
||||
CFLAGS += -fshort-enums
|
||||
# use no variable size enum (ELLCC/musl does not)
|
||||
CFLAGS += -fno-short-enums
|
||||
#CFLAGS += -fno-short-enums
|
||||
# don't use system main definition (the starting point)
|
||||
CFLAGS += -ffreestanding
|
||||
# don't use the standard library
|
||||
CFLAGS += -nostdlib -nostdinc
|
||||
# include ELLCC libraries
|
||||
CFLAGS += -I $(ELLCC)libecc/include/ -I $(ELLCC)libecc/include/arm/
|
||||
# don't use the standard library (only if you provide an alternative libc library)
|
||||
#CFLAGS += -nostdlib -nostdinc
|
||||
# include own libraries
|
||||
CFLAGS += $(foreach lib,$(SRCLIBS),-I $(lib))
|
||||
# include opencm3 libraries
|
||||
|
@ -103,16 +99,17 @@ LDFLAGS += -static
|
|||
LDFLAGS += -nostartfiles
|
||||
# only keep used sections
|
||||
LDFLAGS += --gc-sections
|
||||
# don't use system libraries
|
||||
LDFLAGS += -nostdlib -nostdinc
|
||||
# add ELLCC standard libraries (for libc, libm, libgcc)
|
||||
LDFLAGS += --library-path $(ELLCC)libecc/lib/cortex-m3-linux/
|
||||
# don't use system libraries (only if you provide an alternative libc library)
|
||||
#LDFLAGS += -nostdlib -nostdinc
|
||||
# add standard libraries (for libc, libm, libnosys, libgcc)
|
||||
LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/
|
||||
LDFLAGS += --library-path /usr/lib/gcc/arm-none-eabi/*/armv7-m/
|
||||
# opencm3 libraries
|
||||
LDFLAGS += --library-path $(OPENCM3_LIB)
|
||||
# used libraries (gcc provides the ARM ABI, not sure how to replace with compiler-rt)
|
||||
LDLIBS += --library $(STM32F1_LIB) --library c --library m --library gcc
|
||||
# used libraries (gcc provides the ARM ABI)
|
||||
LDLIBS += --library $(STM32F1_LIB) --library c --library m --library nosys --library gcc
|
||||
|
||||
# target micro-controller information (ARM Cortex-M3 supports thumb and thumnb2, but does not include a floating point unit)
|
||||
# target micro-controller information (ARM Cortex-M3 supports thumb and thumb2, but does not include a floating point unit)
|
||||
ARCH_FLAGS = -mthumb -mcpu=cortex-m3 -msoft-float
|
||||
|
||||
# SWD adapter used
|
||||
|
@ -177,7 +174,7 @@ $(OPENCM3_DIR)/Makefile:
|
|||
# compile libopencm3
|
||||
$(OPENCM3_LIB)/lib$(STM32F1_LIB).a: $(OPENCM3_DIR)/Makefile
|
||||
$(info compiling libopencm3 submodule)
|
||||
$(Q)CFLAGS=-fno-short-enums $(MAKE) --directory $(OPENCM3_DIR)
|
||||
$(Q)$(MAKE) --directory $(OPENCM3_DIR)
|
||||
|
||||
# doxygen documentation
|
||||
doc: Doxyfile README.md $(patsubst %,%.c,$(FIRMWARE)) $(CSRC) $(CHDR)
|
||||
|
|
Loading…
Reference in New Issue