Skip to content

Android cross-compiling: cdump-enumstr fails; must call ranlib on libjsmn.a to fix it  #3473

@remyers

Description

@remyers

Issue and Steps to Reproduce

I had to do some kludgy things to get it to compile and I'm looking for suggestions for my build script and procedure.

System: Ubuntu 18.04.3 LTS (bionic)

  1. followed steps in INSTALL.md for building on Ubuntu. Built succeeded as described.

  2. followed steps for cross-compiling for Android. Build succeeded only after some changes to the procedure described in INSTALL.md.

  3. Installed and tested qemu-user with these steps:

$ apt-get install qemu binfmt-support qemu-user-static
$ update-binfmts --display  | grep arm
  qemu-arm (enabled)
  qemu-armeb (enabled)
  1. Downloaded and unzipped Linux 64-bit (x86) | android-ndk-r21-linux-x86_64.zip in ~/src/android-ndk-r21..

5) Kludge needed for cdump-enumstr to build:
$ cp ./ccan_compat.h ./ccan/ccan_compat.h

  1. Run the following script: android_helper.sh
#!/bin/sh
make clean
ANDROID_NDK=$HOME/src/android-ndk-r21
HOST_TAG=linux-x86_64
ANDROID_PREFIX=${ANDROID_NDK}/toolchains/llvm/prebuilt/${HOST_TAG}

export PATH=$PATH:${ANDROID_PREFIX}/bin
# Change next line depending on target device arch
target_host=arm-linux-androideabi
 
export AR=$target_host-ar
export AS=$target_host-clang
export CC=$target_host-clang
export CXX=$target_host-clang++
export LD=$target_host-ld
export STRIP=$target_host-strip
 
# Two makefile targets should not be cross-compiled so we specify a native CC:
make CC=clang clean ccan/tools/configurator/configurator

make clean -C external/jsmn \
  && make -C external/jsmn
# KLUDGE:
ranlib external/libjsmn.a 

make clean -C ccan/ccan/cdump/tools \
 && make -C ccan/ccan/cdump/tools
 
ANDROID_VERSION=28
# QUESTION: we define MAKE_HOST as armv7a for libwally.. why?
target_host2=armv7a-linux-androideabi${ANDROID_VERSION}

BUILD=x86_64 \
MAKE_HOST=$target_host2 \
make PIE=1 DEVELOPER=0 CONFIGURATOR_CC="arm-linux-androideabi-clang -static"

# KLUDGE: call ranlib and rerun make
ranlib external/libjsmn.a

BUILD=x86_64 \
MAKE_HOST=$target_host2 \
make PIE=1 DEVELOPER=0 CONFIGURATOR_CC="arm-linux-androideabi-clang -static"
  1. Without the kludges above, cdump-enumstr fails to build because libjsmn.a has no index.

  2. There should be a note in INSTALL.md that warns that it's impossible to cross-compile clightning (directly) on OSX because there is no way to install qemu-user-static.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions