1
1
2
- How to cross-compile for Android. These notes were last updated on
3
- 17 Feb 2012, for Valgrind SVN revision 12390/2257.
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.
4
5
5
- This is known to work at least for :
6
- ARM:
6
+ These notes were last updated on 3 Sept 2014, for Valgrind SVN
7
+ revision 14439/2941.
8
+
9
+ These instructions are known to work, or have worked at some time in
10
+ the past, for:
11
+
12
+ arm:
7
13
Android 4.0.3 running on a (rooted, AOSP build) Nexus S.
8
14
Android 4.0.3 running on Motorola Xoom.
9
15
Android 4.0.3 running on android arm emulator.
@@ -34,7 +40,7 @@ install them are described in README.android_emulator.
34
40
35
41
You can get android-ndk-r6 from
36
42
http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2
37
- Install it somewhere. Doesn't matter where. Then do this :
43
+ Install it somewhere. Doesn't matter where. Then:
38
44
39
45
40
46
# Modify this (obviously). Note, this "export" command is only done
@@ -44,25 +50,12 @@ Install it somewhere. Doesn't matter where. Then do this:
44
50
export NDKROOT=/path/to/android-ndk-r6
45
51
46
52
47
- # Modify this too. Tell the build system which Android hardware you
48
- # are building for. It needs to know this so it can compile in
49
- # support for the right Android-hw-specific ioctls. (sigh.) As with
50
- # NDKROOT above, this is merely to avoid repeated typing; none of the
51
- # commands read it.
52
- #
53
- # Currently the supported values are: nexus_s pandaboard
54
- # So choose one of the below:
55
- #
56
- export HWKIND=nexus_s # Samsung Nexus S; also Xoom (for now)
57
- export HWKIND=generic # A generic Android device. eg, Pandaboard
58
- export HWKIND=emulator # Android emulator
59
-
60
53
# Then cd to the root of your Valgrind source tree.
61
54
#
62
55
cd /path/to/valgrind/source/tree
63
56
64
57
65
- # After this point, you don't need to modify anything; just copy and
58
+ # After this point, you don't need to modify anything. Just copy and
66
59
# paste the commands below.
67
60
68
61
@@ -83,6 +76,7 @@ export AR=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin
83
76
export LD=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ld
84
77
export CC=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-gcc
85
78
79
+
86
80
# Do configuration stuff. Don't mess with the --prefix in the
87
81
# configure command below, even if you think it's wrong.
88
82
# You may need to set the --with-tmpdir path to something
@@ -94,7 +88,7 @@ export CC=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin
94
88
./autogen.sh
95
89
96
90
# for ARM
97
- CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND " \
91
+ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
98
92
CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \
99
93
./configure --prefix=/data/local/Inst \
100
94
--host=armv7-unknown-linux --target=armv7-unknown-linux \
@@ -103,19 +97,20 @@ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HW
103
97
# It is not clear what this platform nr really is.
104
98
105
99
# for x86
106
- CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86 -DANDROID_HARDWARE_$HWKIND " \
100
+ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86" \
107
101
CFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86 -fno-pic" \
108
102
./configure --prefix=/data/local/Inst \
109
103
--host=i686-android-linux --target=i686-android-linux \
110
104
--with-tmpdir=/sdcard
111
105
112
106
# for MIPS32
113
- CPPFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips -DANDROID_HARDWARE_$HWKIND " \
107
+ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips" \
114
108
CFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips" \
115
109
./configure --prefix=/data/local/Inst \
116
110
--host=mipsel-linux-android --target=mipsel-linux-android \
117
111
--with-tmpdir=/sdcard
118
112
113
+
119
114
# At the end of the configure run, a few lines of details
120
115
# are printed. Make sure that you see these two lines:
121
116
#
@@ -148,8 +143,26 @@ make -j2 install DESTDIR=`pwd`/Inst
148
143
#
149
144
adb push Inst /
150
145
151
- # To run (on the device)
152
- /data/local/Inst/bin/valgrind [the usual args etc]
146
+
147
+ # To run (on the device). There are two things you need to consider:
148
+ #
149
+ # (1) if you are running on the Android emulator, Valgrind may crash
150
+ # at startup. This is because the emulator (for ARM) may not be
151
+ # simulating a hardware TLS register. To get around this, run
152
+ # Valgrind with:
153
+ # --kernel-variant=android-emulator-no-hw-tls
154
+ #
155
+ # (2) if you are running a real device, you need to tell Valgrind
156
+ # what GPU it has, so Valgrind knows how to handle custom GPU
157
+ # ioctls. You can choose one of the following:
158
+ # --kernel-variant=android-gpu-sgx5xx # PowerVR SGX 5XX series
159
+ # --kernel-variant=android-gpu-adreno3xx # Qualcomm Adreno 3XX series
160
+ # If you don't choose one, the program will still run, but Memcheck
161
+ # may report false errors after the program performs GPU-specific ioctls.
162
+ #
163
+ # Anyway: to run on the device:
164
+ #
165
+ /data/local/Inst/bin/valgrind [kernel variant args] [the usual args etc]
153
166
154
167
155
168
# Once you're up and running, a handy modify-V-rebuild-reinstall
0 commit comments