Repository navigation
Conversation
Make recrypt-openfhe-sys cross-compile for iOS and Android (NDK) without a local [patch] override: - resolve_openfhe_install(): OPENFHE_INSTALL_DIR env (target-specific prebuilt cone) takes priority over the desktop vendor/openfhe-install default. - target_os() via CARGO_CFG_TARGET_OS (build scripts run on the HOST, so cfg!(target_os) is wrong for cross builds). - C++ stdlib link: macos/ios -> c++, android -> c++_shared (NDK cdylib convention; APK bundles libc++_shared.so), linux -> stdc++. - link_openmp(): no-op on ios/android (OpenFHE built WITH_OPENMP=OFF). - -Wno-error on ios/android (OpenFHE headers trip -Werror under those clangs). Lets the NAOMS fork-pin build android directly with OPENFHE_INSTALL_DIR pointing at the per-ABI OpenFHE cone — no worktree-local clone / committed [patch] to a gitignored path (1054 cargo-patch-fix).
The mobile (android/iOS) artifact consuming OpenFHE is a cdylib (libnaoms_core.so). A cdylib tolerates undefined symbols, so the default rustc-link-lib=static= leaves the OpenFHE CKKS typeinfo/vtable (_ZTIN8lbcrypto23CryptoParametersCKKSRNSE et al.) UNDEFINED in the .so even though they are defined (D) in libOPENFHEpke_static.a. On-device dlopen then fails: "typeinfo for lbcrypto::CryptoParametersCKKSRNS is missing". rustc-link-arg is NOT forwarded from this -sys crate to naoms-core's final cdylib link, and --start-group does not help a cdylib that permits UND. The propagating static:+whole-archive= link-lib form force-includes every archive member AND propagates transitively to the cdylib link, so the definitions land in the .so. Desktop/linux link a real executable that already forces resolution, so keep plain static= there. Verified aarch64-linux-android: nm -D shows CKKS typeinfo/vtable DEFINED, 0 UND lbcrypto symbols; dlopen(RTLD_NOW) on an arm64-v8a emulator returns DLOPEN_OK. 1054 android on-device daemon dlopen blocker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
recrypt-openfhe-syscross-compile and link for iOS and Android. NAOMS has shipped these build changes on its desktop, iOS and Android builds since June, from a fork. This PR brings them upstream so we can pin yourmainagain.What changes (
crates/recrypt-openfhe-sys/build.rsonly)CARGO_CFG_TARGET_OSinstead ofcfg!(target_os), which reflects the host a build script runs on, not the target.OPENFHE_INSTALL_DIR. An optional absolute path to a target-specific OpenFHE install, such as an iOS device or simulator build or an aarch64-android build. The default staysvendor/openfhe-install. It also addsrerun-if-env-changed.+whole-archivelinking forOPENFHEpke/core/binfhe_static, using the propagatingrustc-link-libform.static=, a downstream Android cdylib ended up missing the CKKS typeinfo and vtables, sodlopenfailed on the device ("typeinfo for lbcrypto::CryptoParametersCKKSRNS is missing").c++on macOS and iOS,c++_sharedon Android (the NDK convention for cdylibs),stdc++on Linux.WITH_OPENMP=OFFthere.-Wno-erroron iOS and Android, where OpenFHE headers trip-Werrorunder clang.+whole-archivealso applies on desktop now. It only force-includes members of OpenFHE's own static libraries.Verification
mainat 0be9ed9 (git merge-tree).build.rshas not changed upstream since 88ec30f.main:BUILD_STATIC=ON,WITH_OPENMP=OFF.cargo test -p recrypt-openfhe-sys -p recrypt-core --lib -- --test-threads=1.mainfor this PR.Not included: one Android fix that belongs in OpenFHE
OpenFHE's
src/core/lib/utils/get-call-stack.cpp(around line 33) guards the glibcexecinfo.h/backtrace()path with#if defined(__linux__) && defined(__GNUC__). Android is__linux__, clang defines__GNUC__, and bionic has noexecinfo.h, so the Android build fails. Adding&& !defined(__ANDROID__)falls through to the existing no-op#else.Our fork vendored all of OpenFHE to carry that one line, which isn't right for this repo. It probably belongs upstream in openfheorg, or in a patch step here. Happy to do either, whichever you prefer.
Commits keep their original authorship. The last commit only removes downstream-specific wording from the comments.
🤖 Generated with Claude Code