Bug 1463036 - Add -mfloat-abi=softfp to NEON_FLAGS when it makes sense. r?build draft
authorMike Hommey <mh@glandium.org>
Mon, 21 May 2018 12:14:06 +0900
changeset 797678 550b0e2c2073fff45877eb22449d68932cffdf33
parent 797634 94f21505ff13cd089f7129cd24927cf8b31a0f43
push id110534
push userbmo:mh+mozilla@glandium.org
push dateMon, 21 May 2018 11:32:54 +0000
reviewersbuild
bugs1463036, 1199974
milestone62.0a1
Bug 1463036 - Add -mfloat-abi=softfp to NEON_FLAGS when it makes sense. r?build This is similar to what is done for VPX_ASFLAGS (bug 1199974).
build/autoconf/arch.m4
--- a/build/autoconf/arch.m4
+++ b/build/autoconf/arch.m4
@@ -237,16 +237,34 @@ if test "$CPU_ARCH" = "arm"; then
               BUILD_ARM_NEON=
           else
               AC_DEFINE(BUILD_ARM_NEON)
               BUILD_ARM_NEON=1
           fi
       fi
   fi
 
+  dnl Building with -mfpu=neon requires either the "softfp" or the
+  dnl "hardfp" ABI. Depending on the compiler's default target, and the
+  dnl CFLAGS, the default ABI might be neither, in which case it is the
+  dnl "softfloat" ABI.
+  dnl The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
+  dnl we can safely mix code built with both ABIs. So, if we detect
+  dnl that compiling uses the "softfloat" ABI, force the use of the
+  dnl "softfp" ABI instead.
+  dnl Confusingly, the __SOFTFP__ preprocessor variable indicates the
+  dnl "softfloat" ABI, not the "softfp" ABI.
+  dnl Note: VPX_ASFLAGS is also used in CFLAGS.
+  AC_TRY_COMPILE([],
+    [#ifndef __SOFTFP__
+     #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
+     #endif],
+     NEON_FLAGS="$NEON_FLAGS -mfloat-abi=softfp"
+  )
+
 fi # CPU_ARCH = arm
 
 AC_SUBST(HAVE_ARM_SIMD)
 AC_SUBST(HAVE_ARM_NEON)
 AC_SUBST(BUILD_ARM_NEON)
 AC_SUBST(ARM_ARCH)
 AC_SUBST_LIST(NEON_FLAGS)