[Toybox] Fun with the android NDK.

Rob Landley rob at landley.net
Mon Sep 3 09:54:38 PDT 2018



On 09/01/2018 02:00 PM, enh wrote:
> On Fri, Aug 31, 2018 at 2:05 PM Rob Landley <rob at landley.net> wrote:
>>
>> So here's what I had to do to build and run toybox with the Android NDK:
>>
>> 1) I don't remember which NDK version I have installed and ls -l
>> /opt/android/x86-64 is unenlightening (NOTICE is 2400 lines of concatenated help
>> text starting with GPLv2, everything starting with "COPYING" is some variant of
>> GPL (yet MORE license text), repo.prop is a bunch of git hashes,
>> manifest_4639204.xml is not close enough to human readable to matter) but the
>> start of llvm-cc --version is "Android (4639204 based on r316199) clang version
>> 6.0.1" which presumably means something to somebody. It's recent-ish. January maybe?
> 
> if you're missing a CHANGELOG.md file, you should definitely upgrade.
> otherwise that will tell you what version you're using.

I deleted the download directory and only have the "relocated" directory it
installed into /opt. I just have the standalone install.

> sysroot/usr/include/android/ndk-version.h also has the details, for
> programmatic use.

Yup. 17.0-beta1

>> 2) I applied the attached patch, some bits of which should get merged and others
>> I dunno about. (The structure ping wanted... did that git fixed upstream already?)
> 
> yeah, icmphdr is there for me.

Cool. Any idea when it shows up in the ndk? Let's see, download 18-beta2...

Ooh! Ha, I hadn't noticed:

https://developer.android.com/ndk/guides/standalone_toolchain

You use toybox as a build example. Very nice. I'll give these instructions a try
and add them to my testing thing...

Hmmm. In theory toybox expects you to set CROSS_COMPILE (same as thelinux
kernel). If you set CC that'll work fo the build, but not for "make defconfig",
it'll try to use your target compiler to build the kconfig plumbing from 2.6.12?
I _really_ need to rewrite that stuff, it's the only gpl build plumbing left in
the project, and the kernel guys rewrote it to be turing complete recently which
is not a direction I want to go in...)

# ~/android-ndk-r18-beta2$ build/tools/make_standalone_toolchain.py --arch=arm64
 --api 26 --stl=libc++ --install-dir=~/ndk

It created a ~ subdirectory under the extracted android ndk directory. Of course
it did.

> as for the initializations, i'm always happy to see such changes, but
> i haven't needed them personally. i suspect you're using GCC rather
> than clang?

I used the llvm- prefix.

> (GCC will be removed in r18, some time this month.) here
> are the `-Wno-`s i need to be able to build with the Android-preferred
> -Wall -Werror:
> 
>         "-Wno-char-subscripts",
>         "-Wno-gnu-variable-sized-type-not-at-end",

That one's my bad, I need to fix it. (The linestack stuff is unfinished, I
really need to get back to it and actually implement a text editor and such.)

>         "-Wno-missing-field-initializers",
>         "-Wno-sign-compare",
>         "-Wno-string-plus-int",
>         "-Wno-unused-parameter",

Hmmm...

>> 3) "LDFLAGS=--static CROSS_COMPILE=/opt/android/x86-64/bin/llvm- defconfig" and
>> then switch OFF CONFIG_LOG and CONFIG_GETCONF. The first I vaguely remember
>> talking about on here and the android guys intentionally don't export the log
>> functions in the NDK (but you can call the command line utility...?), the second
>> is missing posix stuff. (Is that fixed upstream or should I try to hack around
>> it here, or...?)
> 
> yeah, for the platform i have
> 
> # CONFIG_GETCONF is not set
> CONFIG_LOG=y
> 
> getconf seems to be without any real value.

The kernel build grew a dependency on it, although it's not a deep dependency
yet (it spits out a lot of "getconf not found" stuff but _mostly_ falls back to
sane defaults), and if I was going to add it, I might as well do it right...

> __android_log_write is in the NDK.

I'll upgrade the version and try it again.

Thanks,

Rob



More information about the Toybox mailing list