[Toybox] Fun with the android NDK.

enh enh at google.com
Sat Sep 1 12:00:18 PDT 2018


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.

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

> 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.

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? (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",
        "-Wno-missing-field-initializers",
        "-Wno-sign-compare",
        "-Wno-string-plus-int",
        "-Wno-unused-parameter",

> 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.

__android_log_write is in the NDK.

> 4) Build, with the same LDFLAGS and CROSS_COMPILE and run the result under
> qemu-x86_64 -cpu Nehalem.f (The default cpu qemu emulates has the same immediate
> segfault in the start code my netbook does, but if you have it fake an i7 it works.)
>
> But hey, I have some sort of test environment now. :)
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



More information about the Toybox mailing list