<div dir="ltr">with NDK r15beta2 (out around I/O), strace builds out of the box for arm. (i.e. you can skip the "hack a couple of things" step in my earlier mail.)<div><br></div><div>for aarch64, you'll want to change the CFLAGS line to</div><div><br></div><div> export CFLAGS="-std=gnu99 -fPIE -pie"</div><div><br></div><div>because the aarch64 kernel headers use __uint128_t for the fpsimd `vregs`, which is a gnu extension.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 27, 2017 at 7:36 PM, enh <span dir="ltr"><<a href="mailto:enh@google.com" target="_blank">enh@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Jan 27, 2017 at 7:16 PM, enh <<a href="mailto:enh@google.com">enh@google.com</a>> wrote:<br>
> sadly building stuff with the NDK can be fun at the best of times, and<br>
> strace is actually a pretty hairy project to build. we're working on<br>
> improving the NDK (see below) and i'll try to make sure we add some<br>
> documentation for what the traditional "configure && make" looks like<br>
> with the NDK.<br>
><br>
> anyway, here's how to build a 32-bit ARM strace 4.15 binary with the NDK:<br>
><br>
> * download NDK r14 beta 1 from <a href="https://github.com/android-ndk/ndk/wiki" rel="noreferrer" target="_blank">https://github.com/android-<wbr>ndk/ndk/wiki</a><br>
><br>
> * unpack it<br>
><br>
> * generate a standalone<br>
> toolchain[<a href="https://developer.android.com/ndk/guides/standalone_toolchain.html" rel="noreferrer" target="_blank">https://developer.<wbr>android.com/ndk/guides/<wbr>standalone_toolchain.html</a>]<br>
> using unified headers[<a href="https://android.googlesource.com/platform/ndk/+/master/docs/UnifiedHeaders.md" rel="noreferrer" target="_blank">https://android.<wbr>googlesource.com/platform/ndk/<wbr>+/master/docs/UnifiedHeaders.<wbr>md</a>]:<br>
><br>
> ./android-ndk-r14-beta1/build/<wbr>tools/make_standalone_<wbr>toolchain.py<br>
> --unified-headers --arch arm --api 24 --install-dir /tmp/ndk-arm<br>
><br>
> * download strace 4.15<br>
><br>
> * unpack it<br>
><br>
> * hack a couple of things:<br>
><br>
> 1. strace seems to need mtd/mtd-abi.h and mtd/ubi-user.h for mtd.c.<br>
> they're not in r14beta1 so you'll need to copy them from<br>
> bionic[<a href="https://android.googlesource.com/platform/bionic/+/master/libc/kernel/uapi/mtd/" rel="noreferrer" target="_blank">https://android.<wbr>googlesource.com/platform/<wbr>bionic/+/master/libc/kernel/<wbr>uapi/mtd/</a>]<br>
> into /tmp/ndk-arm/sysroot/usr/<wbr>include/mtd/ (which you'll have to<br>
> create).<br>
><br>
> this is already fixed in r14 beta 2, but that's held up in QA. sorry.<br>
<br>
</span>(the NDK maintainer points out that we do however make canary builds<br>
available[<a href="https://android.googlesource.com/platform/ndk/+/master/docs/ContinuousBuilds.md" rel="noreferrer" target="_blank">https://android.<wbr>googlesource.com/platform/ndk/<wbr>+/master/docs/<wbr>ContinuousBuilds.md</a>]<br>
--- note that the downloads default to darwin, so you'll want to<br>
change that combo box too if you're following the instructions but use<br>
linux.)<br>
<div class="HOEnZb"><div class="h5"><br>
> 2. strace assumes the glibc name __key for the struct ipc64_perm<br>
> field. add these lines to sys/ipc.h in /tmp/ndk-arm:<br>
><br>
> +#if defined(__USE_GNU)<br>
> +#define __key key<br>
> +#define __seq seq<br>
> +#endif<br>
><br>
> i'll add that to<br>
> bionic[<a href="https://android-review.googlesource.com/#/c/329669/" rel="noreferrer" target="_blank">https://android-review.<wbr>googlesource.com/#/c/329669/</a>] and it'll<br>
> be in a future NDK release.<br>
><br>
> * setup:<br>
><br>
> export CC=/tmp/ndk-arm/bin/arm-linux-<wbr>androideabi-clang<br>
> export CFLAGS="-fPIE -fPIC -pie"<br>
> ./configure --host=arm-linux-androideabi<br>
> make<br>
><br>
> * push the resulting "strace" to your device and use it.<br>
><br>
> $ adb push strace /data/local/tmp/strace<br>
> $ adb shell /data/local/tmp/strace -V<br>
> strace -- version 4.15<br>
> $<br>
><br>
> (i actually traced a real executable, but the output of -V was less<br>
> spammy for the purposes of this email.)<br>
><br>
> On Thu, Jan 26, 2017 at 7:31 AM, Larry Dickson <<a href="mailto:tjoccam@tjoccam.com">tjoccam@tjoccam.com</a>> wrote:<br>
>> Hello strace developers,<br>
>><br>
>> After discovering that the Samsung S2 T710 Android tablet is really 32 bit,<br>
>> we attempted to cross-compile strace using the NDK in 32 bits. Again I went<br>
>> for android-ndk-r13b-linux-x86_64.<wbr>zip, which is in<br>
>><br>
>><br>
>> <a href="https://developer.android.com/ndk/downloads/index.html" rel="noreferrer" target="_blank">https://developer.android.com/<wbr>ndk/downloads/index.html</a><br>
>><br>
>> and brought it up according to<br>
>><br>
>> <a href="http://nickdesaulniers.github.io/blog/2016/07/01/android-cli/" rel="noreferrer" target="_blank">http://nickdesaulniers.github.<wbr>io/blog/2016/07/01/android-<wbr>cli/</a><br>
>><br>
>> (except for the source fetch, which was just a download). OK.<br>
>><br>
>><br>
>> Instead of aarch64-linux-android-gcc I used arm-linux-androideabi-gcc, and<br>
>> similar for strip; instead of --host=aarch64-linux I used --host=arm-linux.<br>
>> ./configure worked but not make, which failed quickly on<br>
>><br>
>> print_msgbuf.c:35:21: fatal error: sys/msg.h: No such file or directory<br>
>><br>
>> Are there any known paths to successful compilation of strace for the<br>
>> Android?<br>
>><br>
>> Larry Dickson<br>
>> Space Sciences Corporation<br>
>><br>
>> On Jan 24, 2017, at 8:15 AM, Larry Dickson <<a href="mailto:tjoccam@tjoccam.com">tjoccam@tjoccam.com</a>> wrote:<br>
>><br>
>> Hello strace developers,<br>
>><br>
>> We need strace on our Samsung S2 T710 Android tablet, and I tried to<br>
>> cross-compile it on our Dell XPS-13 (Ubuntu 14.04 LTS) laptop. I went for<br>
>> android-ndk-r13b-linux-x86_64.<wbr>zip, which is in<br>
>><br>
>> <a href="https://developer.android.com/ndk/downloads/index.html" rel="noreferrer" target="_blank">https://developer.android.com/<wbr>ndk/downloads/index.html</a><br>
>><br>
>> and brought it up according to<br>
>><br>
>> <a href="http://nickdesaulniers.github.io/blog/2016/07/01/android-cli/" rel="noreferrer" target="_blank">http://nickdesaulniers.github.<wbr>io/blog/2016/07/01/android-<wbr>cli/</a><br>
>><br>
>> (except for the source fetch, which was just a download). OK. Then I<br>
>> downloaded strace-4.15.tar.xz from sourceforge and followed Muzso<br>
>><br>
>> <a href="http://muzso.hu/2012/04/21/how-to-compile-strace-for-use-on-an-android-phone-running-an-arm-cpu" rel="noreferrer" target="_blank">http://muzso.hu/2012/04/21/<wbr>how-to-compile-strace-for-use-<wbr>on-an-android-phone-running-<wbr>an-arm-cpu</a><br>
>><br>
>> except that I fixed the names and substituted aarch64-linux for arm-linux in<br>
>> the ./configure, which worked. (I used aarch64-linux instead of arm-linux<br>
>> because our device CPU is an Exynos 5433, which is an ARMx8-A.)<br>
>><br>
>> The make failed with error<br>
>><br>
>> # error struct flock64 definition not found in <linux/fcntl.h><br>
>><br>
>> which is an error discussed nowhere on the web, though I can find struct . .<br>
>> . fcntl.h> in three source files.<br>
>><br>
>> Thank you for any help you can give!<br>
>><br>
>> Larry Dickson<br>
>> Space Sciences Corporation<br>
>><br>
>><br>
>><br>
>> ------------------------------<wbr>------------------------------<wbr>------------------<br>
>> Check out the vibrant tech community on one of the world's most<br>
>> engaging tech sites, SlashDot.org! <a href="http://sdm.link/slashdot" rel="noreferrer" target="_blank">http://sdm.link/slashdot</a><br>
>> ______________________________<wbr>_________________<br>
>> Strace-devel mailing list<br>
>> <a href="mailto:Strace-devel@lists.sourceforge.net">Strace-devel@lists.<wbr>sourceforge.net</a><br>
>> <a href="https://lists.sourceforge.net/lists/listinfo/strace-devel" rel="noreferrer" target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/strace-devel</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> Elliott Hughes - <a href="http://who/enh" rel="noreferrer" target="_blank">http://who/enh</a> - <a href="http://jessies.org/~enh/" rel="noreferrer" target="_blank">http://jessies.org/~enh/</a><br>
> Android native code/tools questions? Mail me/drop by/add me as a reviewer.<br>
<br>
<br>
<br>
--<br>
Elliott Hughes - <a href="http://who/enh" rel="noreferrer" target="_blank">http://who/enh</a> - <a href="http://jessies.org/~enh/" rel="noreferrer" target="_blank">http://jessies.org/~enh/</a><br>
Android native code/tools questions? Mail me/drop by/add me as a reviewer.<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Elliott Hughes - <a href="http://who/enh" target="_blank">http://who/enh</a> - <a href="http://jessies.org/~enh/" target="_blank">http://jessies.org/~enh/</a><br>Android native code/tools questions? Mail me/drop by/add me as a reviewer.</div>
</div>