1 <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 4 <title>9.README.android</title> 5 <link rel="stylesheet" type="text/css" href="vg_basic.css"> 6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7 <link rel="home" href="index.html" title="Valgrind Documentation"> 8 <link rel="up" href="dist.html" title="Valgrind Distribution Documents"> 9 <link rel="prev" href="dist.readme-s390.html" title="8.README.S390"> 10 <link rel="next" href="dist.readme-android_emulator.html" title="10.README.android_emulator"> 11 </head> 12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13 <div><table class="nav" width="100%" cellspacing="3" cellpadding="3" border="0" summary="Navigation header"><tr> 14 <td width="22px" align="center" valign="middle"><a accesskey="p" href="dist.readme-s390.html"><img src="images/prev.png" width="18" height="21" border="0" alt="Prev"></a></td> 15 <td width="25px" align="center" valign="middle"><a accesskey="u" href="dist.html"><img src="images/up.png" width="21" height="18" border="0" alt="Up"></a></td> 16 <td width="31px" align="center" valign="middle"><a accesskey="h" href="index.html"><img src="images/home.png" width="27" height="20" border="0" alt="Up"></a></td> 17 <th align="center" valign="middle">Valgrind Distribution Documents</th> 18 <td width="22px" align="center" valign="middle"><a accesskey="n" href="dist.readme-android_emulator.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td> 19 </tr></table></div> 20 <div class="chapter"> 21 <div class="titlepage"><div><div><h1 class="title"> 22 <a name="dist.readme-android"></a>9.README.android</h1></div></div></div> 23 <div class="literallayout"><p><br> 24 <br> 25 Howtocross-compileandrunonAndroid.Pleasereadtotheend,<br> 26 sincethereareimportantdetailsfurtherdownregardingcrash<br> 27 avoidanceandGPUsupport.<br> 28 <br> 29 Thesenoteswerelastupdatedon4Nov2014,forValgrindSVN<br> 30 revision14689/2987.<br> 31 <br> 32 Theseinstructionsareknowntowork,orhaveworkedatsometimein<br> 33 thepast,for:<br> 34 <br> 35 arm:<br> 36 Android4.0.3runningona(rooted,AOSPbuild)NexusS.<br> 37 Android4.0.3runningonMotorolaXoom.<br> 38 Android4.0.3runningonandroidarmemulator.<br> 39 Android4.1runningonandroidemulator.<br> 40 Android2.3.4onNexusSworkedatsometimeinthepast.<br> 41 <br> 42 x86:<br> 43 Android4.0.3runningonandroidx86emulator.<br> 44 <br> 45 mips32:<br> 46 Android4.1.2runningonandroidmipsemulator.<br> 47 Android4.2.2runningonandroidmipsemulator.<br> 48 Android4.3runningonandroidmipsemulator.<br> 49 Android4.0.4runningonBROADCOMbcm7425<br> 50 <br> 51 arm64:<br> 52 Android4.5(?)runningonARMJuno<br> 53 <br> 54 Onandroid-arm,GDBservermightinsertbreaksatwrongaddresses.<br> 55 Feedbackonthiswelcome.<br> 56 <br> 57 Otherconfigurationsandtoolchainsmightwork,buthaven'tbeentested.<br> 58 Feedbackiswelcome.<br> 59 <br> 60 Toolchain:<br> 61 <br> 62 Forarm32,x86andmips32youneedtheandroid-ndk-r6native<br> 63 developmentkit.r6bandr7giveanon-completely-workingbuild;<br> 64 seehttp://code.google.com/p/android/issues/detail?id=23203<br> 65 Fortheandroidemulator,theversionsneededandhowtoinstall<br> 66 themaredescribedinREADME.android_emulator.<br> 67 <br> 68 Youcangetandroid-ndk-r6from<br> 69 http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2<br> 70 <br> 71 Forarm64(aarch64)youneedtheandroid-ndk-r10cNDK,from<br> 72 http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin<br> 73 <br> 74 InstalltheNDKsomewhere.Doesn'tmatterwhere.Then:<br> 75 <br> 76 <br> 77 #Modifythis(obviously).Note,this"export"commandisonlydone<br> 78 #soastoreducetheamountoftypingrequired.Noneofthecommands<br> 79 #belowreaditaspartoftheiroperation.<br> 80 #<br> 81 exportNDKROOT=/path/to/android-ndk-r<version><br> 82 <br> 83 <br> 84 #ThencdtotherootofyourValgrindsourcetree.<br> 85 #<br> 86 cd/path/to/valgrind/source/tree<br> 87 <br> 88 <br> 89 #Afterthispoint,youdon'tneedtomodifyanything.Justcopyand<br> 90 #pastethecommandsbelow.<br> 91 <br> 92 <br> 93 #Setuptoolchainpaths.<br> 94 #<br> 95 #ForARM<br> 96 exportAR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar<br> 97 exportLD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld<br> 98 exportCC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc<br> 99 <br> 100 #Forx86<br> 101 exportAR=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ar<br> 102 exportLD=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-ld<br> 103 exportCC=$NDKROOT/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-gcc<br> 104 <br> 105 #ForMIPS32<br> 106 exportAR=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ar<br> 107 exportLD=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-ld<br> 108 exportCC=$NDKROOT/toolchains/mipsel-linux-android-4.8/prebuilt/linux-x86_64/bin/mipsel-linux-android-gcc<br> 109 <br> 110 #ForARM64(AArch64)<br> 111 exportAR=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar<br> 112 exportLD=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld<br> 113 exportCC=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc<br> 114 <br> 115 <br> 116 #Doconfigurationstuff.Don'tmesswiththe--prefixinthe<br> 117 #configurecommandbelow,evenifyouthinkit'swrong.<br> 118 #Youmayneedtosetthe--with-tmpdirpathtosomething<br> 119 #differentif/sdcarddoesn'tworkonthedevice--thisis<br> 120 #aknowncauseofdifficulties.<br> 121 <br> 122 #Thebelowre-generatesconfigure,Makefiles,...<br> 123 #Thisisnotneededifyoustartfromareleasetarball.<br> 124 ./autogen.sh<br> 125 <br> 126 #forARM<br> 127 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm"\<br> 128 CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm"\<br> 129 ./configure--prefix=/data/local/Inst\<br> 130 --host=armv7-unknown-linux--target=armv7-unknown-linux\<br> 131 --with-tmpdir=/sdcard<br> 132 #note:onandroidemulator,android-14platformwasalsotestedandworks.<br> 133 #Itisnotclearwhatthisplatformnrreallyis.<br> 134 <br> 135 #forx86<br> 136 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86"\<br> 137 CFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-x86-fno-pic"\<br> 138 ./configure--prefix=/data/local/Inst\<br> 139 --host=i686-android-linux--target=i686-android-linux\<br> 140 --with-tmpdir=/sdcard<br> 141 <br> 142 #forMIPS32<br> 143 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips"\<br> 144 CFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-mips"\<br> 145 ./configure--prefix=/data/local/Inst\<br> 146 --host=mipsel-linux-android--target=mipsel-linux-android\<br> 147 --with-tmpdir=/sdcard<br> 148 <br> 149 #forARM64(AArch64)<br> 150 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64"\<br> 151 CFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64"\<br> 152 ./configure--prefix=/data/local/Inst\<br> 153 --host=aarch64-unknown-linux--target=aarch64-unknown-linux\<br> 154 --with-tmpdir=/sdcard<br> 155 <br> 156 <br> 157 #Attheendoftheconfigurerun,afewlinesofdetails<br> 158 #areprinted.Makesurethatyouseethesetwolines:<br> 159 #<br> 160 #ForARM:<br> 161 #Platformvariant:android<br> 162 #Primary-DVGPVstring:-DVGPV_arm_linux_android=1<br> 163 #<br> 164 #Forx86:<br> 165 #Platformvariant:android<br> 166 #Primary-DVGPVstring:-DVGPV_x86_linux_android=1<br> 167 #<br> 168 #Formips32:<br> 169 #Platformvariant:android<br> 170 #Primary-DVGPVstring:-DVGPV_mips32_linux_android=1<br> 171 #<br> 172 #ForARM64(AArch64):<br> 173 #Platformvariant:android<br> 174 #Primary-DVGPVstring:-DVGPV_arm64_linux_android=1<br> 175 #<br> 176 #Ifyouseeanythingelseatthispoint,somethingiswrong,and<br> 177 #eitherthebuildwillfail,orwillsucceedbutyou'llgetsomething<br> 178 #whichwon'twork.<br> 179 <br> 180 <br> 181 #Build,andparktheinstalltreein`pwd`/Inst<br> 182 #<br> 183 make-j4<br> 184 make-j4installDESTDIR=`pwd`/Inst<br> 185 <br> 186 <br> 187 #Togettheinstalltreeontothedevice:<br> 188 #(Idon'tknowwhyit'snot"adbpushInst/data/local",butthis<br> 189 #formulationdoesappeartoputtheresultin/data/local/Inst.)<br> 190 #<br> 191 adbpushInst/<br> 192 <br> 193 <br> 194 #Torun(onthedevice).Therearetwothingsyouneedtoconsider:<br> 195 #<br> 196 #(1)ifyouarerunningontheAndroidemulator,Valgrindmaycrash<br> 197 #atstartup.Thisisbecausetheemulator(forARM)maynotbe<br> 198 #simulatingahardwareTLSregister.Togetaroundthis,run<br> 199 #Valgrindwith:<br> 200 #--kernel-variant=android-no-hw-tls<br> 201 #<br> 202 #(2)ifyouarerunningarealdevice,youneedtotellValgrind<br> 203 #whatGPUithas,soValgrindknowshowtohandlecustomGPU<br> 204 #ioctls.Youcanchooseoneofthefollowing:<br> 205 #--kernel-variant=android-gpu-sgx5xx#PowerVRSGX5XXseries<br> 206 #--kernel-variant=android-gpu-adreno3xx#QualcommAdreno3XXseries<br> 207 #Ifyoudon'tchooseone,theprogramwillstillrun,butMemcheck<br> 208 #mayreportfalseerrorsaftertheprogramperformsGPU-specificioctls.<br> 209 #<br> 210 #Anyway:torunonthedevice:<br> 211 #<br> 212 /data/local/Inst/bin/valgrind[kernelvariantargs][theusualargsetc]<br> 213 <br> 214 <br> 215 #Onceyou'reupandrunning,ahandymodify-V-rebuild-reinstall<br> 216 #commandline(onthehost,ofcourse)is<br> 217 #<br> 218 mq-j2&&mq-j2installDESTDIR=`pwd`/Inst&&adbpushInst/<br> 219 #<br> 220 #where'mq'isanaliasfor'make--quiet'.<br> 221 <br> 222 <br> 223 #Onecommoncauseofrunsfailingatstartupistheinabilityof<br> 224 #Valgrindtofindasuitabletemporarydirectory.Onthedevice,<br> 225 #theredoesn'tseemtobeanyonelocationwhichwealwayshave<br> 226 #permissiontowriteto.Theinstructionsaboveuse/sdcard.If<br> 227 #thatdoesn'tworkforyou,andyou'reValgrindingonespecific<br> 228 #applicationwhichisalreadyinstalled,youcouldtryusingits<br> 229 #temporarydirectory,in/data/data,forexample<br> 230 #/data/data/org.mozilla.firefox_beta.<br> 231 #<br> 232 #Using/system/bin/logcatonthedeviceishelpfulfordiagnosing<br> 233 #thesekindsofproblems.<br> 234 <br> 235 </p></div> 236 </div> 237 <div> 238 <br><table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer"> 239 <tr> 240 <td rowspan="2" width="40%" align="left"> 241 <a accesskey="p" href="dist.readme-s390.html"><<8.README.S390</a></td> 242 <td width="20%" align="center"><a accesskey="u" href="dist.html">Up</a></td> 243 <td rowspan="2" width="40%" align="right"><a accesskey="n" href="dist.readme-android_emulator.html">10.README.android_emulator>></a> 244 </td> 245 </tr> 246 <tr><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td></tr> 247 </table> 248 </div> 249 </body> 250 </html> 251