Is anybody cross compiled and used LTP for android, I tried cross compiling LTP using arm-eabi tool chain, arm-linux-none-gnueabi toolchain, but i am not able to execute testcases in android device.
1 Answers
First create standalone toolchain (with make-standalone-toolchain.sh script) and install it into /opt/android-standalone-toolchain.api-${API}
.
The build itself:
API=24
export TOOLCHAIN_ROOT=/opt/android-standalone-toolchain.api-${API}
export SYSROOT=$TOOLCHAIN_ROOT/sysroot
export CROSS_COMPILE=$TOOLCHAIN_ROOT/bin/arm-linux-androideabi-
export HOST=arm-linux-androideabi
# Non-exhaustive lists of compiler + binutils
# Depending on what you compile, you might need more binutils than that
export CPP=${CROSS_COMPILE}cpp
export AR=${CROSS_COMPILE}ar
export AS=${CROSS_COMPILE}as
export NM=${CROSS_COMPILE}nm
export CC=${CROSS_COMPILE}gcc
export CXX=${CROSS_COMPILE}g++
export LD=${CROSS_COMPILE}ld
export RANLIB=${CROSS_COMPILE}ranlib
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include \
-I${ANDROID_PREFIX}/include"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"
make autotools
./configure --host=${HOST} --with-sysroot=${SYSROOT}
make -j$(getconf _NPROCESSORS_ONLN) ANDROID=1
make install
adb push /opt/ltp /data/local/tmp
CREDITS: Using variable ANDROID=1
is documented in INSTALL file in LTP source code, setting other variables is inspired by android_configure.sh.
But currently the build fails as many tests needs to be disabled (bionic doesn't support many required features, see list of tests needed to be disabled made by people from google).
Currently, there is an effort in upstream to fix building LTP for Android. People from google added LTP into AOSP, but they're contributing the code back to LTP upstream (see info in LTP mailing list people from google planning to contribute, their instructions about building).
Some of android related fixes (people from google and others): fix the executable shell path, fix temp dir, fix stack_clash test.
Currently it might be easier to use google's repository in AOSP (either in-tree build in AOSP tree or out-of-tree with standalone toolchain), but sooner or later LTP upstream should get all fixes for android from google's repository.