[Toybox] toys/android/log.c with android NDK?

Rob Landley rob at landley.net
Sat Mar 10 20:26:45 PST 2018


On 03/09/2018 03:54 PM, enh wrote:
> well, that took a lot longer than expected... but r17beta1 is out now
> with an up-to-date libc.a.
> 
> download: https://github.com/android-ndk/ndk/wiki#current-beta-release
> release notes: https://github.com/android-ndk/ndk/wiki/Changelog-r17-beta1
> 
> standalone toolchain example:
> https://developer.android.com/ndk/guides/standalone_toolchain.html#building_open_source_projects_using_standalone_toolchains
> 
> (https://developer.android.com/ndk/downloads/index.html should update
> later this afternoon.)

Let's see...

$ sudo build/tools/make_standalone_toolchain.py --arch x86_64 --api 26 \
  --stl=libc++ --install-dir=/opt/android/x86-64
$ CROSS_COMPILE=/opt/android/x86-64/bin/llvm- CFLAGS=--static make defconfig
It has no llvm-cc... ok then:
$ sudo ln -s clang /opt/android/x86-64/bin/llvm-cc
$ CROSS_COMPILE=/opt/android/x86-64/bin/llvm- CFLAGS=--static make defconfig
$ CROSS_COMPILE=/opt/android/x86-64/bin/llvm- CFLAGS=--static make
many warnings ignored...
generated/obj/log.o:log.c:function log_main: error: undefined reference to
'__android_log_write'
$ CROSS_COMPILE=... make menuconfig # switch off log in android menu.
$ CROSS_COMPILE=... make
more warnings, more warnings...
scripts/make.sh: line 28: /opt/android/x86-64/bin/llvm-strip: No such file or
directory
strip failed, using unstripped
$ ./toybox
Illegal instruction (core dumped)
landley at driftwood:~/toybox/clean$ file toybox
toybox: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), statically linked,
not stripped

Well... it's certainly progress. :)

I'll see if I can work out why it doesn't run...

$ /opt/android/x86-64/bin/llvm-cc --static hello.c
$ ./a.out
Illegal instruction (core dumped)

Because a statically linked hello world segfaults on ubuntu 14.04, would be why.

The warnings, by the way, are primarily:

toys/posix/iconv.c:53:5: warning: implicit declaration of function 'iconv' is
      invalid in C99 [-Wimplicit-function-declaration]
    iconv(TT.ic, &in, &inlen, &out, &outlen);
    ^
toys/posix/iconv.c:70:31: warning: implicit declaration of function 'iconv_open'
      is invalid in C99 [-Wimplicit-function-declaration]
  if ((iconv_t)-1 == (TT.ic = iconv_open(TT.to, TT.from)))
                              ^
toys/posix/iconv.c:73:24: warning: implicit declaration of function
      'iconv_close' is invalid in C99 [-Wimplicit-function-declaration]
  if (CFG_TOYBOX_FREE) iconv_close(TT.ic);

And that file is doing #include <iconv.h> so I don't see _why_ it's not getting
them?

Rob


More information about the Toybox mailing list