* configure.ac: Allow compilation with older GCC for ARM.
authorVladimir Serbinenko <phcoder@gmail.com>
Wed, 4 Dec 2013 11:42:09 +0000 (12:42 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 4 Dec 2013 11:42:09 +0000 (12:42 +0100)
ChangeLog
configure.ac

index d27eaba..ccd9e8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-04  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * configure.ac: Allow compilation with older GCC for ARM.
+
 2013-12-04  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * configure.ac: Add -no-integrated-as if {addme|ame} isn't supported.
index c371a85..c00110c 100644 (file)
@@ -903,7 +903,7 @@ CFLAGS="$TARGET_CFLAGS"
 # -mno-unaligned-access -mstrict-align
 if test "$target_cpu" = arm; then
   AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
-    grub_cv_target_cc_strict_align=unknown
+    grub_cv_target_cc_strict_align=
     for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
       CFLAGS="$TARGET_CFLAGS $arg -Werror"
       LDFLAGS="$TARGET_LDFLAGS"
@@ -914,13 +914,21 @@ if test "$target_cpu" = arm; then
       fi
     done])
 
-  if test x"$grub_cv_target_cc_strict_align" = xunknown; then
-    AC_MSG_ERROR([couldnt instruct compiler not to use unaligned access])
-  fi
   TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
   if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
     TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
   fi
+  AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
+  [CFLAGS="$TARGET_CFLAGS"
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
+#ifdef __ARM_FEATURE_UNALIGNED
+#error "unaligned"
+#endif
+     ]])],
+     [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
+  if test x$grub_cv_cc_target_emits_unaligned = xyes; then
+    AC_MSG_ERROR([compiler generates unaligned accesses])
+  fi
 fi
 
 # Set them to their new values for the tests below.