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: attempting to build native package with gomobile build mobile example fails with exit status 2 #30415

Closed
bubthegreat opened this issue Feb 26, 2019 · 8 comments

Comments

Projects
None yet
5 participants
@bubthegreat
Copy link

commented Feb 26, 2019

After installing and configuring android studio per their setup instructions, adding the SDK environment variables, and installing the additional dependencies (CMAKE, NDK, LLDB, platforms for 7.0+), attempts to run through the native package build steps fail with deprecation warnings.

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

Attempted in 1.11.4 and latest 1.12 (As of 2/26/2019)

PS C:\Users\bubth\Development> go version
go version go1.11.4 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
PS C:\Users\bubth\Development> go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\bubth\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\bubth\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\bubth\AppData\Local\Temp\go-build580209074=/tmp/go-build -gno-record-gcc-switches
PS C:\Users\bubth\Development>

Android SDK Info:

Android Studio 3.3.1
Build #AI-182.5107.16.33.5264788, built on January 28, 2019
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

What did you do?

PS C:\Users\bubth\Development> gomobile init
PS C:\Users\bubth\Development> gomobile build -target=android golang.org/x/mobile/example/basic
C:\Users\bubth\go\bin\gomobile.exe: go build -buildmode=c-shared -o C:\Users\bubth\AppData\Local\Temp\gomobile-work-069435679\lib\armeabi-v7a\libbasic.so golang.org/x/mobile/example/basic failed: exit status 2
# runtime/cgo
clang++.exe: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]
PS C:\Users\bubth\Development>

After updating to 1.12:

PS C:\Users\bubth\Development> go version
go version go1.12 windows/amd64
PS C:\Users\bubth\Development> go get golang.org/x/mobile/cmd/gomobile
PS C:\Users\bubth\Development> gomobile init
PS C:\Users\bubth\Development> go get -d golang.org/x/mobile/example/basic
PS C:\Users\bubth\Development> gomobile build -target=android golang.org/x/mobile/example/basic
C:\Users\bubth\go\bin\gomobile.exe: go build -buildmode=c-shared -o C:\Users\bubth\AppData\Local\Temp\gomobile-work-076420807\lib\armeabi-v7a\libbasic.so golang.org/x/mobile/example/basic failed: exit status 2
# runtime/cgo
clang++.exe: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]

PS C:\Users\bubth\Development>

What did you expect to see?

Successful build of the example mobile application.

What did you see instead?

Errors when attempting to build.

C:\Users\bubth\AppData\Local\Temp\gomobile-work-076420807\lib\armeabi-v7a\libbasic.so golang.org/x/mobile/example/basic failed: exit status 2
# runtime/cgo
clang++.exe: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]

@bcmills bcmills changed the title Attempting to build native package with gomobile build mobile example fails with exit status 2 x/mobile: attempting to build native package with gomobile build mobile example fails with exit status 2 Feb 27, 2019

@gopherbot gopherbot added this to the Unreleased milestone Feb 27, 2019

@gopherbot gopherbot added the mobile label Feb 27, 2019

@bcmills bcmills added NeedsInvestigation and removed mobile labels Feb 27, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Feb 27, 2019

@bcmills bcmills added the mobile label Feb 27, 2019

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2019

See android-ndk/ndk#920. It seems the builtin compilers introduced in r19b are broken on Windows. One workaround is to use revision 8b05ea26b5669e5f52084ab001b8e49ec8877955 of gomobile which does not contain the change to use the new compilers.

@gopherbot

This comment has been minimized.

Copy link

commented Feb 27, 2019

Change https://golang.org/cl/164177 mentions this issue: cmd/gomobile: work around broken Windows NDK compiler scripts

@bubthegreat

This comment has been minimized.

Copy link
Author

commented Feb 27, 2019

For folks like me who are still learning golang and it's nuances, what's the simplest way to use that revision of gomobile? Would I be cherry picking a specific revision from the repo and rebuilding, or is there a simpler way?

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2019

You can apply my fix posted above or simply wait; it will probably be reviewed and merged soon enough and then a simple "go get -u golang.org/x/mobile/cmd/..." will do.

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2019

@bubthegreat please try again with the newest gomobile. Use go get -u golang.org/x/mobile/cmd/...to upgrade.

@wejoy

This comment has been minimized.

Copy link

commented Mar 5, 2019

@bubthegreat please try again with the newest gomobile. Use go get -u golang.org/x/mobile/cmd/...to upgrade.

It looks good now.

@bubthegreat

This comment has been minimized.

Copy link
Author

commented Mar 5, 2019

Verified working - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.