specs: design for dropping Cgo on mobile (iOS purego, Android non-goal)#123
Merged
Conversation
9404129 to
39ec2ca
Compare
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.
Design spec only — no implementation — following the #118 precedent for the Linux design PR.
Summary
Completes the Cgo-removal track (darwin #117, Linux #120, BSD #121) for the two remaining mobile backends, after investigating both. The investigation produced a clean split on a single test: can the platform's clipboard backend function without importing a package that itself requires Cgo?
clipboard_ios.goimports nox/mobilepackage (UIPasteboardis process-global), andGOOS=ios CGO_ENABLED=0 go build stdpasses. Port it to the samepurego/objcpasteboard binding shipped for darwin (darwin: remove the Cgo / C-toolchain dependency (purego) (#69) #117), retargeted toUIPasteboard; deleteclipboard_ios.m. Simpler than darwin: text-only, no image, no TIFF, noDlsym.x/mobile/app.RunOnJVM→mobileinit.RunOnJVM→C.lockJNI(Cgo), and gomobile Android apps are-buildmode=c-sharedvia the NDK regardless. No source change; the spec records the full dependency analysis and rejects the purego-over-JNI alternative (churn, no toolchain win).Notable findings
CGO_ENABLED=0,clipboard.goresolves toundefined: initialize/read/write/watch— neither a backend nor the graceful stubs link. The iOS port fixes it for iOS.clipboard_ios.m:return (char *)[str UTF8String]returns a pointer into autoreleased storage without copying. The purego port copies bytes out, with a regression test.No open tracking issue exists for mobile (closed #8/#70); references the sibling #69/#25 and builds on #117.