arch/arm: unify compile flags to common/Toolchain.defs

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-09-15 22:06:54 +08:00 committed by Xiang Xiao
parent 0f0a94186f
commit 54aa91f02b
10 changed files with 238 additions and 1302 deletions

View File

@ -1,5 +1,5 @@
############################################################################
# arch/arm/src/armv/Toolchain.defs
# arch/arm/src/arm/Toolchain.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@ -18,165 +18,4 @@
#
############################################################################
# Setup for the selected toolchain
#
# Handle old-style chip-specific toolchain names in the absence of
# a new-style toolchain specification, force the selection of a single
# toolchain and allow the selected toolchain to be overridden by a
# command-line selection.
#
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_BUILDROOT) \
),y)
CONFIG_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_GNU_EABI) \
),y)
CONFIG_TOOLCHAIN ?= GNU_EABI
endif
#
# Supported toolchains
#
# TODO - It's likely that all of these toolchains now support the
# CortexM4. Since they are all GCC-based, we could almost
# certainly simplify this further.
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# FPU options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ARCHOPTIMIZATION += -Os
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif
ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT),y)
CROSSDEV ?= arm-nuttx-eabi-
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT_OABI),y)
CROSSDEV ?= arm-nuttx-elf-
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
CROSSDEV ?= arm-none-eabi-
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHCXXFLAGS += -Wall -Wshadow -Wundef
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# Default toolchain
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
STRIP = $(CROSSDEV)strip --strip-unneeded
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
# Link Time Optimization
ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
LD := $(CROSSDEV)gcc
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fuse-linker-plugin
ARCHOPTIMIZATION += -fno-builtin
endif
endif
# Add the builtin library
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name))
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -18,71 +18,6 @@
#
############################################################################
# Setup for the selected toolchain
#
# Handle old-style chip-specific toolchain names in the absence of
# a new-style toolchain specification, force the selection of a single
# toolchain and allow the selected toolchain to be overridden by a
# command-line selection.
#
ifeq ($(filter y, $(CONFIG_ARM_TOOLCHAIN_BUILDROOT)),y)
CONFIG_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, $(CONFIG_ARM_TOOLCHAIN_GNU_EABI)),y)
CONFIG_TOOLCHAIN ?= GNU_EABI
endif
ifeq ($(filter y, $(CONFIG_ARM_TOOLCHAIN_CLANG)),y)
CONFIG_TOOLCHAIN ?= CLANG
endif
#
# Supported toolchains
#
# TODO - It's likely that all of these toolchains now support the
# CortexM0. Since they are all GCC-based, we could almost
# certainly simplify this further.
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHOPTIMIZATION += -Oz
else
ARCHOPTIMIZATION += -Os
endif
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif
# Parametrization for ARCHCPUFLAGS
TOOLCHAIN_MTUNE := -mcpu=cortex-m0 -mthumb
@ -90,147 +25,8 @@ TOOLCHAIN_MFLOAT := -mfloat-abi=soft
# Clang Configuration files
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
TOOLCHAIN_MARCH := --config armv6m_soft_nofp_nosys
endif
# Link Time Optimization
ifeq ($(CONFIG_LTO_THIN),y)
ARCHOPTIMIZATION += -flto=thin
else ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
ARCHOPTIMIZATION += -fuse-linker-plugin
endif
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_TOOLCHAIN),BUILDROOT)
CROSSDEV ?= arm-nuttx-eabi-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
CROSSDEV ?= arm-none-eabi-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
endif
# Clang toolchain
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
CC = clang
CXX = clang++
CPP = clang -E -P -x c
LD = ld.lld -m armelf
STRIP = llvm-strip --strip-unneeded
AR = llvm-ar rcs
NM = llvm-nm
OBJCOPY = llvm-objcopy
OBJDUMP = llvm-objdump
# Since the no_builtin attribute is not fully supported on Clang
# disable the built-in functions, refer:
# https://github.com/apache/incubator-nuttx/pull/5971
ARCHOPTIMIZATION += -fno-builtin
# Default toolchain
else
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
STRIP = $(CROSSDEV)strip --strip-unneeded
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
ifeq ($(CONFIG_LTO_FULL),y)
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
LD := $(CROSSDEV)gcc
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fno-builtin
endif
endif
endif
# Architecture flags
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif
ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHCXXFLAGS += -Wall -Wshadow -Wundef
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# Add the builtin library
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(wildcard $(COMPILER_RT_LIB)),)
# if "--print-libgcc-file-name" unable to find the correct libgcc PATH
# then go ahead and try "--print-file-name"
COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB))))
endif
endif
EXTRA_LIBS += $(COMPILER_RT_LIB)
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -18,41 +18,6 @@
#
############################################################################
# Setup for the selected toolchain
#
# Select and allow the selected toolchain to be overridden by a command-line
#selection.
#
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_BUILDROOT) \
),y)
CONFIG_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_GNU_EABI) \
),y)
CONFIG_TOOLCHAIN ?= GNU_EABI
endif
#
# Supported toolchains
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# FPU options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_ARM_THUMB),y)
ARCHCPUFLAGS += -mthumb
endif
ifeq ($(CONFIG_ARCH_CORTEXA5),y)
ARCHCPUFLAGS += -mcpu=cortex-a5
else ifeq ($(CONFIG_ARCH_CORTEXA7),y)
@ -96,134 +61,4 @@ else
ARCHCPUFLAGS += -mfloat-abi=soft
endif
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ARCHOPTIMIZATION += -Os
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif
ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
endif
ifeq ($(CONFIG_ENDIAN_BIG),y)
TARGET_ARCH := armeb
else
TARGET_ARCH := arm
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHCXXFLAGS += -Wall -Wshadow -Wundef
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT),y)
CROSSDEV ?= $(TARGET_ARCH)-nuttx-eabi-
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT_OABI),y)
CROSSDEV ?= $(TARGET_ARCH)-nuttx-elf-
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
CROSSDEV ?= $(TARGET_ARCH)-none-eabi-
endif
# Default toolchain
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
STRIP = $(CROSSDEV)strip --strip-unneeded
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
# Link Time Optimization
ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
LD := $(CROSSDEV)gcc
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fuse-linker-plugin
ARCHOPTIMIZATION += -fno-builtin
endif
endif
# Add the builtin library
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name))
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -18,85 +18,6 @@
#
############################################################################
# Setup for the selected toolchain
#
# Handle old-style chip-specific toolchain names in the absence of
# a new-style toolchain specification, force the selection of a single
# toolchain and allow the selected toolchain to be overridden by a
# command-line selection.
#
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_BUILDROOT) \
),y)
CONFIG_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_GNU_EABI) \
),y)
CONFIG_TOOLCHAIN ?= GNU_EABI
endif
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_CLANG) \
),y)
CONFIG_TOOLCHAIN ?= CLANG
endif
#
# Supported toolchains
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# FPU options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHOPTIMIZATION += -Oz
else
ARCHOPTIMIZATION += -Os
endif
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif
ifeq ($(CONFIG_ARMV7M_STACKCHECK),y)
ARCHOPTIMIZATION += -finstrument-functions -ffixed-r10
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif
ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
endif
# Parametrization for ARCHCPUFLAGS
ifeq ($(CONFIG_ARCH_CORTEXM4),y)
@ -136,7 +57,7 @@ endif
# Clang Configuration files
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
ifeq ($(CONFIG_ARCH_CORTEXM4),y)
ifeq ($(CONFIG_ARCH_FPU),y)
@ -156,140 +77,8 @@ ifeq ($(CONFIG_TOOLCHAIN),CLANG)
endif
# Link Time Optimization
ifeq ($(CONFIG_LTO_THIN),y)
ARCHOPTIMIZATION += -flto=thin
else ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
ARCHOPTIMIZATION += -fuse-linker-plugin
endif
ifeq ($(CONFIG_ARMV7M_STACKCHECK),y)
ARCHOPTIMIZATION += -finstrument-functions -ffixed-r10
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT),y)
CROSSDEV ?= arm-nuttx-eabi-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) -mthumb $(TOOLCHAIN_MFLOAT)
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT_OABI),y)
CROSSDEV ?= arm-nuttx-elf-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
endif
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
CROSSDEV ?= arm-none-eabi-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) -mthumb $(TOOLCHAIN_MFLOAT)
endif
# Clang toolchain
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
CC = clang
CXX = clang++
CPP = clang -E -P -x c
LD = ld.lld -m armelf
STRIP = llvm-strip --strip-unneeded
AR = llvm-ar rcs
NM = llvm-nm
OBJCOPY = llvm-objcopy
OBJDUMP = llvm-objdump
# Since the no_builtin attribute is not fully supported on Clang
# disable the built-in functions, refer:
# https://github.com/apache/incubator-nuttx/pull/5971
ARCHOPTIMIZATION += -fno-builtin
# Default toolchain
else
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
STRIP = $(CROSSDEV)strip --strip-unneeded
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
ifeq ($(CONFIG_LTO_FULL),y)
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
LD := $(CROSSDEV)gcc
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fno-builtin
endif
endif
endif
# Architecture flags
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHCXXFLAGS += -Wall -Wshadow -Wundef
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# Add the builtin library
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(wildcard $(COMPILER_RT_LIB)),)
# if "--print-libgcc-file-name" unable to find the correct libgcc PATH
# then go ahead and try "--print-file-name"
COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB))))
endif
endif
EXTRA_LIBS += $(COMPILER_RT_LIB)
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -18,61 +18,6 @@
#
############################################################################
# Setup for the selected toolchain
#
# Select and allow the selected toolchain to be overridden by a command-line
#selection.
#
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_BUILDROOT) \
),y)
CONFIG_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_GNU_EABI) \
),y)
CONFIG_TOOLCHAIN ?= GNU_EABI
endif
#
# Supported toolchains
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# FPU options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ARCHOPTIMIZATION += -Os
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif
ifeq ($(CONFIG_ARCH_CORTEXR4),y)
ARCHCPUFLAGS += -mcpu=cortex-r4
else ifeq ($(CONFIG_ARCH_CORTEXR5),y)
@ -92,114 +37,4 @@ else
ARCHCPUFLAGS += -mfloat-abi=soft
endif
ifeq ($(CONFIG_ENDIAN_BIG),y)
ARCHCPUFLAGS += -mbig-endian
endif
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif
ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
endif
ifeq ($(CONFIG_ENDIAN_BIG),y)
TARGET_ARCH := armeb
else
TARGET_ARCH := arm
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT),y)
CROSSDEV ?= $(TARGET_ARCH)-nuttx-eabi-
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT_OABI),y)
CROSSDEV ?= $(TARGET_ARCH)-nuttx-elf-
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
CROSSDEV ?= $(TARGET_ARCH)-none-eabi-
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHCXXFLAGS += -Wall -Wshadow -Wundef
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# Default toolchain
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
STRIP = $(CROSSDEV)strip --strip-unneeded
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
# Link Time Optimization
ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
LD := $(CROSSDEV)gcc
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fuse-linker-plugin
ARCHOPTIMIZATION += -fno-builtin
endif
endif
# Add the builtin library
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name))
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -18,85 +18,6 @@
#
############################################################################
# Setup for the selected toolchain
#
# Handle old-style chip-specific toolchain names in the absence of
# a new-style toolchain specification, force the selection of a single
# toolchain and allow the selected toolchain to be overridden by a
# command-line selection.
#
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_BUILDROOT) \
),y)
CONFIG_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_GNU_EABI) \
),y)
CONFIG_TOOLCHAIN ?= GNU_EABI
endif
ifeq ($(filter y, \
$(CONFIG_ARM_TOOLCHAIN_CLANG) \
),y)
CONFIG_TOOLCHAIN ?= CLANG
endif
#
# Supported toolchains
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# FPU options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHOPTIMIZATION += -Oz
else
ARCHOPTIMIZATION += -Os
endif
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif
ifeq ($(CONFIG_ARMV8M_STACKCHECK),y)
ARCHOPTIMIZATION += -finstrument-functions -ffixed-r10
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif
ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
endif
# Parametrization for ARCHCPUFLAGS
ifeq ($(CONFIG_ARCH_CORTEXM23),y)
@ -139,7 +60,7 @@ endif
# Clang Configuration files
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
ifeq ($(CONFIG_ARCH_CORTEXM23),y)
TOOLCHAIN_MARCH += --config armv8m.main_soft_nofp_nosys
@ -165,140 +86,8 @@ ifeq ($(CONFIG_TOOLCHAIN),CLANG)
endif
# Link Time Optimization
ifeq ($(CONFIG_LTO_THIN),y)
ARCHOPTIMIZATION += -flto=thin
else ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
ARCHOPTIMIZATION += -fuse-linker-plugin
endif
ifeq ($(CONFIG_ARMV8M_STACKCHECK),y)
ARCHOPTIMIZATION += -finstrument-functions -ffixed-r10
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT),y)
CROSSDEV ?= arm-nuttx-eabi-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) -mthumb $(TOOLCHAIN_MFLOAT)
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT_OABI),y)
CROSSDEV ?= arm-nuttx-elf-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
endif
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
CROSSDEV ?= arm-none-eabi-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) -mthumb $(TOOLCHAIN_MFLOAT)
endif
# Clang toolchain
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) -mthumb $(TOOLCHAIN_MFLOAT)
CC = clang
CXX = clang++
CPP = clang -E -P -x c
LD = ld.lld -m armelf
STRIP = llvm-strip --strip-unneeded
AR = llvm-ar rcs
NM = llvm-nm
OBJCOPY = llvm-objcopy
OBJDUMP = llvm-objdump
# Since the no_builtin attribute is not fully supported on Clang
# disable the built-in functions, refer:
# https://github.com/apache/incubator-nuttx/pull/5971
ARCHOPTIMIZATION += -fno-builtin
# Default toolchain
else
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
LD = $(CROSSDEV)ld
STRIP = $(CROSSDEV)strip --strip-unneeded
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ifeq ($(CONFIG_LTO_FULL),y)
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
LD := $(CROSSDEV)gcc
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fno-builtin
endif
endif
endif
# Architecture flags
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHCXXFLAGS += -Wall -Wshadow -Wundef
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# Add the builtin library
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(wildcard $(COMPILER_RT_LIB)),)
# if "--print-libgcc-file-name" unable to find the correct libgcc PATH
# then go ahead and try "--print-file-name"
COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB))))
endif
endif
EXTRA_LIBS += $(COMPILER_RT_LIB)
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -0,0 +1,219 @@
############################################################################
# arch/arm/src/armv8-m/Toolchain.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
#
# Supported toolchains
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# FPU options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHOPTIMIZATION += -Oz
else
ARCHOPTIMIZATION += -Os
endif
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif
ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif
ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
ARCHOPTIMIZATION += -fsanitize-undefined-trap-on-error
endif
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
ifeq ($(CONFIG_ARM_THUMB),y)
ARCHOPTIMIZATION += -mthumb
endif
# Link Time Optimization
ifeq ($(CONFIG_LTO_THIN),y)
ARCHOPTIMIZATION += -flto=thin
else ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_ARM_TOOLCHAIN_GNU_EABI),y)
ARCHOPTIMIZATION += -fuse-linker-plugin
endif
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_ENDIAN_BIG),y)
ARCHCPUFLAGS += -mbig-endian
TARGET_ARCH := armeb
else
ARCHCPUFLAGS += -mlittle-endian
TARGET_ARCH := arm
endif
ARCHCPUFLAGS += $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT),y)
CROSSDEV ?= $(TARGET_ARCH)-nuttx-eabi-
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_BUILDROOT_OABI),y)
CROSSDEV ?= $(TARGET_ARCH)-nuttx-elf-
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_ARM_TOOLCHAIN_GNU_EABI),y)
CROSSDEV ?= $(TARGET_ARCH)-none-eabi-
endif
# Clang toolchain
ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
CC = clang
CXX = clang++
CPP = clang -E -P -x c
LD = ld.lld -m armelf
STRIP = llvm-strip --strip-unneeded
AR = llvm-ar rcs
NM = llvm-nm
OBJCOPY = llvm-objcopy
OBJDUMP = llvm-objdump
# Since the no_builtin attribute is not fully supported on Clang
# disable the built-in functions, refer:
# https://github.com/apache/incubator-nuttx/pull/5971
ARCHOPTIMIZATION += -fno-builtin
# Default toolchain
else
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
LD = $(CROSSDEV)ld
STRIP = $(CROSSDEV)strip --strip-unneeded
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ifeq ($(CONFIG_LTO_FULL),y)
ifeq ($(CONFIG_ARM_TOOLCHAIN_GNU_EABI),y)
LD := $(CROSSDEV)gcc
AR := $(CROSSDEV)gcc-ar rcs
NM := $(CROSSDEV)gcc-nm
ARCHOPTIMIZATION += -fno-builtin
endif
endif
endif
ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHOPTIMIZATION += -fshort-enums
endif
# Architecture flags
ARCHCFLAGS += -Wstrict-prototypes
ARCHCXXFLAGS += -nostdinc++
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
ARCHOPTIMIZATION += -fno-common -Wall -Wshadow -Wundef
ARCHOPTIMIZATION += -nostdlib
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# Add the builtin library
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ifeq ($(wildcard $(COMPILER_RT_LIB)),)
# if "--print-libgcc-file-name" unable to find the correct libgcc PATH
# then go ahead and try "--print-file-name"
COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB))))
endif
endif
EXTRA_LIBS += $(COMPILER_RT_LIB)
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
ifeq ($(CONFIG_ARCH_COVERAGE),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif

View File

@ -18,182 +18,16 @@
#
############################################################################
# Setup for the selected toolchain
#
# Handle old-style chip-specific toolchain names in the absence of
# a new-style toolchain specification, force the selection of a single
# toolchain and allow the selected toolchain to be overridden by a
# command-line selection.
#
ifeq ($(filter y, $(CONFIG_ARM_TOOLCHAIN_BUILDROOT)),y)
CONFIG_TOOLCHAIN ?= BUILDROOT
endif
ifeq ($(filter y, $(CONFIG_ARM_TOOLCHAIN_GNU_EABI)),y)
CONFIG_TOOLCHAIN ?= GNU_EABI
endif
ifeq ($(filter y, $(CONFIG_ARM_TOOLCHAIN_CLANG)),y)
CONFIG_TOOLCHAIN ?= CLANG
endif
#
# Supported toolchains
#
# Each toolchain definition should set:
#
# CROSSDEV The GNU toolchain triple (command prefix)
# ARCHCPUFLAGS CPU-specific flags selecting the instruction set
# options, etc.
# ARCHOPTIMIZATION The optimization level that results in
# reliable code generation.
#
ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHOPTIMIZATION += -Oz
else
ARCHOPTIMIZATION += -Os
endif
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += -fno-strict-aliasing
endif
ifeq ($(CONFIG_FRAME_POINTER),y)
ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls
else
ARCHOPTIMIZATION += -fomit-frame-pointer
endif
ifeq ($(CONFIG_STACK_CANARIES),y)
ARCHOPTIMIZATION += -fstack-protector-all
endif
# Clang Configuration files
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
TOOLCHAIN_MARCH := --config armv6m_soft_nofp_nosys
endif
# Link Time Optimization
ifeq ($(CONFIG_LTO_THIN),y)
ARCHOPTIMIZATION += -flto=thin
else ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
endif
# NuttX buildroot under Linux or Cygwin
ifeq ($(CONFIG_TOOLCHAIN),BUILDROOT)
CROSSDEV ?= arm-nuttx-eabi-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
endif
# Generic GNU EABI toolchain
ifeq ($(CONFIG_TOOLCHAIN),GNU_EABI)
ifeq ($(CONFIG_ARM_TOOLCHAIN_GNU_EABI),y)
CROSSDEV ?= tc32-elf-
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
endif
# Clang toolchain
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT)
CC = clang
CXX = clang++
CPP = clang -E -P -x c
LD = ld.lld -m armelf
STRIP = llvm-strip --strip-unneeded
AR = llvm-ar rcs
NM = llvm-nm
OBJCOPY = llvm-objcopy
OBJDUMP = llvm-objdump
# Since the no_builtin attribute is not fully supported on Clang
# disable the built-in functions, refer:
# https://github.com/apache/incubator-nuttx/pull/5971
ARCHOPTIMIZATION += -fno-builtin
# Default toolchain
else
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E -P -x c
LD = $(CROSSDEV)ld
STRIP = $(CROSSDEV)strip --strip-unneeded
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
endif
# Architecture flags
ifeq ($(CONFIG_MM_KASAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=kernel-address
endif
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common -nostdinc++
ARCHCFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHCXXFLAGS += -Wall -Wshadow -Wundef
ifneq ($(CONFIG_CXX_EXCEPTION),y)
ARCHCXXFLAGS += -fno-exceptions -fcheck-new
endif
ifneq ($(CONFIG_CXX_RTTI),y)
ARCHCXXFLAGS += -fno-rtti
endif
LDFLAGS += -nostdlib
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
endif
# Add the builtin library
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
ifeq ($(CONFIG_TOOLCHAIN),CLANG)
ifeq ($(wildcard $(COMPILER_RT_LIB)),)
# if "--print-libgcc-file-name" unable to find the correct libgcc PATH
# then go ahead and try "--print-file-name"
COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB))))
endif
endif
EXTRA_LIBS += $(COMPILER_RT_LIB)
ifneq ($(CONFIG_LIBM),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a))
endif
ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -27,7 +27,7 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
ifneq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -funwind-tables
ARCHCXXFLAGS += -funwind-tables
endif

View File

@ -27,7 +27,7 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
ifneq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
ifneq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHCFLAGS += -funwind-tables
ARCHCXXFLAGS += -funwind-tables
endif