[Toybox] Fun with the android NDK.

enh enh at google.com
Thu Sep 6 15:11:44 PDT 2018


On Thu, Sep 6, 2018 at 8:43 AM Rob Landley <rob at landley.net> wrote:
>
> On 09/03/2018 11:54 AM, Rob Landley wrote:
> >> __android_log_write is in the NDK.
> >
> > I'll upgrade the version and try it again.
>
> Ok, installed android-ndk-r18-beta2 with
>
>   build/tools/make_standalone_toolchain.py --arch=x86_64 --api 28 \
>     --stl=libc++ --install-dir=$(readlink -f ~/android/x86_64)
>
> then
>
>   LDFLAGS=--static CROSS_COMPILE=~/android/x86_64/bin/llvm- \
>     make distclean defconfig
>
> and
>
>  LDFLAGS=--static CROSS_COMPILE=~/android/x86_64/bin/llvm- make
>
> Getconfig still died because
>
> ./generated/getconf.h:5:1: error: use of undeclared identifier '_CS_PATH'
> _CS_PATH,_CS_V7_ENV
> ^
> ./generated/getconf.h:5:10: error: use of undeclared identifier '_CS_V7_ENV'
> _CS_PATH,_CS_V7_ENV
>          ^
> toys/posix/getconf.c:139:9: error: implicit declaration of function 'confstr' is
>       invalid in C99 [-Werror,-Wimplicit-function-declaration]
>         confstr(confstr_vals[j], toybuf, sizeof(toybuf));
>
> Ok, switch that off and rebuild (I should add a compile-time probe for confstr),

(makes sense. i don't see us adding confstr(3) to Android any time soon.)

> and...
>
> generated/obj/log.o:log.c:function log_main: error: undefined reference to
> '__android_log_write'
>
> Your statement that this was in the NDK does not appear to be the case yet.

at a guess, you're not linking liblog? the logging functions aren't in libc.

> Ok,
> switch off CONFIG_LOG and:
>
> lvm-strip: Unknown command line argument '-o'.  Try:
> '/home/landley/android/x86_64/bin/llvm-strip -help'
> llvm-strip: Did you mean '-O'?
>
> The prefixed llvm-strip doesn't know the "-o" option specifying output file.

we've had a lot of issues with llvm-strip, so you probably want to
stick to the binutils one for now.

> Hmmm... well, it isn't in posix-2008, I suppose they have a point. I can cp and
> then strip?
>
> $ ls -l toybox
> -r-xr-xr-x 1 landley landley 4213840 Sep  5 14:47 toybox
> $ ~/android/x86_64/bin/llvm-strip toybox
> $ ls -l toybox
> -rwxrwxr-x 1 landley landley 4215248 Sep  5 14:50 toybox
>
> Oh bravo, stripping it made it 2k _bigger_. How the...
>
> $ strip toybox
> $ ls -l toybox
> -rwxrwxr-x 1 landley landley 930944 Sep  5 14:52 toybox
>
> The host one knows how to strip it. And defconfig-ish build is still 930k. With
> glibc it's:
>
> $ ls -l toybox
> -r-xr-xr-x 1 landley landley 1435128 Sep  5 14:59 toybox
>
> And with musl-libc it's:
>
> $ ls -l toybox
> -r-xr-xr-x 1 landley landley 567240 Sep  5 15:02 toybox
>
> So that's sane I suppose...
>
> Rob



More information about the Toybox mailing list