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 #