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: build failing when using go modules #27234

Open
mirza-s opened this Issue Aug 26, 2018 · 8 comments

Comments

Projects
None yet
9 participants
@mirza-s

mirza-s commented Aug 26, 2018

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

go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN="/Users/mbp/go/bin"
GOCACHE="/Users/mbp/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mbp/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mbp/wrk/src/libfp/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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/go-build526348344=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

gomobile bind -target=android .

What did you expect to see?

Normal build as when building inside GOPATH

What did you see instead?

gomobile: go build -buildmode=c-shared -o=/var/folders/nt/0hzfppd92jvbk99fhvnhy8ph0000gn/T/gomobile-work-327189385/android/src/main/jniLibs/armeabi-v7a/libgojni.so gobind failed: exit status 1
go: finding github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d
go: finding golang.org/x/mobile v0.0.0-20180808221059-bceb7ef27cc6
can't load package: package gobind: unknown import path "gobind": cannot find module providing package gobind
@hajimehoshi

This comment has been minimized.

Contributor

hajimehoshi commented Sep 10, 2018

Hi, what's going on this?

@wangyun

This comment has been minimized.

wangyun commented Sep 19, 2018

I have the same issue but with some different error message:

gomobile: /home/wangyun/dev/gopath/bin/gobind -lang=go,java -outdir=/tmp/gomobile-work-948078978 testaar failed: exit status 1
unable to import bind: cannot find package "golang.org/x/mobile/bind" in any of:
/home/wangyun/dev/software/go/src/golang.org/x/mobile/bind (from $GOROOT)
/home/wangyun/dev/gopath/src/golang.org/x/mobile/bind (from $GOPATH)
unable to import bind: cannot find package "golang.org/x/mobile/bind" in any of:
/home/wangyun/dev/software/go/src/golang.org/x/mobile/bind (from $GOROOT)
/home/wangyun/dev/gopath/src/golang.org/x/mobile/bind (from $GOPATH)
unable to import bind/java: cannot find package "golang.org/x/mobile/bind/java" in any of:
/home/wangyun/dev/software/go/src/golang.org/x/mobile/bind/java (from $GOROOT)
/home/wangyun/dev/gopath/src/golang.org/x/mobile/bind/java (from $GOPATH)

I'm using go 1.11 and updated gomobile, gobind to the latest version.

@evenardo

This comment has been minimized.

evenardo commented Oct 10, 2018

'''
env go111module=off gomobile bind
'''
it's will temporarily worked fine

@myitcv

This comment has been minimized.

Member

myitcv commented Nov 14, 2018

cc @eliasnaur - some time has elapsed since this issue and I'm not sufficiently up to speed to know whether mobile is now modules-aware.

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Nov 14, 2018

@glenfordwilliams

This comment has been minimized.

glenfordwilliams commented Nov 28, 2018

is there work currently being done on this front?

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Nov 28, 2018

Not yet, at least not from my side. Partly because of time available, partly because I prefer to wait for module support to mature (GO111MODULE always on, the go/packages package feature complete and so on), but the main stumbling block is that I can't see the gomobile bind mode work as usual in module mode, at least not in its current form.
The problem is vendoring: gomobile bind generates a main package that in turn imports the packages you want to export to Java or Objective C. That works well in GOPATH mode, but not in module mode. Suppose gomobile bind in module mode generates a module containing a main package and your module as a dependency. Then, because vendored packages are only respected for the main module, any vendored packages from your module will be ignored by the go tool.
Perhaps some form of #26640 will help gomobile. Perhaps gomobile bind should work in a different way. I haven't thought that much about it.

@eliasnaur

This comment has been minimized.

Contributor

eliasnaur commented Nov 28, 2018

I started a conversation about gomobile and modules here: https://groups.google.com/forum/#!topic/golang-dev/C0ip7pFC2Oc

One question I would like you to ponder on that thread is whether it would be acceptable to require gomobile users to first generate glue code with the gobind tool and then only let the gomobile tool do the final packaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment