grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] Allow compiling without -mthumb-interwork as long as no thumb is involved
Date: Fri, 06 Dec 2013 14:34:29 +0100	[thread overview]
Message-ID: <52A1D265.9070608@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2822 bytes --]

My experiments with clang have shown that it doesn't accept
-mthumb-interwork and generates code that isn't interworkable
on armv5t even with explicit -march=armv5t.
Moreover the thumb code it generates even with -march=armv5t
contains Thumb-2 instructions which qemu rightfully interprets as
bl to random address corrupting lr in process and producing
crash dumps with senseless $pc and $lr.
So any kind of thumb1 support with clang is in any case out of
the question.
Then the question if it makes sense to allow (but mention that it's
not supported) compilations with clang and old GCC as long as they
use only arm and thumb2.
Which maintainance costs would it create?
Having clang allowed helps for comparisons and to uncover hidden bugs
(like .bss alignment bug in sparc64 port) but this usefulness is limited.
diff --git a/INSTALL b/INSTALL
index b91d975..3be0271 100644
--- a/INSTALL
+++ b/INSTALL
@@ -17,6 +17,7 @@ configuring the GRUB.
         much bigger binaries.
 	earlier versions not tested
   Note: clang 3.2 or later works for arm
+	None of tested clang versions generated usable thumb code
 	earlier versions not tested
   Note: clang 3.3 or later works for arm64
 	earlier versions have no arm64 support
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 4ec2b81..c390490 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -11,8 +11,6 @@ if COND_sparc64_ieee1275
   LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
 endif
 if COND_arm
-  CFLAGS_PLATFORM += -mthumb-interwork
-  CCASFLAGS_PLATFORM = -mthumb-interwork
   LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
 endif
 if COND_arm64
diff --git a/configure.ac b/configure.ac
index d13cd3d..0fb40e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -858,6 +858,28 @@ if test "x$target_cpu" = xarm; then
   if test "x$grub_cv_cc_mlong_calls" = xyes; then
     TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls"
   fi
+  AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
+    CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+		      [grub_cv_cc_mthumb_interwork=yes],
+		      [grub_cv_cc_mthumb_interwork=no])
+  ])
+  if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
+    TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
+  # clang defaults to thumb-interwork but not GCC
+  else
+    CFLAGS="$TARGET_CFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+#if defined (__thumb__) && !defined (__thumb2__)
+#error thumb without interworking
+#endif
+]])],
+		      [no_interwork_ok=yes],
+		      [no_interwork_ok=no])
+    if test x$no_interwork_ok = xno ; then
+       AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork])
+    fi
+  fi
 fi
 
 #


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

                 reply	other threads:[~2013-12-06 13:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52A1D265.9070608@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).