cmd/gomobile: Use parallel build for frameworks on Apple platforms
Currently the build for different targets and CPU architectures is sequential. Even for a small project, it usually takes about one minute to build for -target maccatalyst,ios,iossimulator,macos, which is very different from our perception of build speed of Golang.
By adopting this parallel build approach, we can save a lot of time.
Simple visualization (gomobile bind -target maccatalyst,ios,iossimulator,macos ...):
Main Branch
- Build Mac Catalyst (amd64)
- Build Mac Catalyst (arm64)
- Merge into a fat binary
- Build iOS (arm64)
- Build iOS Simulator (amd64)
- Build iOS Simulator (arm64)
- Merge into a fat binary
- Build macOS (amd64)
- Build macOS (arm64)
- Merge into a fat binary
- Create xcframework
This PR
- Build different architectures in parallel
- Merge different architectures for a single target into a fat binary (this is the limitation of xcodebuild. In theory, we don't need to do so. Reference: https://developer.apple.com/forums/thread/666335?answerId=685927022#685927022)
- Create xcframework
Quick Benchmark
Local machine comparison with a minimal demo Golang project (on M1 Max):
Sample 1
Official demo: https://github.com/golang/mobile/tree/master/example/bind/hello
# This PR
$ time gomobile-parallel bind -v -target maccatalyst,ios,iossimulator,macos -o /path/to/parallel/Demo.xcframework
gomobile-parallel bind -v -target -o 29.46s user 18.07s system 303% cpu 15.645 total
# Main Branch
$ time gomobile bind -v -target maccatalyst,ios,iossimulator,macos -o /path/to/sequential/Demo.xcframework
gomobile bind -v -target maccatalyst,ios,iossimulator,macos -o 27.10s user 13.18s system 77% cpu 52.052 total
Sample 2
# This PR
gomobile-parallel bind -target -o 30.98s user 17.43s system 183% cpu 26.400 total
# Main branch
gomobile bind -target maccatalyst,ios,iossimulator,macos -o 25.80s user 13.17s system 38% cpu 1:42.43 total
This PR (HEAD: 7a4f454e11fd7cbfa3d5c07dc27e8536dee90f8a) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
Message from Gopher Robot:
Patch Set 1:
Congratulations on opening your first change. Thank you for your contribution!
Next steps: A maintainer will review your change and provide feedback. See https://golang.org/doc/contribute.html#review for more info and tips to get your patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be surprising to people new to the project. The careful, iterative review process is our way of helping mentor contributors and ensuring that their contributions have a lasting impact.
Please don’t reply on this GitHub thread. Visit golang.org/cl/375134. After addressing review feedback, remember to publish your drafts!
This PR (HEAD: 0572ebcc29614dc1491849958a596813ccc887a0) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
This PR (HEAD: 6e4c23ba23586abc075161606c7e3c199f1805ca) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
This PR (HEAD: 45c426714eb65ef5927fb37705e354d4d5b23aaa) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
This PR (HEAD: 1b903c74b694baa0218c2b1996b8868753df0d45) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
This PR (HEAD: 50d954c8a2dd2b0bd72545ac4279ef51533ce2b8) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
This PR (HEAD: fd0e9491da4415266824a6cf0d555422f05c15b6) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
This PR (HEAD: faf4e940650a19f37d887b0bb4ef712a27f52177) has been imported to Gerrit for code review.
Please visit https://go-review.googlesource.com/c/mobile/+/375134 to see it.
Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info
@hyangah gentle ping : )