[Toybox] Fun with the android NDK.

enh enh at google.com
Thu Sep 6 15:46:41 PDT 2018


On Mon, Sep 3, 2018 at 9:54 AM Rob Landley <rob at landley.net> wrote:
>
>
>
> 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.

(i was going to file a bug at
https://github.com/android-ndk/ndk/issues/new but danalbert fixed it
quicker than i could file the bug [because i was looking up the
mailing list to give a link to this thread...]. turns out he naturally
uses "--install-dir ~/ndk" which obviously is the shell's problem
rather than python's...
https://android-review.googlesource.com/c/platform/ndk/+/749658 )

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

"there be dragons"... we're moving the platform off binutils as i
speak, but it's very much a work in progress, and we're finding lots
of bugs/differences from binutils.

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

to be clear[er than i was], i actually meant confstr(3).

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