From c2d26988fd417c6481907c8b2644b40371b59da3 Mon Sep 17 00:00:00 2001 From: guoshichao Date: Mon, 22 Jul 2024 17:19:33 +0800 Subject: [PATCH] greenhills: fix double-precision float operation running error since not all Armv7-m platform support double-precision floating operations, so we add an extra option that help those specific platform could define the single-precision floating operations. for example, qemu-mps platform(armv7-m) support double-precision floating operations, so we do not need to open CONFIG_ARM_FPU_SINGLE_HARDWARE build options; but for fc7300 platform(armv7-m) only support single-precision floating operations, so if we pass "-fhard" build option to "ghs" compiler, then the following instruction will be generated: vcvt.f64.s32 d9, s18 which will fail to execute on fc7300 platform. with "-fsingle" build option, the "ghs" compiler will generate hardware instruction for single-precision floating operation, and generate software instruction for double-precision floating operation. Signed-off-by: guoshichao --- arch/arm/src/armv7-m/Toolchain.defs | 4 +++- arch/arm/src/common/Toolchain.defs | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index 039ad179f77..1b33e9c9b6a 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -64,8 +64,10 @@ ifeq ($(CONFIG_ARCH_FPU),y) ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),y) ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y) TOOLCHAIN_MFLOAT += -fsoft - else + else ifeq ($(CONFIG_ARCH_DPFPU),y) TOOLCHAIN_MFLOAT += -fhard + else + TOOLCHAIN_MFLOAT += -fsingle endif else ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index b4ca0a06bdd..7950b2e034e 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -416,8 +416,10 @@ else ifeq ($(CONFIG_ARCH_TOOLCHAIN_GHS),y) ifeq ($(CONFIG_ARCH_FPU),y) ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y) COMPILER_RT_LIB += -l$(GHS_ROOT_PATH)/lib/thumb2/libind_sf - else + else ifeq ($(CONFIG_ARCH_DPFPU),y) COMPILER_RT_LIB += -l$(GHS_ROOT_PATH)/lib/thumb2/libind_fp + else + COMPILER_RT_LIB += -l$(GHS_ROOT_PATH)/lib/thumb2/libind_sd endif else COMPILER_RT_LIB += -l$(GHS_ROOT_PATH)/lib/thumb2/libind_sf @@ -427,7 +429,21 @@ endif EXTRA_LIBS += $(COMPILER_RT_LIB) ifeq ($(CONFIG_LIBM_TOOLCHAIN),y) - EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) + ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),y) + ifeq ($(CONFIG_ARCH_FPU),y) + ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y) + EXTRA_LIBS += -l$(GHS_ROOT_PATH)/lib/thumb2/libmath_sf + else ifeq ($(CONFIG_ARCH_DPFPU),y) + EXTRA_LIBS += -l$(GHS_ROOT_PATH)/lib/thumb2/libmath_fp + else + EXTRA_LIBS += -l$(GHS_ROOT_PATH)/lib/thumb2/libmath_sd + endif + else + EXTRA_LIBS += -l$(GHS_ROOT_PATH)/lib/thumb2/libmath_sf + endif + else + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) + endif endif ifeq ($(CONFIG_LIBSUPCXX),y)