From 381ff0ad0a67fe74eeb41d4fdfc08de710349fd6 Mon Sep 17 00:00:00 2001 From: Dino Li Date: Wed, 3 Jun 2020 17:07:05 +0800 Subject: riscv-rv32i: Enable FPU extension only if CONFIG_FPU is enabled At default, CONFIG_FPU option isn't enabled. But currently, FPU extension is always enabled when building FW image. This will cause problem if hardware doesn't support the extension and floating-point instructions are generated. So we fix it. BUG=none BRANCH=none TEST=Floating-point instructions are used for floating point operation if CONFIG_FPU is enabled. Otherwise, library routines are used. Signed-off-by: Dino Li Change-Id: Ifb77bd0cca1158ca7f6637fa9ec025ac8712bbfd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2227779 Reviewed-by: Vincent Palatin Commit-Queue: Vincent Palatin --- core/riscv-rv32i/build.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/riscv-rv32i/build.mk b/core/riscv-rv32i/build.mk index c8d7328a3a..a69e2ecafc 100644 --- a/core/riscv-rv32i/build.mk +++ b/core/riscv-rv32i/build.mk @@ -10,8 +10,10 @@ $(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_riscv),\ /opt/coreboot-sdk/bin/riscv64-elf-) +# Enable FPU extension if config option of FPU is enabled. +_FPU_EXTENSION=$(if $(CONFIG_FPU),f,) # CPU specific compilation flags -CFLAGS_CPU+=-march=rv32imafc -mabi=ilp32f -Os +CFLAGS_CPU+=-march=rv32ima$(_FPU_EXTENSION)c -mabi=ilp32$(_FPU_EXTENSION) -Os LDFLAGS_EXTRA+=-mrelax LDFLAGS_EXTRA+=-static-libgcc -lgcc -- cgit v1.2.1