Add another drd/tests/bar_bad exp variant.
[valgrind.git] / README.android
blob199616e1b21fc70adf80ead4507fc377766e366c
2 How to cross-compile and run on Android.  Please read to the end,
3 since there are important details further down regarding crash
4 avoidance and GPU support.
6 These notes were last updated on 4 Nov 2014, for Valgrind SVN
7 revision 14689/2987.
9 These instructions are known to work, or have worked at some time in
10 the past, for:
12 arm:
13   Android 4.0.3 running on a (rooted, AOSP build) Nexus S.
14   Android 4.0.3 running on Motorola Xoom.
15   Android 4.0.3 running on android arm emulator.
16   Android 4.1   running on android emulator.
17   Android 2.3.4 on Nexus S worked at some time in the past.
19 x86:
20   Android 4.0.3 running on android x86 emulator.
22 mips32:
23   Android 4.1.2 running on android mips emulator.
24   Android 4.2.2 running on android mips emulator.
25   Android 4.3   running on android mips emulator.
26   Android 4.0.4 running on BROADCOM bcm7425
28 arm64:
29   Android 4.5 (?) running on ARM Juno
31 On android-arm, GDBserver might insert breaks at wrong addresses.
32 Feedback on this welcome.
34 Other configurations and toolchains might work, but haven't been tested.
35 Feedback is welcome.
37 Toolchain:
39   For arm32, x86 and mips32 you need the android-ndk-r6 native
40     development kit.  r6b and r7 give a non-completely-working build;
41     see http://code.google.com/p/android/issues/detail?id=23203
42     For the android emulator, the versions needed and how to install
43     them are described in README.android_emulator.
45     You can get android-ndk-r6 from
46     http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2
48   For arm64 (aarch64) you need the android-ndk-r10c NDK, from
49     http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin
51 Install the NDK somewhere.  Doesn't matter where.  Then:
54 # Modify this (obviously).  Note, this "export" command is only done
55 # so as to reduce the amount of typing required.  None of the commands
56 # below read it as part of their operation.
58 export NDKROOT=/path/to/android-ndk-r<version>
61 # Then cd to the root of your Valgrind source tree.
63 cd /path/to/valgrind/source/tree
66 # After this point, you don't need to modify anything.  Just copy and
67 # paste the commands below.
70 # Set up toolchain paths.
72 # For ARM
73 export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar
74 export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld
75 export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
77 # For x86
78 export AR=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ar
79 export LD=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ld
80 export CC=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-gcc
82 # For MIPS32
83 export AR=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ar
84 export LD=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ld
85 export CC=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-gcc
87 # For ARM64 (AArch64)
88 export AR=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar 
89 export LD=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld
90 export CC=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc
93 # Do configuration stuff.  Don't mess with the --prefix in the
94 # configure command below, even if you think it's wrong.
95 # You may need to set the --with-tmpdir path to something
96 # different if /sdcard doesn't work on the device -- this is
97 # a known cause of difficulties.
99 # The below re-generates configure, Makefiles, ...
100 # This is not needed if you start from a release tarball.
101 ./autogen.sh
103 # for ARM
104 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
105    CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
106    ./configure --prefix=/data/local/Inst \
107    --host=armv7-unknown-linux --target=armv7-unknown-linux \
108    --with-tmpdir=/sdcard
109 # note: on android emulator, android-14 platform was also tested and works.
110 # It is not clear what this platform nr really is.
112 # for x86
113 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86" \
114    CFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86 -fno-pic" \
115    ./configure --prefix=/data/local/Inst \
116    --host=i686-android-linux --target=i686-android-linux \
117    --with-tmpdir=/sdcard
119 # for MIPS32
120 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips" \
121    CFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips" \
122    ./configure --prefix=/data/local/Inst \
123    --host=mipsel-linux-android --target=mipsel-linux-android \
124    --with-tmpdir=/sdcard
126 # for ARM64 (AArch64)
127 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64" \
128    CFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64" \
129    ./configure --prefix=/data/local/Inst \
130    --host=aarch64-unknown-linux --target=aarch64-unknown-linux \
131    --with-tmpdir=/sdcard
134 # At the end of the configure run, a few lines of details
135 # are printed.  Make sure that you see these two lines:
137 # For ARM:
138 #          Platform variant: android
139 #     Primary -DVGPV string: -DVGPV_arm_linux_android=1
141 # For x86:
142 #          Platform variant: android
143 #     Primary -DVGPV string: -DVGPV_x86_linux_android=1
145 # For mips32:
146 #          Platform variant: android
147 #     Primary -DVGPV string: -DVGPV_mips32_linux_android=1
149 # For ARM64 (AArch64):
150 #          Platform variant: android
151 #     Primary -DVGPV string: -DVGPV_arm64_linux_android=1
153 # If you see anything else at this point, something is wrong, and
154 # either the build will fail, or will succeed but you'll get something
155 # which won't work.
158 # Build, and park the install tree in `pwd`/Inst
160 make -j4
161 make -j4 install DESTDIR=`pwd`/Inst
164 # To get the install tree onto the device:
165 # (I don't know why it's not "adb push Inst /data/local", but this
166 # formulation does appear to put the result in /data/local/Inst.)
168 adb push Inst /
171 # To run (on the device).  There are two things you need to consider:
173 # (1) if you are running on the Android emulator, Valgrind may crash
174 #     at startup.  This is because the emulator (for ARM) may not be
175 #     simulating a hardware TLS register.  To get around this, run
176 #     Valgrind with:
177 #       --kernel-variant=android-no-hw-tls
179 # (2) if you are running a real device, you need to tell Valgrind
180 #     what GPU it has, so Valgrind knows how to handle custom GPU
181 #     ioctls.  You can choose one of the following:
182 #       --kernel-variant=android-gpu-sgx5xx     # PowerVR SGX 5XX series
183 #       --kernel-variant=android-gpu-adreno3xx  # Qualcomm Adreno 3XX series
184 #     If you don't choose one, the program will still run, but Memcheck
185 #     may report false errors after the program performs GPU-specific ioctls.
187 # Anyway: to run on the device:
189 /data/local/Inst/bin/valgrind [kernel variant args] [the usual args etc]
192 # Once you're up and running, a handy modify-V-rebuild-reinstall
193 # command line (on the host, of course) is
195 mq -j2 && mq -j2 install DESTDIR=`pwd`/Inst && adb push Inst /
197 # where 'mq' is an alias for 'make --quiet'.
200 # One common cause of runs failing at startup is the inability of
201 # Valgrind to find a suitable temporary directory.  On the device,
202 # there doesn't seem to be any one location which we always have
203 # permission to write to.  The instructions above use /sdcard.  If
204 # that doesn't work for you, and you're Valgrinding one specific
205 # application which is already installed, you could try using its
206 # temporary directory, in /data/data, for example
207 # /data/data/org.mozilla.firefox_beta.
209 # Using /system/bin/logcat on the device is helpful for diagnosing
210 # these kinds of problems.