mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
clang make work for samd21
This commit is contained in:
parent
366f1cf186
commit
a7bf0e3e7f
@ -4,10 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
|
||||
-mcpu=cortex-m0 \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m0 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# IAR Flags
|
||||
CFLAGS += --cpu cortex-m0
|
||||
ASFLAGS += --cpu cortex-m0
|
||||
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
|
@ -4,10 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
|
||||
-mcpu=cortex-m0plus \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m0plus \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# IAR Flags
|
||||
CFLAGS += --cpu cortex-m0+
|
||||
ASFLAGS += --cpu cortex-m0+
|
||||
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
|
@ -4,10 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
|
||||
-mcpu=cortex-m23 \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m23 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# IAR Flags
|
||||
CFLAGS += --cpu cortex-m23
|
||||
ASFLAGS += --cpu cortex-m23
|
||||
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
|
@ -4,13 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
|
||||
-mcpu=cortex-m3 \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m3 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# IAR Flags
|
||||
CFLAGS += \
|
||||
--cpu cortex-m3 \
|
||||
CFLAGS += --cpu cortex-m3
|
||||
ASFLAGS += --cpu cortex-m3
|
||||
|
||||
ASFLAGS += \
|
||||
--cpu cortex-m3
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
|
@ -1,16 +1,24 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mcpu=cortex-m33+nodsp \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m33 \
|
||||
-mfpu=softvp \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += \
|
||||
CFLAGS += \
|
||||
--cpu cortex-m33+nodsp \
|
||||
|
||||
ASFLAGS += \
|
||||
ASFLAGS += \
|
||||
--cpu cortex-m33+nodsp \
|
||||
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM33_NTZ/non_secure
|
||||
|
@ -5,15 +5,23 @@ ifeq ($(TOOLCHAIN),gcc)
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv5-sp-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m33 \
|
||||
-mfpu=fpv5-sp-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += \
|
||||
CFLAGS += \
|
||||
--cpu cortex-m33 \
|
||||
--fpu VFPv5-SP \
|
||||
|
||||
ASFLAGS += \
|
||||
ASFLAGS += \
|
||||
--cpu cortex-m33 \
|
||||
--fpu VFPv5-SP \
|
||||
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM33_NTZ/non_secure
|
||||
|
@ -5,9 +5,18 @@ ifeq ($(TOOLCHAIN),gcc)
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += --cpu cortex-m4 --fpu VFPv4
|
||||
ASFLAGS += --cpu cortex-m4 --fpu VFPv4
|
||||
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM4F
|
||||
|
@ -5,6 +5,12 @@ ifeq ($(TOOLCHAIN),gcc)
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv5-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
CFLAGS += \
|
||||
--target=arm-none-eabi \
|
||||
-mcpu=cortex-m7 \
|
||||
-mfpu=fpv5-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += \
|
||||
--cpu cortex-m7 \
|
||||
@ -14,6 +20,8 @@ else ifeq ($(TOOLCHAIN),iar)
|
||||
--cpu cortex-m7 \
|
||||
--fpu VFPv5_D16 \
|
||||
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM7/r0p1
|
||||
|
@ -1,7 +1,11 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
# nothing to add
|
||||
else ifeq ($(TOOLCHAIN),clang)
|
||||
# nothing to add
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# nothing to add
|
||||
else
|
||||
$(error "TOOLCHAIN is not supported")
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
|
@ -2,6 +2,26 @@
|
||||
# Common make definition for all examples
|
||||
# ---------------------------------------
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Toolchain
|
||||
# Can be changed via TOOLCHAIN=gcc|iar or CC=arm-none-eabi-gcc|iccarm|clang
|
||||
#-------------------------------------------------------------
|
||||
|
||||
ifneq (,$(findstring clang,$(CC)))
|
||||
TOOLCHAIN = clang
|
||||
else ifneq (,$(findstring iccarm,$(CC)))
|
||||
TOOLCHAIN = iar
|
||||
else ifneq (,$(findstring gcc,$(CC)))
|
||||
TOOLCHAIN = gcc
|
||||
endif
|
||||
|
||||
# Default to GCC
|
||||
ifndef TOOLCHAIN
|
||||
TOOLCHAIN = gcc
|
||||
endif
|
||||
|
||||
$(info TOOLCHAIN: $(TOOLCHAIN))
|
||||
|
||||
#-------------- TOP and CURRENT_PATH ------------
|
||||
|
||||
# Set TOP to be the path to get from the current directory (where make was invoked) to the top of the tree.
|
||||
@ -75,12 +95,6 @@ else
|
||||
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
|
||||
endif
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Toolchain
|
||||
# Can be changed via TOOLCHAIN=gcc|iar or CC=arm-none-eabi-gcc|iccarm|clang
|
||||
#-------------------------------------------------------------
|
||||
TOOLCHAIN ?= gcc
|
||||
|
||||
#-------------- Source files and compiler flags --------------
|
||||
# tinyusb makefile
|
||||
include $(TOP)/src/tinyusb.mk
|
||||
@ -112,7 +126,7 @@ endif
|
||||
|
||||
# Logger: default is uart, can be set to rtt or swo
|
||||
ifneq ($(LOGGER),)
|
||||
CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
|
||||
CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
|
||||
endif
|
||||
|
||||
ifeq ($(LOGGER),rtt)
|
||||
|
@ -24,7 +24,7 @@ vpath %.c . $(TOP)
|
||||
vpath %.s . $(TOP)
|
||||
vpath %.S . $(TOP)
|
||||
|
||||
include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN)_rules.mk
|
||||
include ${TOP}/examples/build_system/make/toolchain/$(TOOLCHAIN)_rules.mk
|
||||
|
||||
# ---------------------------------------
|
||||
# Compiler Flags
|
||||
|
10
examples/build_system/make/toolchain/arm_clang.mk
Normal file
10
examples/build_system/make/toolchain/arm_clang.mk
Normal file
@ -0,0 +1,10 @@
|
||||
CC = clang
|
||||
CXX = clang++
|
||||
AS = $(CC) -x assembler-with-cpp
|
||||
LD = $(CC)
|
||||
|
||||
GDB = $(CROSS_COMPILE)gdb
|
||||
OBJCOPY = llvm-objcopy
|
||||
SIZE = llvm-size
|
||||
|
||||
include ${TOP}/examples/build_system/make/toolchain/gcc_common.mk
|
@ -12,73 +12,9 @@ GDB = $(CROSS_COMPILE)gdb
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
|
||||
CC_VERSION := $(shell $(CC) -dumpversion)
|
||||
CC_VERSION_MAJOR = $(firstword $(subst ., ,$(CC_VERSION)))
|
||||
|
||||
# ---------------------------------------
|
||||
# Compiler Flags
|
||||
# ---------------------------------------
|
||||
CFLAGS += \
|
||||
-MD \
|
||||
-ggdb \
|
||||
-fdata-sections \
|
||||
-ffunction-sections \
|
||||
-fsingle-precision-constant \
|
||||
-fno-strict-aliasing \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wfatal-errors \
|
||||
-Wdouble-promotion \
|
||||
-Wstrict-prototypes \
|
||||
-Wstrict-overflow \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wunreachable-code \
|
||||
-Wcast-align \
|
||||
-Wcast-function-type \
|
||||
-Wcast-qual \
|
||||
-Wnull-dereference \
|
||||
-Wuninitialized \
|
||||
-Wunused \
|
||||
-Wreturn-type \
|
||||
-Wredundant-decls \
|
||||
|
||||
# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
|
||||
# -Wconversion
|
||||
LIBS += -lgcc -lm -lnosys
|
||||
|
||||
# Size Optimization as default
|
||||
CFLAGS_OPTIMIZED ?= -Os
|
||||
|
||||
# Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0
|
||||
NO_LTO = 1
|
||||
else
|
||||
CFLAGS += $(CFLAGS_OPTIMIZED)
|
||||
endif
|
||||
|
||||
# ---------------------------------------
|
||||
# Linker Flags
|
||||
# ---------------------------------------
|
||||
LDFLAGS += \
|
||||
-Wl,-Map=$@.map \
|
||||
-Wl,-cref \
|
||||
-Wl,-gc-sections \
|
||||
|
||||
# renesas rx does not support --print-memory-usage flags
|
||||
ifneq ($(FAMILY),rx)
|
||||
LDFLAGS += -Wl,--print-memory-usage
|
||||
endif
|
||||
|
||||
# from version 12
|
||||
ifeq ($(strip $(if $(CMDEXE),\
|
||||
$(shell if $(CC_VERSION_MAJOR) geq 12 (echo 1) else (echo 0)),\
|
||||
$(shell expr $(CC_VERSION_MAJOR) \>= 12))), 1)
|
||||
LDFLAGS += -Wl,--no-warn-rwx-segment
|
||||
endif
|
||||
include ${TOP}/examples/build_system/make/toolchain/gcc_common.mk
|
||||
|
1
examples/build_system/make/toolchain/clang_rules.mk
Normal file
1
examples/build_system/make/toolchain/clang_rules.mk
Normal file
@ -0,0 +1 @@
|
||||
include ${TOP}/examples/build_system/make/toolchain/gcc_rules.mk
|
71
examples/build_system/make/toolchain/gcc_common.mk
Normal file
71
examples/build_system/make/toolchain/gcc_common.mk
Normal file
@ -0,0 +1,71 @@
|
||||
# ---------------------------------------
|
||||
# Compiler Flags
|
||||
# ---------------------------------------
|
||||
CFLAGS += \
|
||||
-MD \
|
||||
-ggdb \
|
||||
-fdata-sections \
|
||||
-ffunction-sections \
|
||||
-fno-strict-aliasing \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wfatal-errors \
|
||||
-Wdouble-promotion \
|
||||
-Wstrict-prototypes \
|
||||
-Wstrict-overflow \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wunreachable-code \
|
||||
-Wcast-align \
|
||||
-Wcast-function-type \
|
||||
-Wcast-qual \
|
||||
-Wnull-dereference \
|
||||
-Wuninitialized \
|
||||
-Wunused \
|
||||
-Wreturn-type \
|
||||
-Wredundant-decls \
|
||||
|
||||
# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
|
||||
# -Wconversion
|
||||
|
||||
# Size Optimization as default
|
||||
CFLAGS_OPTIMIZED ?= -Os
|
||||
|
||||
# Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0
|
||||
NO_LTO = 1
|
||||
else
|
||||
CFLAGS += $(CFLAGS_OPTIMIZED)
|
||||
endif
|
||||
|
||||
# ---------------------------------------
|
||||
# Linker Flags
|
||||
# ---------------------------------------
|
||||
LDFLAGS += \
|
||||
-Wl,-Map=$@.map \
|
||||
-Wl,--cref \
|
||||
-Wl,-gc-sections \
|
||||
|
||||
# renesas rx does not support --print-memory-usage flags
|
||||
ifneq ($(FAMILY),rx)
|
||||
LDFLAGS += -Wl,--print-memory-usage
|
||||
endif
|
||||
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CC_VERSION := $(shell $(CC) -dumpversion)
|
||||
CC_VERSION_MAJOR = $(firstword $(subst ., ,$(CC_VERSION)))
|
||||
|
||||
# from version 12
|
||||
ifeq ($(strip $(if $(CMDEXE),\
|
||||
$(shell if $(CC_VERSION_MAJOR) geq 12 (echo 1) else (echo 0)),\
|
||||
$(shell expr $(CC_VERSION_MAJOR) \>= 12))), 1)
|
||||
LDFLAGS += -Wl,--no-warn-rwx-segment
|
||||
endif
|
||||
endif
|
@ -21,8 +21,13 @@ ifneq ($(CFLAGS_SKIP),)
|
||||
CFLAGS := $(filter-out $(CFLAGS_SKIP),$(CFLAGS))
|
||||
endif
|
||||
|
||||
ifeq ($(TOOLCHAIN),clang)
|
||||
LDFLAGS += $(CFLAGS) $(LDFLAGS_CLANG)
|
||||
else
|
||||
LDFLAGS += $(CFLAGS) $(LDFLAGS_GCC)
|
||||
endif
|
||||
|
||||
# TODO should be removed after all examples are updated
|
||||
ifdef LD_FILE
|
||||
LDFLAGS += -Wl,-T,$(TOP)/$(LD_FILE)
|
||||
endif
|
||||
@ -33,11 +38,7 @@ endif
|
||||
|
||||
ASFLAGS += $(CFLAGS)
|
||||
|
||||
LIBS_GCC ?= -lgcc -lm -lnosys
|
||||
|
||||
# libc
|
||||
LIBS += $(LIBS_GCC)
|
||||
|
||||
ifneq ($(BOARD), spresense)
|
||||
LIBS += -lc
|
||||
endif
|
@ -6,7 +6,6 @@ CPU_CORE ?= cortex-m0plus
|
||||
|
||||
CFLAGS += \
|
||||
-flto \
|
||||
-nostdlib -nostartfiles \
|
||||
-DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_SAMD21
|
||||
|
||||
@ -16,7 +15,11 @@ CFLAGS += -Wno-error=redundant-decls
|
||||
# SAM driver is flooded with -Wcast-qual which slow down complication significantly
|
||||
CFLAGS_SKIP += -Wcast-qual
|
||||
|
||||
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
|
||||
LDFLAGS_GCC += \
|
||||
-nostdlib -nostartfiles \
|
||||
-specs=nosys.specs -specs=nano.specs \
|
||||
|
||||
LDFLAGS_CLANG +=
|
||||
|
||||
SRC_C += \
|
||||
src/portable/microchip/samd/dcd_samd.c \
|
||||
|
Loading…
x
Reference in New Issue
Block a user