Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: No way to identify when being built for iossimulator #58539

Open
rob-deutsch opened this issue Feb 15, 2023 · 2 comments
Open

x/mobile: No way to identify when being built for iossimulator #58539

rob-deutsch opened this issue Feb 15, 2023 · 2 comments
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@rob-deutsch
Copy link

rob-deutsch commented Feb 15, 2023

What version of Go are you using (go version)?

$ go version
go version go1.19.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes. This is the latest release

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/rob/Library/Caches/go-build"
GOENV="/Users/rob/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rob/go/pkg/mod"
GONOPROXY="github.com/rob-deutsch"
GONOSUMDB="github.com/rob-deutsch"
GOOS="darwin"
GOPATH="/Users/rob/go"
GOPRIVATE="github.com/rob-deutsch"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_s/36069dcj0c9dffd1lsrg4l_h0000gn/T/go-build106360914=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Created a library that relies on statically linked libraries (included as .syso)
  2. Make sure that there are different .syso files for the iOS sdk and the iPhoneSimulator sdk
  3. Ran gomobile bind -target ios/arm64,iossimulator/arm64 -o Library.xcframework

What did you see?

Received this error message:

gomobile: xcodebuild -create-xcframework -framework /var/folders/_s/36069dcj0c9dffd1lsrg4l_h0000gn/T/gomobile-work-4172868616/iossimulator/iphonesimulator/Library.framework -framework /var/folders/_s/36069dcj0c9dffd1lsrg4l_h0000gn/T/gomobile-work-4172868616/ios/iphoneos/Library.framework -output Library.xcframework failed: exit status 70
error: binaries with multiple platforms are not supported '/var/folders/_s/36069dcj0c9dffd1lsrg4l_h0000gn/T/gomobile-work-4172868616/iossimulator/iphonesimulator/Library.framework/Library'

This issue is caused by the fact that go is trying to link the ios static libraries instead of the iossimulator static library.

What did you expect to see?

There needs to be a way to use build tags to identify whether we're building for ios/arm64 or iossimulator/arm64. That way different static libraries can be linked depending on e.g.:

//go:build arm64 && ios && !iossimulator

and

//go:build arm64 && ios && iossimulator

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Feb 15, 2023
@gopherbot gopherbot added this to the Unreleased milestone Feb 15, 2023
@changkun
Copy link
Member

If I recall correctly, iossimulator is not a build tag but a build target of the gomobile command.

@rob-deutsch
Copy link
Author

That's correct, but it should also be a build tag, because the compiler might need to know when gomobile is building the iossimulator build target.

My Go build needs to do different things depending on whether its being built for ios or iossimulator.

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
None yet
Development

No branches or pull requests

5 participants