Ensure that -mno-unaligned-access or some equivalent option is used.

This commit is contained in:
Vladimir Serbinenko 2013-11-30 11:31:14 +01:00
parent 35de6d4bac
commit d74b9a1d1a
3 changed files with 23 additions and 24 deletions

View file

@ -839,11 +839,26 @@ fi
CFLAGS="$TARGET_CFLAGS"
# -mno-unaligned-access
# -mno-unaligned-access -mstrict-align
if test "$target_cpu" = arm; then
grub_CHECK_NO_UNALIGNED_ACCESS
if test x"$nua_possible" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mno-unaligned-access"
AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
grub_cv_target_cc_strict_align=unknown
for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
CFLAGS="$TARGET_CFLAGS $arg -Werror"
LDFLAGS="$TARGET_LDFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_strict_align="$arg"
break;
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
fi