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: gomobile bind on M1 panics when building for iOS if the Android NDK is installed #47296

Closed
iamcalledrob opened this issue Jul 20, 2021 · 2 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@iamcalledrob
Copy link

iamcalledrob commented Jul 20, 2021

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

$ go version
go version go1.16.5 darwin/arm64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/rob/Library/Caches/go-build"
GOENV="/Users/rob/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rob/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/rob/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/rob/Code/push/xplat/go.mod"
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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3l/mj1p0_6x3dnb850mkd9ph8b00000gn/T/go-build3886656969=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I ran gomobile bind -target ios on an Apple Silicon mac with the Android NDK installed (and therefore ANDROID_NDK_HOME exported to my path).

What did you expect to see?

The bind command execute and build for iOS.

What did you see instead?

panic: unsupported GOARCH: arm64

goroutine 1 [running]:
main.archNDK(...)
	/Users/rob/go/pkg/mod/golang.org/x/mobile@v0.0.0-20210716004757-34ab1303b554/cmd/gomobile/env.go:298
main.(*ndkToolchain).Path(0x140000a3bc0, 0x140000180d1, 0x2f, 0x10506e3c2, 0x5, 0x0, 0x140000a39f8)

There seem to be 2 compounding issues leading to this:

  1. archNDK() panics when run on arm64. (Ideally, the NDK could be invoked using Rosetta if the GOARCH is arm64)
  2. env.go attempts to set up the Android cross-compiler (invoking archNDK()) even when the gomobile target is iOS.

This leads to the issue that simply having the NDK installed causes a panic—even when building for iOS only.

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jul 20, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jul 20, 2021
@AlexRouSg
Copy link
Contributor

Looks like a duplicate of #46464

@seankhliao
Copy link
Member

Duplicate of #46464

@seankhliao seankhliao marked this as a duplicate of #46464 Jul 20, 2021
@golang golang locked and limited conversation to collaborators Jul 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

4 participants