aboutsummaryrefslogtreecommitdiff
path: root/tests/build/issue17144-byteswap/build.sh
blob: 158ff139338e4be6939920ccfd5b1a340b009abe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Check if APP_ABI=armeabi-v7a use "rev" instructions for __swapXX
# See https://android-review.googlesource.com/#/c/17144
#

fail_panic ()
{
    if [ $? != 0 ] ; then
        echo "ERROR: $@"
        exit 1
    fi
}

for opt do
    optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
    case "$opt" in
    APP_ABI=*)
        APP_ABI=$optarg
        ;;
    esac
done

if [ -z "$APP_ABI" -o "$APP_ABI" = "all" -o "$APP_ABI" != "${APP_ABI%%armeabi-v7a*}" ]; then
    # checking armeabi-v7a
    $NDK/ndk-build -B APP_ABI=armeabi-v7a APP_CFLAGS=-save-temps NDK_DEBUG=1
    fail_panic "can't compile for APP_ABI=armeabi-v7a"
    grep -qw rev16 issue17144-byteswap.s
    fail_panic "armeabi-v7a doesn't use rev16 instruction for __swap16()"
    grep -qw rev issue17144-byteswap.s
    fail_panic "armeabi-v7a doesn't use rev instruciton for __swap32()"
fi

if [ -z "$APP_ABI" -o "$APP_ABI" = "all" -o "$APP_ABI" != "${APP_ABI%%x86*}" ]; then
    # checking x86
    $NDK/ndk-build -B APP_ABI=x86 APP_CFLAGS=-save-temps NDK_DEBUG=1
    fail_panic "can't compile for x86"
    grep -qw rorw issue17144-byteswap.s
    fail_panic "x86 doesn't use rorw instruction for __swap16()"
    grep -qw bswap issue17144-byteswap.s
    fail_panic "x86 doesn't use bswap instruciton for __swap32()"
fi

if [ -z "$APP_ABI" -o "$APP_ABI" = "all" -o "$APP_ABI" != "${APP_ABI%%mips*}" ]; then
    # checking mips
    # Note that MD_SWAP in machine/endian.h is only defined for r2.  Add
    # -mips32r2 because default Android toolchain support r1
    $NDK/ndk-build -B APP_ABI=mips APP_CFLAGS="-save-temps -mips32r2" NDK_DEBUG=1
    fail_panic "can't compile for mips"
    grep -qw wsbh issue17144-byteswap.s
    fail_panic "mips doesn't use wsbh instruction for __swap16()"
    grep -w rotr issue17144-byteswap.s | grep -qw rotr
    fail_panic "mips doesn't use wsbh/rotr instruciton for __swap32()"
fi

rm -rf libs obj issue17144-byteswap.*