openssl: Android build of latest OpenSSL_1_1_1-stable fails

OpenSSL build on Anrdoid ndk19 has worked fine at least up to commit 2403153c95b312e0a5a178c516335ee8dd17526c from Aug 17. Latest version from Aug 27 produces shm related compilation warnings:

clang  -I. -Icrypto/include -Iinclude -fPIC -pthread  -target armv7a-linux-androideabi -gcc-toolchain /home/vagrant/android-ndk/r19c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/vagrant/android-ndk/r19c/platforms/android-21/arch-arm -Wa,--noexecstack -Qunused-arguments -Wall -O3 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" -D__ANDROID_API__=21 -isystem /home/vagrant/android-ndk/r19c/sysroot/usr/include/arm-linux-androideabi -isystem /home/vagrant/android-ndk/r19c/sysroot/usr/include -DNDEBUG -D__ANDROID_API__=21 -MMD -MF crypto/rand/rand_unix.d.tmp -MT crypto/rand/rand_unix.o -c -o crypto/rand/rand_unix.o crypto/rand/rand_unix.c
crypto/rand/rand_unix.c:370:5: warning: implicit declaration of function 'shmdt' is invalid in C99 [-Wimplicit-function-declaration]
    shmdt(shm_addr);
    ^

and linking fails like this:

Build baresip arm64-v8a
[1/2] Building C object CMakeFiles/baresip.dir/baresip.c.o
[2/2] Linking C shared library /home/vagrant/build/com.tutpro.baresip/app/build/intermediates/cmake/release/obj/arm64-v8a/libbaresip.so
FAILED: : && /home/vagrant/android-ndk/r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang  --target=aarch64-none-linux-android21 --gcc-toolchain=/home/vagrant/android-ndk/r19c/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/vagrant/android-ndk/r19c/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -DHAVE_INTTYPES_H -O2 -DNDEBUG  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libbaresip.so -o /home/vagrant/build/com.tutpro.baresip/app/build/intermediates/cmake/release/obj/arm64-v8a/libbaresip.so CMakeFiles/baresip.dir/baresip.c.o  -landroid -lOpenSLES /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/baresip/lib/arm64-v8a/libbaresip.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/rem/lib/arm64-v8a/librem.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/re/lib/arm64-v8a/libre.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/openssl/lib/arm64-v8a/libssl.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/openssl/lib/arm64-v8a/libcrypto.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/opus/lib/arm64-v8a/libopus.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/g7221/lib/arm64-v8a/libg722_1.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/ilbc/lib/arm64-v8a/libilbc.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/webrtc/lib/arm64-v8a/libwebrtc.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/zrtp/lib/arm64-v8a/libzrtp.a /home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/bn/lib/arm64-v8a/libbn.a -lz -llog -latomic -lm && :
/home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/openssl/lib/arm64-v8a/libcrypto.a(rand_unix.o): In function `rand_pool_acquire_entropy':
rand_unix.c:(.text+0x394): undefined reference to `shmget'
rand_unix.c:(.text+0x3b4): undefined reference to `shmat'
rand_unix.c:(.text+0x770): undefined reference to `shmget'
/home/vagrant/build/com.tutpro.baresip/app/src/main/cpp/../../../../distribution/openssl/lib/arm64-v8a/libcrypto.a(rand_unix.o): In function `cleanup_shm':
rand_unix.c:(.text+0x89c): undefined reference to `shmdt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (18 by maintainers)

Most upvoted comments

Agreed in general. I think in the moment the straight forward fix would be something like this:

diff --git a/e_os.h b/e_os.h
index fe4c091..858bc40 100644
--- a/e_os.h
+++ b/e_os.h
@@ -28,7 +28,7 @@
  * default, we will try to read at least one of these files
  */
 #  define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom"
-#  ifdef __linux
+#  if defined(__linux) && !defined(__ANDROID__)
 #   ifndef DEVRANDOM_WAIT
 #    define DEVRANDOM_WAIT   "/dev/random"
 #   endif

Bernd Edlinger writes:

fixing a compile error is something different than testing on a target device.

I can do the testing on Android device.