Summary
cb-mpc does not compile for Android ARM64 (NDK r28, Bionic libc) due to two issues:
-
bzero macro conflict — Android Bionic defines bzero as a macro in <strings.h>. This conflicts with coinbase::bzero() in include/cbmpc/core/buf.h, causing parse errors throughout the codebase.
-
dlinfo / RTLD_DI_LINKMAP unavailable — src/cbmpc/core/error.cpp uses these inside #ifdef __linux__, but Android defines __linux__ without providing dlinfo (glibc extension, not in Bionic).
-
cmake/openssl.cmake platform check — The link_openssl macro only handles IS_LINUX and IS_MACOS, skipping iOS and Android with "unsupported platform".
Environment
- cb-mpc: v0.2.1 (commit from main branch)
- NDK: r28 (28.0.13004108)
- Target:
arm64-v8a, Android API 24
- Host: macOS ARM64
- OpenSSL: 3.6.1 cross-compiled for
android-arm64
Suggested Fix
Three small, non-breaking changes:
1. include/cbmpc/core/buf.h — undef Bionic's bzero macro
#include <cbmpc/core/macros.h>
+// Android Bionic defines bzero as a macro, which conflicts with coinbase::bzero.
+#ifdef bzero
+#undef bzero
+#endif
+
namespace coinbase {
2. src/cbmpc/core/error.cpp — guard glibc-only APIs
-#ifdef __linux__
+#if defined(__linux__) && !defined(__ANDROID__)
class symbols_t {
Same change on two more #ifdef __linux__ blocks in the same file (lines ~229 and ~247) that reference symbols_t.
3. cmake/openssl.cmake — add mobile platforms
- elseif(IS_MACOS)
+ elseif(IS_MACOS OR IS_IOS OR IS_IOS_SIMULATOR OR IS_ANDROID)
The lib path layout (${CBMPC_OPENSSL_ROOT}/lib/libcrypto.a) is the same across all Apple and Android targets.
Result
With these patches applied:
- Android ARM64 (
arm64-v8a): builds successfully, libcbmpc.a 4.1MB stripped (ELF64 AArch64)
- iOS ARM64: builds successfully,
libcbmpc.a 5.0MB (Mach-O arm64, platform iOS, min 15.0)
- macOS ARM64: no change, existing build unaffected
Note: compilation_flags.cmake already has Android-specific linker flags (lines 72-77), suggesting Android support was partially considered but never completed.
Context
We're building a Flutter app that uses cb-mpc via dart:ffi (mobile) and Go CGO (backend). macOS builds work perfectly (validated in our PoC). iOS builds work with just the cmake platform patch. Android needs all three fixes.
Happy to submit a PR if you're open to it. The changes are minimal and don't affect existing Linux/macOS builds.
Related: #67 (iOS support question)
Summary
cb-mpc does not compile for Android ARM64 (NDK r28, Bionic libc) due to two issues:
bzeromacro conflict — Android Bionic definesbzeroas a macro in<strings.h>. This conflicts withcoinbase::bzero()ininclude/cbmpc/core/buf.h, causing parse errors throughout the codebase.dlinfo/RTLD_DI_LINKMAPunavailable —src/cbmpc/core/error.cppuses these inside#ifdef __linux__, but Android defines__linux__without providingdlinfo(glibc extension, not in Bionic).cmake/openssl.cmakeplatform check — Thelink_opensslmacro only handlesIS_LINUXandIS_MACOS, skipping iOS and Android with "unsupported platform".Environment
arm64-v8a, Android API 24android-arm64Suggested Fix
Three small, non-breaking changes:
1.
include/cbmpc/core/buf.h— undef Bionic's bzero macro2.
src/cbmpc/core/error.cpp— guard glibc-only APIsSame change on two more
#ifdef __linux__blocks in the same file (lines ~229 and ~247) that referencesymbols_t.3.
cmake/openssl.cmake— add mobile platformsThe lib path layout (
${CBMPC_OPENSSL_ROOT}/lib/libcrypto.a) is the same across all Apple and Android targets.Result
With these patches applied:
arm64-v8a): builds successfully,libcbmpc.a4.1MB stripped (ELF64 AArch64)libcbmpc.a5.0MB (Mach-O arm64, platform iOS, min 15.0)Note:
compilation_flags.cmakealready has Android-specific linker flags (lines 72-77), suggesting Android support was partially considered but never completed.Context
We're building a Flutter app that uses cb-mpc via dart:ffi (mobile) and Go CGO (backend). macOS builds work perfectly (validated in our PoC). iOS builds work with just the cmake platform patch. Android needs all three fixes.
Happy to submit a PR if you're open to it. The changes are minimal and don't affect existing Linux/macOS builds.
Related: #67 (iOS support question)