1

I am trying to build OpenSSH for Android. I am using the current (as of this writing) version, which is 9.3p. Here what I do (mostly taken from Building OpenSSH for Android):

export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/21.0.6113669
export PATH=$PATH:$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
cd ~/src

git clone git@github.com:openssh/openssh-portable.git
cd github-portable
git checkout V_9_3_P1
mkdir -p build/android-arm
autoreconf
# for the moment, build a stripped-down version without zlib and openssl
CHOST="arm-linux-androideabi" \
  CHOST2="armv7a-linux-androideabi17" \
  CC="${CHOST2}-clang" \
  CXX="${CHOST2}-clang++" \
  CFLAGS="-DHAVE_ATTRIBUTE__SENTINEL__=1" \
  CXXFLAGS="-DHAVE_ATTRIBUTE__SENTINEL__=1" \
  RANLIB="${CHOST}-ranlib" \
  LD="${CHOST}-ld" \
  AR="${CHOST}-ar" \
  ARFLAGS="cr" \
  CHOST="${CHOST}" \
  ./configure --host=arm-linux-androideabi --with-libs --without-zlib --without-openssl --prefix=$PWD/build/android-arm
make ssh

CFLAGS and CXXFLAGS are a workaround for another build issue, described in a comment to the question above, as well as https://github.com/android/ndk/issues/1362#issuecomment-712437159.

The build fails with an error, apparently due to some incompatibility between OpenSSH and one of the header files included from NDK:

armv7a-linux-androideabi26-clang -DHAVE_ATTRIBUTE__SENTINEL__=1 -pipe -Wunknown-warning-option -Qunused-arguments -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -Wimplicit-fallthrough -fno-strict-aliasing -mretpoline -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong   -fPIC -I. -I.. -I. -I./..  -DHAVE_CONFIG_H -c bsd-misc.c
bsd-misc.c:392:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
bzero(void *b, size_t n)
      ^
bsd-misc.c:392:16: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
bzero(void *b, size_t n)
               ^
bsd-misc.c:392:1: error: at most one overload for a given name may lack the 'overloadable' attribute
bzero(void *b, size_t n)
^
/home/user149408/tools/android-sdk-linux_86/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/strings.h:61:23: note: expanded from macro 'bzero'
#define bzero(b, len) __bionic_bzero((b), (len))
                      ^
/home/user149408/tools/android-sdk-linux_86/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/strings.h:62:40: note: previous unmarked overload of function is here
static __inline__ __always_inline void __bionic_bzero(void* b, size_t len) {
                                       ^
bsd-misc.c:392:7: error: parameter name omitted
bzero(void *b, size_t n)
      ^
bsd-misc.c:392:16: error: parameter name omitted
bzero(void *b, size_t n)
               ^
bsd-misc.c:394:15: error: use of undeclared identifier 'b'
        (void)memset(b, 0, n);
                     ^
bsd-misc.c:394:21: error: use of undeclared identifier 'n'
        (void)memset(b, 0, n);
                           ^
2 warnings and 5 errors generated.
make[1]: *** [Makefile:106: bsd-misc.o] Error 1
make[1]: Leaving directory '/home/user149408/src/openssh-portable/openbsd-compat'
make: *** [Makefile:199: openbsd-compat/libopenbsd-compat.a] Error 2

Building natively for the host platform (Ubuntu 22.04 x86_64) works.

What’s up here, and what can I do about it?

user149408
  • 5,385
  • 4
  • 33
  • 69

0 Answers0