Test which flags make our asm compile.
Previously we relied on assumption that clang always needs -no-integrated-as but it's not always true.
This commit is contained in:
parent
0b02bfa034
commit
065ad910f1
6 changed files with 89 additions and 27 deletions
20
asm-tests/arm.S
Normal file
20
asm-tests/arm.S
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* on arm clang doesn't support .arch directive */
|
||||
|
||||
.text
|
||||
.syntax unified
|
||||
|
||||
#if !defined (__thumb2__)
|
||||
.arch armv7a
|
||||
.arm
|
||||
#else
|
||||
.arch armv7
|
||||
.thumb
|
||||
#endif
|
||||
mcr p15, 0, r11, c7, c14, 2
|
||||
|
||||
/* clang restricts access to dsb/isb despite .arch */
|
||||
dsb
|
||||
isb
|
||||
|
||||
|
||||
|
10
asm-tests/i386.S
Normal file
10
asm-tests/i386.S
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* on x86 old clang doesn't support .code16
|
||||
newer clang supports it but creates 6-byte jumps instead of 3-byte ones
|
||||
which makes us go over boot sector size. */
|
||||
|
||||
.code16
|
||||
jmp far
|
||||
.org 4
|
||||
.space 300
|
||||
far:
|
||||
.byte 0
|
11
asm-tests/mips.S
Normal file
11
asm-tests/mips.S
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* on mips clang doesn't support privilegied instructions, doubleword store/load
|
||||
and crashes with hand-written assembly
|
||||
*/
|
||||
|
||||
.set mips3
|
||||
sync
|
||||
ld $t2, 0($t6)
|
||||
|
||||
a:
|
||||
addiu $t7, $s0, (b - a)
|
||||
b: nop
|
8
asm-tests/powerpc.S
Normal file
8
asm-tests/powerpc.S
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
|
||||
used by gcrypt */
|
||||
/* Cache invalidation loop is a fair test. */
|
||||
li 5, 0
|
||||
1: icbi 5, 3
|
||||
addi 5, 5, 32
|
||||
cmpw 5, 4
|
||||
blt 1b
|
9
asm-tests/sparc64.S
Normal file
9
asm-tests/sparc64.S
Normal file
|
@ -0,0 +1,9 @@
|
|||
.text
|
||||
1:
|
||||
/* A small list of examples of what clang doesn't support. */
|
||||
clr %o0
|
||||
lduw [%o4 + 4], %o4
|
||||
and %o6, ~0xff, %o6
|
||||
stw %o5, [%o3]
|
||||
bne,pt %icc, 1b
|
||||
nop
|
58
configure.ac
58
configure.ac
|
@ -560,35 +560,39 @@ AC_COMPILE_IFELSE(
|
|||
]])],
|
||||
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
|
||||
|
||||
# on x86 clang doesn't support .code16
|
||||
# on arm clang doesn't support .arch directive
|
||||
# on mips clang doesn't support privilegied instructions, doubleword store/load
|
||||
# and crashes with hand-written assembly
|
||||
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
|
||||
|| test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \
|
||||
|| test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
|
||||
fi
|
||||
|
||||
if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
|
||||
AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
|
||||
[
|
||||
CFLAGS="$TARGET_CFLAGS"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([], [[
|
||||
unsigned int a = 0, b = 0;
|
||||
asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b));
|
||||
if (a)
|
||||
return 1;
|
||||
]])],
|
||||
[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])])
|
||||
# clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
|
||||
# used by gcrypt
|
||||
if test x$grub_cv_cc_target_clang_ame = xno ; then
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as"
|
||||
AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
|
||||
test_program=
|
||||
case "x$target_cpu" in
|
||||
xmips | xmipsel)
|
||||
test_program=mips
|
||||
;;
|
||||
xi386 | xx86_64)
|
||||
test_program=i386
|
||||
;;
|
||||
xpowerpc | xsparc64 | xarm)
|
||||
test_program=$target_cpu
|
||||
;;
|
||||
esac
|
||||
if test x"$test_program" = x ; then
|
||||
grub_cv_cc_target_asm_compile=
|
||||
else
|
||||
found=no
|
||||
for arg in "" "-no-integrated-as"; do
|
||||
cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
|
||||
echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
|
||||
if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
|
||||
grub_cv_cc_target_asm_compile="$arg"
|
||||
found=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test x"$found" = xno ; then
|
||||
AC_MSG_ERROR([could not compile assembly])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
|
||||
|
||||
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
|
||||
|
|
Loading…
Reference in a new issue