From a0be010122974a3d05a5db3a77171f2118df3c7b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 10 Jun 2022 08:57:07 -0700 Subject: core/cortex-m: Set FPU to auto Use "-mfpu=auto" so that the compiler will choose the correct FPU settings based on the settings of -mcpu and -march: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html. According to the above doc "-mfpu=auto" is the default and shouldn't be required, but compilation using gcc fails without the flag. clang does not support the "-mfpu=auto" flag, but will choose the correct floating point unit based on the -mcpu flag: https://lists.llvm.org/pipermail/llvm-dev/2018-September/126468.html BRANCH=none BUG=b:145677491, b:234181908 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes Change-Id: I3c255ee53e31763d29dfb2086fcebf3d8290dc56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3699793 Reviewed-by: Andrea Grandi --- core/cortex-m/build.mk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/cortex-m/build.mk b/core/cortex-m/build.mk index 489990ec7a..cab5fab0f4 100644 --- a/core/cortex-m/build.mk +++ b/core/cortex-m/build.mk @@ -12,7 +12,19 @@ $(call set-option,CROSS_COMPILE,\ /opt/coreboot-sdk/bin/arm-eabi-) # FPU compilation flags -CFLAGS_FPU-$(CONFIG_FPU)=-mfpu=fpv4-sp-d16 -mfloat-abi=hard +CFLAGS_FPU-$(CONFIG_FPU)=-mfloat-abi=hard +ifeq ($(cc-name),gcc) +# -mfpu=auto will choose correct hardware based on settings of -mcpu and -march +# https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html. +# +# According to the above doc "-mfpu=auto" is the default and shouldn't be +# required, but compilation using gcc fails without the flag. +# +# clang does not support "-mfpu=auto" flag, but will choose the correct floating +# point unit based on the -mcpu flag: +# https://lists.llvm.org/pipermail/llvm-dev/2018-September/126468.html +CFLAGS_FPU-$(CONFIG_FPU)+=-mfpu=auto +endif # CPU specific compilation flags CFLAGS_CPU+=-mthumb -- cgit v1.2.1