arm/armlink: add support of link time optimization(lto)

Optimization goal(Code size)

Smaller                           GCC(-Os) GCC(-flto -Os) CLANG(-flto -Oz) ARMCLANG(-flto -Oz/-Omin)
lm3s6965-ek/qemu-flat(Cortex-M3)   208662      193893           199525             195464
                                               -7.07%           -4.37%             -6.32%
sabre-6quad/smp(Cortex-A9)         131360      122500            N/A               123988
                                               -6.74%            N/A               -5.61%

Faster performance                GCC(-O3) GCC(-flto -O3) CLANG(-flto -Ofast) ARMCLANG(-flto -Ofast) ARMCLANG(-flto -Omax)
lm3s6965-ek/qemu-flat(Cortex-M3)   257502      296364           369465             346696                  384204
                                              +15.00%          +43.40%            +34.60%                 +49.20%
sabre-6quad/smp(Cortex-A9)         166520      196004             N/A              207908                  224140
                                              +17.70%             N/A             +24.85%                 +34.60%

Reference:
https://developer.arm.com/documentation/101754/0618/armclang-Reference/armclang-Command-line-Options/-O--armclang-

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-09-26 13:55:24 +08:00 committed by Xiang Xiao
parent 40ef5bc6db
commit a2cd1b0db3
2 changed files with 10 additions and 3 deletions

View File

@ -78,11 +78,17 @@ endif
ifeq ($(CONFIG_LTO_THIN),y)
ARCHOPTIMIZATION += -flto=thin
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --lto
endif
else ifeq ($(CONFIG_LTO_FULL),y)
ARCHOPTIMIZATION += -flto
ifeq ($(CONFIG_ARM_TOOLCHAIN_GNU_EABI),y)
ARCHOPTIMIZATION += -fuse-linker-plugin
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --lto
endif
endif
# NuttX buildroot under Linux or Cygwin
@ -220,9 +226,10 @@ ifneq ($(CONFIG_CXX_RTTI),y)
endif
ARCHOPTIMIZATION += -fno-common -Wall -Wshadow -Wundef
ARCHOPTIMIZATION += -nostdlib
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),)
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
ARCHOPTIMIZATION += -nostdlib
else
LDFLAGS += -nostdlib
endif

View File

@ -101,7 +101,7 @@ OSCRAM_SECTIONS DDR3_START DDR3_SIZE
CONSTRUCTORS
}
bss AlignExpr(ImageLimit(data), 0x8)
bss AlignExpr(ImageLimit(data), 0x10)
{
*(.bss)
*(.bss.*)