]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Discover which option provides soft-float on configure stage.
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 21 Feb 2015 22:46:47 +0000 (23:46 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 21 Feb 2015 23:35:11 +0000 (00:35 +0100)
Deals with clang needing other arguments to stop issuing floating
instructions than gcc.

configure.ac

index 8b94d346ebe19b63771e008585992acce3ec2707..10a6bf9c16ef63754235da7266dd64f553f1dccc 100644 (file)
@@ -682,11 +682,39 @@ fi
 # that floats are a good fit to run instead of what's written in the code.
 # Given that floating point unit is disabled (if present to begin with)
 # when GRUB is running which may result in various hard crashes.
-if test "x$target_cpu" = xarm64; then
-  TARGET_CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd"
-else
-  TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float"
-  TARGET_CCASFLAGS="$TARGET_CCASFLAGS -msoft-float"
+if test x"$platform" != xemu ; then
+  AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
+    grub_cv_target_cc_soft_float=no
+    if test "x$target_cpu" = xarm64; then
+       CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror"
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+                        [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], [])
+    fi
+    for cand in "-Xclang -msoft-float -Xclang -no-implicit-float" \
+               "-Xclang -msoft-float" "-msoft-float"; do
+      if test x"$grub_cv_target_cc_soft_float" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $cand -Werror"
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+                       [grub_cv_target_cc_soft_float="$cand"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_soft_float" = xno ; then
+    AC_MSG_ERROR([could not force soft-float])
+  fi
+
+  case x"$grub_cv_target_cc_soft_float" in
+    x"-Xclang"*)
+      # A trick so that clang doesn't see it on link stаge
+      TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
+      ;;
+    *)
+      TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
+      ;;
+  esac
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
 fi
 
 # By default, GCC 4.4 generates .eh_frame sections containing unwind