From f8a36f10c3d3106d35684b6bd191450f56593725 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Fri, 23 Apr 2021 17:57:02 -0300 Subject: [PATCH] arch: Uniformize optimization flag setting across architectures --- arch/arm/src/arm/Toolchain.defs | 4 ++-- arch/arm/src/armv6-m/Toolchain.defs | 7 ++----- arch/arm/src/armv7-a/Toolchain.defs | 4 ++-- arch/arm/src/armv7-m/Toolchain.defs | 5 ++--- arch/arm/src/armv7-r/Toolchain.defs | 4 ++-- arch/arm/src/armv8-m/Toolchain.defs | 5 ++--- arch/avr/src/avr/Toolchain.defs | 6 ++---- arch/misoc/src/lm32/Toolchain.defs | 4 ++-- arch/misoc/src/minerva/Toolchain.defs | 6 ++++-- arch/or1k/src/mor1kx/Toolchain.defs | 3 ++- arch/risc-v/src/rv64gc/Toolchain.defs | 9 ++------- arch/xtensa/src/lx6/Toolchain.defs | 2 +- 12 files changed, 25 insertions(+), 34 deletions(-) diff --git a/arch/arm/src/arm/Toolchain.defs b/arch/arm/src/arm/Toolchain.defs index 0997ffeae0..ca842ea6da 100644 --- a/arch/arm/src/arm/Toolchain.defs +++ b/arch/arm/src/arm/Toolchain.defs @@ -63,6 +63,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # NuttX buildroot under Linux or Cygwin @@ -73,14 +75,12 @@ ifeq ($(CONFIG_ARM_OABI_TOOLCHAIN),y) else CROSSDEV ?= arm-nuttx-eabi- endif - MAXOPTIMIZATION ?= -Os endif # Generic GNU EABI toolchain ifeq ($(CONFIG_ARM_TOOLCHAIN),GNU_EABI) CROSSDEV ?= arm-none-eabi- - MAXOPTIMIZATION ?= -Os endif # Default toolchain diff --git a/arch/arm/src/armv6-m/Toolchain.defs b/arch/arm/src/armv6-m/Toolchain.defs index 3684668f2c..d154b1cf01 100644 --- a/arch/arm/src/armv6-m/Toolchain.defs +++ b/arch/arm/src/armv6-m/Toolchain.defs @@ -57,6 +57,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # NuttX buildroot under Linux or Cygwin @@ -73,11 +75,6 @@ ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),GNU_EABI) ARCHCPUFLAGS = -mcpu=cortex-m0 -mthumb -mfloat-abi=soft endif -# Individual tools may limit the optimizatin level but, by default, the -# optimization level will be set to -Os - -MAXOPTIMIZATION ?= -Os - # Default toolchain CC = $(CROSSDEV)gcc diff --git a/arch/arm/src/armv7-a/Toolchain.defs b/arch/arm/src/armv7-a/Toolchain.defs index 21aeca56ef..3550536479 100644 --- a/arch/arm/src/armv7-a/Toolchain.defs +++ b/arch/arm/src/armv7-a/Toolchain.defs @@ -75,6 +75,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif ifeq ($(CONFIG_ENDIAN_BIG),y) @@ -91,14 +93,12 @@ ifeq ($(CONFIG_ARMV7A_OABI_TOOLCHAIN),y) else CROSSDEV ?= $(TARGET_ARCH)-nuttx-eabi- endif - MAXOPTIMIZATION ?= -Os endif # Generic GNU EABI toolchain ifeq ($(CONFIG_ARMV7A_TOOLCHAIN),GNU_EABI) CROSSDEV ?= $(TARGET_ARCH)-none-eabi- - MAXOPTIMIZATION ?= -Os endif # Default toolchain diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index 3745142872..7f5626bfdc 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -71,6 +71,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # Parametrization for ARCHCPUFLAGS @@ -117,14 +119,12 @@ else CROSSDEV ?= arm-nuttx-eabi- ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) endif - MAXOPTIMIZATION ?= -Os endif # Generic GNU EABI toolchain ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),GNU_EABI) CROSSDEV ?= arm-none-eabi- - MAXOPTIMIZATION ?= -Os ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) endif @@ -132,7 +132,6 @@ endif ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANG) CROSSDEV ?= arm-none-eabi- - MAXOPTIMIZATION ?= -Os ARCHCPUFLAGS = -target arm-none-eabi $(TOOLCHAIN_MCPU) $(TOOLCHAIN_MFLOAT) CC = clang CXX = clang++ diff --git a/arch/arm/src/armv7-r/Toolchain.defs b/arch/arm/src/armv7-r/Toolchain.defs index be48f2d8b8..1bedd899d3 100644 --- a/arch/arm/src/armv7-r/Toolchain.defs +++ b/arch/arm/src/armv7-r/Toolchain.defs @@ -57,6 +57,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif ifeq ($(CONFIG_ENDIAN_BIG),y) @@ -73,14 +75,12 @@ ifeq ($(CONFIG_ARMV7R_OABI_TOOLCHAIN),y) else CROSSDEV ?= $(TARGET_ARCH)-nuttx-eabi- endif - MAXOPTIMIZATION ?= -Os endif # Generic GNU EABI toolchain ifeq ($(CONFIG_ARMV7R_TOOLCHAIN),GNU_EABI) CROSSDEV ?= $(TARGET_ARCH)-none-eabi- - MAXOPTIMIZATION ?= -Os endif # Default toolchain diff --git a/arch/arm/src/armv8-m/Toolchain.defs b/arch/arm/src/armv8-m/Toolchain.defs index 0ccad3895b..4a76b53924 100644 --- a/arch/arm/src/armv8-m/Toolchain.defs +++ b/arch/arm/src/armv8-m/Toolchain.defs @@ -71,6 +71,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # Parametrization for ARCHCPUFLAGS @@ -107,14 +109,12 @@ else CROSSDEV ?= arm-nuttx-eabi- ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) endif - MAXOPTIMIZATION ?= -Os endif # Generic GNU EABI toolchain ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),GNU_EABI) CROSSDEV ?= arm-none-eabi- - MAXOPTIMIZATION ?= -Os ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) endif @@ -122,7 +122,6 @@ endif ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),CLANG) CROSSDEV ?= arm-none-eabi- - MAXOPTIMIZATION ?= -Os ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) endif diff --git a/arch/avr/src/avr/Toolchain.defs b/arch/avr/src/avr/Toolchain.defs index 74e93a8cfe..493bdc0af1 100644 --- a/arch/avr/src/avr/Toolchain.defs +++ b/arch/avr/src/avr/Toolchain.defs @@ -86,13 +86,14 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -O2 endif # NuttX buildroot GCC toolchain under Linux or Cygwin ifeq ($(CONFIG_AVR_TOOLCHAIN),BUILDROOT) CROSSDEV ?= avr-nuttx-elf- - MAXOPTIMIZATION ?= -O2 LDFLAGS += -nostartfiles -nodefaultlibs endif @@ -100,7 +101,6 @@ endif ifeq ($(CONFIG_AVR_TOOLCHAIN),CROSSPACK) CROSSDEV ?= avr- - MAXOPTIMIZATION ?= -O2 LDFLAGS += -nostartfiles -nodefaultlibs endif @@ -108,13 +108,11 @@ endif ifeq ($(CONFIG_AVR_TOOLCHAIN),LINUXGCC) CROSSDEV ?= avr- - MAXOPTIMIZATION ?= -O2 LDFLAGS += -nostartfiles -nodefaultlibs endif ifeq ($(CONFIG_AVR_TOOLCHAIN),WINAVR) CROSSDEV ?= avr- - MAXOPTIMIZATION ?= -O2 LDFLAGS += -nostartfiles -nodefaultlibs endif diff --git a/arch/misoc/src/lm32/Toolchain.defs b/arch/misoc/src/lm32/Toolchain.defs index 5e264e833e..79961f338b 100644 --- a/arch/misoc/src/lm32/Toolchain.defs +++ b/arch/misoc/src/lm32/Toolchain.defs @@ -57,20 +57,20 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # NuttX buildroot under Linux or Cygwin ifeq ($(CONFIG_LM32_TOOLCHAIN),BUILDROOT) CROSSDEV ?= lm32-nuttx-elf- - MAXOPTIMIZATION ?= -Os endif # Generic GNU toolchain ifeq ($(CONFIG_LM32_TOOLCHAIN),GNUL) CROSSDEV ?= lm32-elf- - MAXOPTIMIZATION ?= -Os endif # Default toolchain diff --git a/arch/misoc/src/minerva/Toolchain.defs b/arch/misoc/src/minerva/Toolchain.defs index fc223bcbae..a90f39bdc3 100644 --- a/arch/misoc/src/minerva/Toolchain.defs +++ b/arch/misoc/src/minerva/Toolchain.defs @@ -21,8 +21,10 @@ CROSSDEV = riscv32-unknown-elf- ARCHCPUFLAGS = -march=rv32i -ifeq ($(CONFIG_DEBUG_SYMBOLS),) -MAXOPTIMIZATION ?= -Os +ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) + MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # Default toolchain diff --git a/arch/or1k/src/mor1kx/Toolchain.defs b/arch/or1k/src/mor1kx/Toolchain.defs index 95fe2ceeee..68b7bc7f21 100644 --- a/arch/or1k/src/mor1kx/Toolchain.defs +++ b/arch/or1k/src/mor1kx/Toolchain.defs @@ -49,6 +49,8 @@ ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -O2 endif # Pick correct or1k architecture selection @@ -61,7 +63,6 @@ endif #ifeq ($(CONFIG_OR1K_TOOLCHAIN),GNU_ELF) CROSSDEV ?= or1k-elf- -MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mboard=de0_nano ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs diff --git a/arch/risc-v/src/rv64gc/Toolchain.defs b/arch/risc-v/src/rv64gc/Toolchain.defs index 9614a4d323..479ec25352 100644 --- a/arch/risc-v/src/rv64gc/Toolchain.defs +++ b/arch/risc-v/src/rv64gc/Toolchain.defs @@ -49,6 +49,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # Generic GNU RVG toolchain @@ -57,13 +59,6 @@ ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG) CROSSDEV ?= riscv64-unknown-elf- endif -# Individual tools may limit the optimization level but, by default, the -# optimization level will be set to -Os - -ifeq ($(CONFIG_DEBUG_SYMBOLS),) -MAXOPTIMIZATION ?= -Os -endif - # Default toolchain CC = $(CROSSDEV)gcc diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index 72181b673f..525cb4f481 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -36,7 +36,7 @@ ARCHCPUFLAGS = ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) else - MAXOPTIMIZATION := -Os + MAXOPTIMIZATION ?= -Os endif # Default toolchain