Android: use the librnp built for the sysroot instead of rebuilding it inline

prepare-toolchain-clang.sh builds librnp and installs it in the Android
sysroot, but our own configure ignores it and builds librnp a second time,
inline, whenever ../supportlibs/librnp exists -- which is the case as soon as
libretroshare is checked out inside the RetroShare super-project instead of
standalone.

That inline build cannot work: librnp's CMake compiles findopensslfeatures
and runs it to enumerate the OpenSSL features, and that binary is an Android
executable the build host cannot execute. Where binfmt/qemu picks it up, as
on WSL, it fails on the missing Android dynamic linker:

  CMake Error at supportlibs/librnp/cmake/Modules/FindOpenSSLFeatures.cmake:151:
    Error getting supported OpenSSL hashes: 255
    qemu-aarch64: Could not open '/system/bin/linker64': No such file or directory

Prefer the pre-built library on Android, falling back to the previous
behaviour when none is installed. Desktop builds are untouched: RS_ANDROID is
OFF there, so the local librnp source is still used exactly as before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
jolavillette 2026-08-17 09:08:59 +02:00
parent 339c765235
commit 44d5840c45

View File

@ -379,7 +379,23 @@ if(RS_RNPLIB)
set(RNPLIB_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../supportlibs/librnp/")
if(EXISTS "${RNPLIB_DEVEL_DIR}/CMakeLists.txt")
## On Android prefer an already built and installed librnp, which
## prepare-toolchain-clang.sh puts in the sysroot before configuring us.
## Building it inline instead cannot work: librnp's CMake runs a freshly
## compiled findopensslfeatures to enumerate the OpenSSL features, and that
## binary is an Android executable the build host cannot run -- either not
## at all, or through binfmt/qemu which then fails on the missing Android
## dynamic linker:
## qemu-aarch64: Could not open '/system/bin/linker64': No such file or
## directory
## The inline build is only reached when libretroshare is checked out
## inside the RetroShare super-project, which is why building from a
## standalone clone has always worked.
if(RS_ANDROID)
find_library(RS_PREBUILT_RNP_LIBRARY NAMES rnp)
endif(RS_ANDROID)
if(NOT RS_PREBUILT_RNP_LIBRARY AND EXISTS "${RNPLIB_DEVEL_DIR}/CMakeLists.txt")
message(STATUS "librnp source found at ${RNPLIB_DEVEL_DIR} using it")
rnplib_set_inline_build_options()
add_subdirectory("${RNPLIB_DEVEL_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/librnp")