From 44d5840c45f2c66fcbb3eae5603b8d2eaf01e728 Mon Sep 17 00:00:00 2001 From: jolavillette Date: Mon, 17 Aug 2026 09:08:59 +0200 Subject: [PATCH] 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) --- CMakeLists.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca90289ff..146fd1992 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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")