<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 30, 2017 at 12:58 AM, Rob Landley <span dir="ltr"><<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_-8720488974024734082gmail-">On 04/28/2017 05:31 PM, enh wrote:<br>
> since rob asked on some other thread earlier this week...<br>
><br>
> NDK r15beta2 should hopefully ship in time for I/O in a couple of weeks,<br>
> so i had a quick go at building toybox out of the box with the latest<br>
> bits...<br>
<br>
</span>Yay!<br>
<br>
In other test harness news, I've put a lot of work into<br>
<a href="https://github.com/landley/mkroot" rel="noreferrer" target="_blank">https://github.com/landley/mkr<wbr>oot</a> in the past week or so (simple<br>
musl-libc test environment booting under qemu), and if you run the<br>
mcm-buildall.sh script against<br>
<a href="https://github.com/richfelker/musl-cross-make" rel="noreferrer" target="_blank">https://github.com/richfelker/<wbr>musl-cross-make</a> and then do something like<br>
<br>
CROSS_COMPILE=~/musl-cross-mak<wbr>e/output/aarch64-linux-musleab<wbr>i-cross/bin/aarch64-linux-<wbr>musleabi-<br>
./mkroot.sh dropbear kernel<br>
<br>
If it works you can then cd output/aarch64" and ./qemu-aarch64.sh and it<br>
should boot you into a little emulated system.<br>
<br>
I haven't got the whole <a href="https://landley.net/aboriginal/control-images" rel="noreferrer" target="_blank">https://landley.net/aboriginal<wbr>/control-images</a><br>
infrastructure reproduced yet, but I'm working on it.<br>
<br>
I'd love to point CROSS_COMPILE at the NDK toolchains and try to get<br>
those to work too. (Although the main reason I can use musl-cross-make<br>
is I made puppy eyes at Rich to provide _native_ compilers, so my little<br>
emulated environment can natively build stuff in the emulator. I need to<br>
write and check in a module/distcc for mkroot so I can do the distcc<br>
trick from <a href="http://landley.net/aboriginal/about.html" rel="noreferrer" target="_blank">http://landley.net/aboriginal/<wbr>about.html</a> and I see qemu<br>
thinks it's grown multi-threaded SMP support, which might actually make<br>
use of SMP on the host. I should poke at it, the single-cpu emulator<br>
could only keep about 3 distcc slaves running on the host and even I've<br>
got an 8-way SMP system...)<br>
<span class="gmail-m_-8720488974024734082gmail-"><br>
> $ ./android-ndk-r15-beta2/build/<wbr>tools/make_standalone_toolchai<wbr>n.py<br>
> --unified-headers --arch arm64 --api 24 --install-dir<br>
> /tmp/n-standalone-toolchain<br>
<br>
</span>Is there somewhere I can download ndk snapshots from?<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> just has beta 1...</blockquote><div><br></div><div>yeah, it'll be there when we actually release beta2, but until then you'll have to get it from the usual [continuous builds](<a href="https://android.googlesource.com/platform/ndk/+/master/docs/ContinuousBuilds.md" target="_blank">https://android.<wbr>googlesource.com/platform/ndk/<wbr>+/master/docs/<wbr>ContinuousBuilds.md</a>).</div><div><br></div><div>either master or ndk-r15-release should be fine; they're more or less identical right now.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_-8720488974024734082gmail-"><br>
> $ git clone <a href="https://github.com/landley/toybox.git" rel="noreferrer" target="_blank">https://github.com/landley/toy<wbr>box.git</a><br>
> $ cd toybox<br>
> $ CC=clang<br>
> CROSS_COMPILE=/tmp/n-standalon<wbr>e-toolchain/bin/aarch64-linux-<wbr>android-<br>
> make defconfig<br>
> $ CC=clang<br>
> CROSS_COMPILE=/tmp/n-standalon<wbr>e-toolchain/bin/aarch64-linux-<wbr>android- make<br>
><br>
> i've attached one patch to make mkpasswd not part of the "defconfig" for<br>
> Android, since (a) we don't have passwd and (b) we don't have crypt(3).<br>
> so it wouldn't be any use and you can't build it anyway.<br>
><br>
> i've attached another patch to add liblog to the list of probed<br>
> libraries so that toybox actually links okay.<br>
<br>
</span>Applied both, although I had to fix up the second so it installed on top<br>
of your -libz patch.<br>
<span class="gmail-m_-8720488974024734082gmail-"><br>
> with that there's only one problem left (ignoring compiler warnings, and<br>
> the fact that selinux and boringssl aren't part of the NDK so you'll be<br>
> without working versions of any of the selinux stuff or fast versions of<br>
<br>
</span>Out of curiosity, why not?</blockquote><div><br></div><div>in the literal sense: because the NDK has to guarantee ABI stability (since your app might end up running on anything from Gingerbread to Nougat), and those aren't under our control.</div><div><br></div><div>in the "why isn't it trivial to just say 'my app needs boringssl or whatever, just build it and include it'?" sense: because the NDK has both too many and too few build systems, and there's no good way to make this work for all of them (plus whatever else you happen to be using).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_-8720488974024734082gmail-">
> the hash stuff) --- there is no public API for the<br>
> <cutils/sched_policy.h>, so that still won't build out of the box.<br>
<br>
</span>I should add a compile time probe for that... try now?</blockquote><div><br></div><div>yep, works out of the box for me with arm and aarch64.</div><div><br></div><div>for this no-selinux/no-smack configuration, the compiler is confused by lsm_context and incorrectly thinks that `result` can use used uninitialized. this shuts it up (which you might want to do because it's a super spammy warning by virtue of coming from a header file):</div><div><br></div><div><div>diff --git a/lib/lsm.h b/lib/lsm.h</div><div>index e21d424..005e1f6 100644</div><div>--- a/lib/lsm.h</div><div>+++ b/lib/lsm.h</div><div>@@ -55,7 +55,7 @@ static inline char *lsm_name(void)</div><div> static inline char *lsm_context(void)</div><div> {</div><div>   int ok = 0;</div><div>-  char *result;</div><div>+  char *result = NULL;</div><div> </div><div>   if (CFG_TOYBOX_SMACK) ok = smack_new_label_from_self(&result) > 0;</div><div>   else ok = getcon(&result) == 0;</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>there's one other warning from ftpget.c which AOSP doesn't normally build:</div><div><br></div><div><div>toys/net/ftpget.c:140:9: warning: variable 'port' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]</div><div>    if (rc==227) for (s = toybuf; (s = strchr(s, ',')); s++) {</div><div>        ^~~~~~~</div><div>toys/net/ftpget.c:149:31: note: uninitialized use occurs here</div><div>    si6.sin6_port = SWAP_BE16(port); // same field size/offset for v4 and v6</div><div>                              ^~~~</div><div>./lib/portability.h:202:31: note: expanded from macro 'SWAP_BE16'</div><div>#define SWAP_BE16(x) bswap_16(x)</div><div>                              ^</div><div>/tmp/n-standalone-toolchain-arm/bin/../sysroot/usr/include/byteswap.h:35:30: note: expanded from macro 'bswap_16'</div><div>#define bswap_16(x) __swap16(x)</div><div>                             ^</div><div>toys/net/ftpget.c:140:5: note: remove the 'if' if its condition is always true</div><div>    if (rc==227) for (s = toybuf; (s = strchr(s, ',')); s++) {</div><div>    ^~~~~~~~~~~~~</div><div>toys/net/ftpget.c:96:23: note: initialize the variable 'port' to silence this warning</div><div>  int rc, ii = 1, port;</div><div>                      ^</div><div>                       = 0</div></div><div><br></div><div>haven't looked in to that.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_-8720488974024734082gmail-"><br>
> (this was a useful exercise because it showed that <scsi/sg.h> was still<br>
> missing from the NDK, so that bug should finally be fixed for real this<br>
> time.)<br>
<br>
</span>Yay!<br>
<br>
Rob<br>
______________________________<wbr>_________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net" target="_blank">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer" target="_blank">http://lists.landley.net/listi<wbr>nfo.cgi/toybox-landley.net</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-8720488974024734082gmail_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></div>