[Toybox] Fun with the android NDK.

Rob Landley rob at landley.net
Sat Sep 8 14:18:55 PDT 2018


On 09/06/2018 05:11 PM, enh wrote:
>> 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.)

I added an #ifdef to portability.h to build getconf with the NDK.

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

It's in the library probe list but the ndk only has liblog.so, not liblog.a, so
the probe goes "it's not there" when building statically. (And I can't run the
dynamic build on an ubuntu host.)

Other than that, I just checked in the fixes and defconfig builds. Can't run it
until I can link it, but just the one warning left, which is an issue I should
fix in the code but probably not this weekend.

Oh, I had to create an llvm-cc symlink to "clang". (CROSS_COMPILE needs prefixed
versions of all the names.)

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

If I provide a prefix, the build uses the prefixed version for strip. Kinda
awkward not to: until now it's been consistent and I got in the habit of being
SURE to use all the prefixed commands for the target at each step and not leak
host toolchain stuff anywhere...

That said, strip basically being a NOP works for me, the result runs and is
testable and the toolchain can get fixed when it gets fixed.

Rob

P.S. The _reason_ you can't use the host strip when cross compiling, the first
one I hit anyway, is that back in the 90's the sh4 hardware developers used
versions of the elf spec translated into japanese to implement their compiler,
and the translation switched codepages in a way that turned _ into a period. So
their assembly prefix on sh4 in the Hitachi compiler was implemented as "."
following the translated docs, and that became the sh4 standard. But the x86
strip converted whatever prefix you were using into _ in some places (just
overwriting whatever was there), and the resulting x86 binary couldn't find
_start. I.E. using x86 strip on an sh4 executable broke it. Maybe they've fixed
it now?



More information about the Toybox mailing list