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/cmd/gomobile: brackets expression not supported on this target #43331

Open
nathan-fiscaletti opened this issue Dec 22, 2020 · 5 comments
Open

Comments

@nathan-fiscaletti
Copy link
Contributor

@nathan-fiscaletti nathan-fiscaletti commented Dec 22, 2020

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

$ go version
go version go1.13.8 darwin/amd64

Does this issue reproduce with the latest release?

I don't believe this issue is related to Go itself, but instead to the gomobile package.

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

go env Output
$ go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/nathanf/Library/Caches/go-build"
GOENV="/Users/nathanf/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/nathanf/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.8/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.8/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w3/_t_vv2jd6tb1hvj_m7jffg940000gn/T/go-build297220612=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I installed gomobile using the following commands:

$ go get golang.org/x/mobile/cmd/gomobile
$ gomobile init

After which, i attempted to build a project using gomobile bind -target ios, however when I do i see a bunch of these messages spat out.

gcc_arm64.S:27:16: error: brackets expression not supported on this target
 stp x19, x20, [sp, #-16]!

I think this may be an old issue that was closed back in go1.5: #11339

I'm not seeing the darwin_arm or darwin_arm64 directories in my $GOROOT/pkg directory, and i think I'm supposed to be.

What did you expect to see?

The iOS Framework compiled successfully.

What did you see instead?

The above errors.

@nathan-fiscaletti nathan-fiscaletti changed the title gomobile: cmd/gomobile: brackets expression not supported on this target Dec 22, 2020
@networkimprov
Copy link

@networkimprov networkimprov commented Dec 22, 2020

Have you tried with Go 1.15? 1.13 is no longer supported.

@ebilling
Copy link

@ebilling ebilling commented Dec 24, 2020

I'm seeing the same issue with go1.16beta1 (dropped this week) on the new M1 Mac.

However, when I build go from source from commit a508840 (last week), it works fine.

@dmitshur dmitshur changed the title cmd/gomobile: brackets expression not supported on this target x/mobile/cmd/gomobile: brackets expression not supported on this target Dec 30, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 30, 2020
@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Dec 30, 2020

Is this problem reproducible even with a small iOS project on a supported version of Go? If so, can you please share a complete sequence of steps to trigger the problem, and include the full output? (If it's large, you can paste it elsewhere and link to it, or place it in a <details> tag.)

CC @cherrymui, @hajimehoshi.

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Dec 30, 2020

That error is due to the C compiler targeting the wrong architecture. It would be good to know how the Go toolchain and C toolchain are invoked. (I'm not familiar with gomobile to tell.)

@ebilling if you are on an M1, it may be due to x86 environment "slips" in, which causes the C compiler being invoked as an x86 binary (instead of ARM64 binary), which targets x86 by default. It may be helpful to run commands under arch -arm64. (Does gomobile set C flags (e.g. -arch arm64) explicitly?)

@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Dec 30, 2020

(Does gomobile set C flags (e.g. -arch arm64) explicitly?)

I believe it does, see https://github.com/golang/mobile/blob/e6ae53a27f4fd7cfa2943f2ae47b96cba8eb01c9/cmd/gomobile/env.go#L170-L172.

The original issue had go get golang.org/x/mobile/cmd/gomobile as the command that was run, which may install an old version of gomobile if it were invoked outside a directory containing a go.mod file (i.e., if there was an old version of x/mobile in GOPATH and GOPATH mode was selected). We still need to confirm if this is a problem when using the latest gomobile and Go 1.15 (or 1.16 beta).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants