* [PATCH] Allow compiling without -mthumb-interwork as long as no thumb is involved
@ 2013-12-06 13:34 Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; only message in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-12-06 13:34 UTC (permalink / raw)
To: The development of GRUB 2
[-- 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 --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-12-06 13:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-06 13:34 [PATCH] Allow compiling without -mthumb-interwork as long as no thumb is involved Vladimir 'φ-coder/phcoder' Serbinenko
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).