Repository navigation
Flag lmdb text_env as code so Debug iOS links - #9
Conversation
650953e to
5a2411f
Compare
peachbits
left a comment
There was a problem hiding this comment.
The mechanism checks out: the anchor matches the pinned mdb.c exactly once, all 52 ESECT symbols are functions so pure_instructions is accurate, and the moneroPatchTag bump does force lwsf.build.* to recompile through the dirty-dep cascade in scripts/utils/tasks.ts. No correctness findings. The four notes below are housekeeping.
peachbits
left a comment
There was a problem hiding this comment.
housekeeping items worth addressing before merging
|
All four housekeeping threads are fixed and resolved: the Related row now points at the merge commit of accountbased#1055 with the anchor that exists there, both code permalinks are repo-relative, the arm64_b26 link label is closed, and the cacheTag comment states the real mechanism with the tag bumped to |
The vendored LMDB in monero puts its infrequently used env functions in a private __TEXT,text_env section. The two-field Mach-O section spec leaves S_ATTR_PURE_INSTRUCTIONS unset, so ld does not treat the section as code: it sorts it past every real code section and will not plant a branch island into it. A Debug simulator build carrying all four large native wallet libraries pushes __TEXT to ~190MB, which puts text_env beyond the +/-128MB reach of arm64 B/BL, and the link fails on an arm64_b26 fixup error against _mdb_mutex_failed. Release links only because its __TEXT is ~50MB smaller. Patch the section spec to its full form so the section carries the same flags as __text. The section survives, so upstream's grouping still holds. The patch asserts its own anchor and the clone cacheTag now carries a patch revision, since getRepo checks the tree out fresh on every cache miss.
5a2411f to
3e86c2c
Compare
Technical Design Document
lmdb-text-env-arm64-debug-link.md
Description
A Debug iOS simulator build of edge-react-gui carrying all four large native wallet libraries (react-native-pirate-wallet, react-native-zcash, react-native-monero, react-native-zano) fails to link:
The LMDB vendored inside monero puts about 50 rarely used environment functions in a private section through its
ESECTmacro, which on Apple expands to__attribute__((section("__TEXT,text_env"))). That two-field Mach-O specifier leavesS_ATTR_PURE_INSTRUCTIONSunset, so ld does not count the section as code: it sorts it past every real code section (173MB into a 190MB__TEXT) and will not plant a branch island for a call that crosses the +/-128MBB/BLreach. Release links only because its__TEXTis about 50MB smaller.This spells the section out in full, so
text_envcarries the same flags as__textand ld sorts it directly after__text. The section survives, so upstream's grouping of cold environment functions still holds.Two supporting pieces come with it:
String.replaceno-ops when the pattern misses, so a drifted monero would silently produce an unpatched module and a link that fails again for a reason nobody would connect to this change. The throw turns that into a build failure naming the patch, matching the existingrpc.cpppatch in the same file.monero.clonecacheTag (1-esect). The tag does not hash the patch text, so on a cache hitmonero.cloneis skipped outright and the tree keeps whatever the previous run left in it; bumping the leading revision digit is what makes an edited patch rebuild.Asana: Monero: fix iOS debug build linking
Testing
All measurements on 2026-09-07 against edge-react-gui at
f15eb640(branchagent/1214721783909451, react-native-pirate-wallet 0.3.4), untrimmed (zcash, monero and zano all autolinked), on an iOS 18.6 simulator.arm64-apple-ios-simulator: the two-field section spelling gives section flags0x00000400; the four-field spelling gives0x80000400, addingS_ATTR_PURE_INSTRUCTIONS, which is what__textcarries.otool -lover the rebuiltMoneroModule.xcframework:text_envcarries0x80000400onios-arm64and on both simulator architectures. The published 0.4.2 artifact carries0x00000000.node_modules/react-native-monero/ios/:** BUILD FAILED **with thearm64_b26error above, reproducing the report exactly.** BUILD SUCCEEDED **, zeroarm64_b26lines and zerotext_envlines.text_envmoved from0x00ada62e0to0x005f6e5b8, directly after__text, so no branch island is needed at all.edge-rjqa3, wallet "My Monero" synced to 0.001891391795 XMR ($0.97).createTransactionandbroadcastTransactionboth ran against the rebuilt module.verify-repo.shpasses (changelog, prepare, eslint).Not done here: the version commit and publish (this repo cuts the version as its own commit at publish time), then the edge-react-gui pin bump from 0.5.0 to the new version. That bump is a pin change only: develop and edge-currency-accountbased master already consume 0.5.0.
Cases 4-6 above ran the pirate branch's 0.4.2 JavaScript against the rebuilt native module. That is safe because the compiled
MoneroEngine.broadcastTxin that branch's node_modules discardsbroadcastTransaction's return value, the only surface 0.5.0 changed.Test evidence
5a2411fFlag lmdb text_env as code so Debug iOS links
untrimmed debug build launched
xmr wallet synced
xmr send transaction success
Note
Medium Risk
Changes native monero/LMDB compile output and iOS linking layout; wrong or stale patches could break builds or regress Debug links, though runtime LMDB semantics are unchanged.
Overview
Fixes Debug iOS simulator link failures (
arm64_b26/_mdb_mutex_failed) when the app bundles several large native wallet libraries. Vendored LMDB’s AppleESECTmacro used a two-field Mach-O section name, so__TEXT,text_envwas not treated as code and landed ~173MB into__TEXT, beyond arm64B/BLreach.During
monero.cloneinscripts/libraries/lwsf.ts, the patch rewritesmdb.cto use a full section specifier (regular,pure_instructions), matching__textso the linker laystext_envwith other code. A failed anchor check aborts the build if upstreammdb.cdrifts, andmoneroPatchTagis appended to the clone cacheTag so edited patches are not served from a stale cached tree.CHANGELOG records the fix;
src/docs/lmdb-text-env-arm64-debug-link.mddocuments problem, design, and verification. No JS or wallet API changes; rebuiltMoneroModule.xcframeworkonly.Reviewed by Cursor Bugbot for commit 3e86c2c. Bugbot is set up for automated code reviews on this repo. Configure here.