Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a87c1cf

Browse files
hyangahstffabi
authored andcommitted
cmd/gomobile: work around for corrupted build on Mac Catalyst
The problem was observed after Go 1.18. x/mobile requires go1.22.0+. Patch from stffabi@e31230f For golang/go#52299 Co-authored-by: stffabi <[email protected]> Change-Id: I856c68f60ad7c45acf4ae550a1e66747ef7719db Reviewed-on: https://go-review.googlesource.com/c/mobile/+/635342 Auto-Submit: Hyang-Ah Hana Kim <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent ce44b27 commit a87c1cf

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

cmd/gomobile/env.go

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ func platformOS(platform string) string {
6363
case "macos", "maccatalyst":
6464
// For "maccatalyst", Go packages should be built with GOOS=darwin,
6565
// not GOOS=ios, since the underlying OS (and kernel, runtime) is macOS.
66+
// But, using GOOS=darwin with build-tag ios leads to corrupt builds: https://go.dev/issue/52299
67+
// => So we use GOOS=ios for now.
6668
// We also apply a "macos" or "maccatalyst" build tag, respectively.
6769
// See below for additional context.
68-
return "darwin"
70+
return "ios"
6971
default:
7072
panic(fmt.Sprintf("unexpected platform: %s", platform))
7173
}
@@ -82,17 +84,17 @@ func platformTags(platform string) []string {
8284
case "maccatalyst":
8385
// Mac Catalyst is a subset of iOS APIs made available on macOS
8486
// designed to ease porting apps developed for iPad to macOS.
85-
// See https://developer.apple.com/mac-catalyst/.
86-
// Because of this, when building a Go package targeting maccatalyst,
87-
// GOOS=darwin (not ios). To bridge the gap and enable maccatalyst
88-
// packages to be compiled, we also specify the "ios" build tag.
87+
// See
88+
// https://developer.apple.com/mac-catalyst/.
89+
// https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets/49560690#49560690
90+
//
91+
// Historically gomobile used GOOS=darwin with build tag ios when
92+
// targeting Mac Catalyst. However, this configuration is not officially
93+
// supported and leads to corrupt builds after go1.18: https://go.dev/issues/52299
94+
// Use GOOS=ios.
8995
// To help discriminate between darwin, ios, macos, and maccatalyst
9096
// targets, there is also a "maccatalyst" tag.
91-
// Some additional context on this can be found here:
92-
// https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets/49560690#49560690
93-
// TODO(ydnar): remove tag "ios" when cgo supports Catalyst
94-
// See golang.org/issues/47228
95-
return []string{"ios", "macos", "maccatalyst"}
97+
return []string{"macos", "maccatalyst"}
9698
default:
9799
panic(fmt.Sprintf("unexpected platform: %s", platform))
98100
}
@@ -217,17 +219,11 @@ func envInit() (err error) {
217219
cflags += " -mios-simulator-version-min=" + buildIOSVersion
218220
cflags += " -fembed-bitcode"
219221
case "maccatalyst":
220-
// Mac Catalyst is a subset of iOS APIs made available on macOS
221-
// designed to ease porting apps developed for iPad to macOS.
222-
// See https://developer.apple.com/mac-catalyst/.
223-
// Because of this, when building a Go package targeting maccatalyst,
224-
// GOOS=darwin (not ios). To bridge the gap and enable maccatalyst
225-
// packages to be compiled, we also specify the "ios" build tag.
226-
// To help discriminate between darwin, ios, macos, and maccatalyst
227-
// targets, there is also a "maccatalyst" tag.
228-
// Some additional context on this can be found here:
229-
// https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets/49560690#49560690
230-
goos = "darwin"
222+
// See the comment about maccatalyst's GOOS, build tags configuration
223+
// in platformOS and platformTags.
224+
// Using GOOS=darwin with build-tag ios leads to corrupt builds: https://go.dev/issue/52299
225+
// => So we use GOOS=ios for now.
226+
goos = "ios"
231227
sdk = "macosx"
232228
clang, cflags, err = envClang(sdk)
233229
// TODO(ydnar): the following 3 lines MAY be needed to compile

0 commit comments

Comments
 (0)