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 triggers a CC compilation with the wrong compiler #49502

Closed
bmteller opened this issue Nov 10, 2021 · 3 comments
Closed
Labels
FrozenDueToAge 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.
Milestone

Comments

@bmteller
Copy link

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

go version go1.16.2 linux/amd64

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

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/workspace/mobile/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2276006800=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Ran gomobile bind -target android -androidapi 30 -javapkg io.teller github.com/tellerhq/quic-droid-edge/mobile/pkg/droid

What did you expect to see?

Success

What did you see instead?

gomobile: err: exit status 2: stderr: go: downloading github.com/segmentio/ksuid v1.0.3
go: downloading go.uber.org/zap v1.16.0
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/lucas-clemente/quic-go v0.22.1
go: downloading go.uber.org/multierr v1.5.0
go: downloading go.uber.org/atomic v1.6.0
go: downloading github.com/cheekybits/genny v1.0.0
go: downloading golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
go: downloading golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
go: downloading github.com/marten-seemann/qtls-go1-16 v0.1.4
# runtime/cgo
gcc: error: unrecognized command line option '-marm'; did you mean '-mabm'?

If I explicitly set a target architecture using gomobile bind -target android/arm64 -androidapi 30 -javapkg io.teller github.com/tellerhq/quic-droid-edge/mobile/pkg/droid then I get a slightly different error.

gomobile: err: exit status 2: stderr: go: downloading github.com/segmentio/ksuid v1.0.3
go: downloading go.uber.org/zap v1.16.0
go: downloading github.com/lucas-clemente/quic-go v0.22.1
go: downloading google.golang.org/protobuf v1.27.1
go: downloading go.uber.org/multierr v1.5.0
go: downloading go.uber.org/atomic v1.6.0
go: downloading github.com/cheekybits/genny v1.0.0
go: downloading golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
go: downloading golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
go: downloading github.com/marten-seemann/qtls-go1-16 v0.1.4
# runtime/cgo
gcc_android.c:6:10: fatal error: android/log.h: No such file or directory
 #include <android/log.h>
          ^~~~~~~~~~~~~~~
compilation terminated.

If I run the command a second time then it succeeds. However, if delete the contents of $GOPATH/pkg/mod/ and reinstall gomobile and run gomobile bind again I get the same failure.

if I run GOOS=android GOARCH=arm64 CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang CXX=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++ CGO_ENABLED=1 go list -compiled=true -json github.com/tellerhq/quic-droid-edge/mobile/pkg/droid before running gomobile bind then the error is not triggered.

The error seems to be related to:

https://github.com/golang/mobile/blob/master/cmd/gomobile/bind.go#L113

pkgs, err := packages.Load(packagesConfig(targets[0]), args...)

this triggers some kind of CC compilation but the CC env variable is not set correctly at this point in time so it is unable to find android/log.h or it gets these architecture errors because the CC compiler on my box does not understand -marm but the android toolchain one does.

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Nov 10, 2021
@gopherbot gopherbot added this to the Unreleased milestone Nov 10, 2021
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 11, 2021
@cagedmantis
Copy link
Contributor

/cc @hyangah

@changkun
Copy link
Member

changkun commented Dec 5, 2021

Can't find the repository github.com/tellerhq/quic-droid-edge hence can't really start to investigate. Any updates?

@changkun
Copy link
Member

Not responding. Close.

@golang golang locked and limited conversation to collaborators Feb 21, 2023
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 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants