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: gomobile bind fails a package importing gl #24941

Closed
hajimehoshi opened this issue Apr 19, 2018 · 6 comments
Closed

x/mobile/cmd/gomobile: gomobile bind fails a package importing gl #24941

hajimehoshi opened this issue Apr 19, 2018 · 6 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@hajimehoshi
Copy link
Member

hajimehoshi commented Apr 19, 2018

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

go version go1.10 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=""
GOCACHE="/Users/hajimehoshi/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hajimehoshi/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/7t/qw3np69559591s1v0mk5_p1m0000gn/T/go-build050927311=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

$ cat $GOPATH/src/github.com/hajimehoshi/gomobilebindtest/test.go 
// +build android

package gomobilebindtest

import (
        _ "golang.org/x/mobile/gl"
)

func Foo() {}

$ gomobile bind -v github.com/hajimehoshi/gomobilebindtest

What did you expect to see?

Building succeeds.

What did you see instead?

Building fails with this error:

type-checking package "github.com/hajimehoshi/gomobilebindtest" failed (/Users/hajimehoshi/go/src/github.com/hajimehoshi/gomobilebindtest/test.go:6:4: could not import golang.org/x/mobile/gl (type-checking package "golang.org/x/mobile/gl" failed (/Users/hajimehoshi/go/src/golang.org/x/mobile/gl/gl.go:20:12: undeclared name: context)))
can't load package: package gobind: cannot find package "gobind" in any of:
        /usr/local/go/src/gobind (from $GOROOT)
        /var/folders/7t/qw3np69559591s1v0mk5_p1m0000gn/T/gomobile-work-299819452/src/gobind (from $GOPATH)
        /Users/hajimehoshi/go/src/gobind
gomobile: go build -v -buildmode=c-shared -o=/var/folders/7t/qw3np69559591s1v0mk5_p1m0000gn/T/gomobile-work-299819452/android/src/main/jniLibs/armeabi-v7a/libgojni.so gobind failed: exit status 1
@gopherbot gopherbot added this to the Unreleased milestone Apr 19, 2018
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Apr 19, 2018
@hajimehoshi
Copy link
Member Author

CC @eliasnaur

@eliasnaur
Copy link
Contributor

Have you rebuilt the gomobile commands? (go install golang.org/x/mobile/cmd/...) I get

gomobile: package "github.com/hajimehoshi/gomobilebindtest": no buildable Go source files in /home/elias/dev/go/src/github.com/hajimehoshi/gomobilebindtest

Which is caused by CL 99777 that again adds GOOS=android to gomobile bind -target=android builds.

@hajimehoshi
Copy link
Member Author

Yeah I did go install so that I'm using the latest gomobile binaries.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/108336 mentions this issue: cmd/gomobile: add CGO_ENABLED=1 to gobind runs

@eliasnaur
Copy link
Contributor

Can you test CL 108336?

@hajimehoshi
Copy link
Member Author

Yeah that worked. Thanks!

@golang golang locked and limited conversation to collaborators Apr 20, 2019
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
A previous CL switched gobind to use the "source" importer so go
files using cgo can be type checked. However, CGO_ENABLED=1 also
have to be passed in for such files not be ignored.

Also add -tags ios to the gomobile test output missing from CL
99777.

Fixes golang/go#24941

Change-Id: I868469af3061b82ab592899e365a8a90a0333e58
Reviewed-on: https://go-review.googlesource.com/108336
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
A previous CL switched gobind to use the "source" importer so go
files using cgo can be type checked. However, CGO_ENABLED=1 also
have to be passed in for such files not be ignored.

Also add -tags ios to the gomobile test output missing from CL
99777.

Fixes golang/go#24941

Change-Id: I868469af3061b82ab592899e365a8a90a0333e58
Reviewed-on: https://go-review.googlesource.com/108336
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
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

3 participants