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 init no longer works due to openal-soft and Go changes #46943

Open
BenLubar opened this issue Jun 27, 2021 · 5 comments
Open
Labels
mobile Android, iOS, and x/mobile modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@BenLubar
Copy link

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

$ go version
go version go1.16.5 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/ben/go/bin"
GOCACHE="/home/ben/.cache/go-build"
GOENV="/home/ben/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ben/.golang-path/pkg/mod"
GONOPROXY="git.lubar.me/*"
GONOSUMDB="git.lubar.me/*"
GOOS="linux"
GOPATH="/home/ben/.golang-path"
GOPATH="/home/ben/.golang-path"
GOPRIVATE="git.lubar.me/*"
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.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build979802223=/tmp/go-build -gno-record-gcc-switches"

What did you do?

git clone -b 1.21.1 https://github.com/kcat/openal-soft.git
gomobile init -openal openal-soft

What did you expect to see?

It builds the shared library.

What did you see instead?

gomobile: go install golang.org/x/mobile/cmd/gobind failed: exit status 1
go install: version is required when current directory is not in a module
        Try 'go install golang.org/x/mobile/cmd/gobind@latest' to install the latest version

and if I make a go.mod file to avoid that error:

gomobile: /usr/bin/cmake /home/ben/src/utils/openal-soft -DCMAKE_TOOLCHAIN_FILE=/home/ben/src/utils/openal-soft/XCompile-Android.txt -DHOST=armv7a-linux-androideabi16 failed: exit status 1
CMake Error at XCompile-Android.txt:16 (MESSAGE):
  Use the toolchain provided by the Android NDK
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/CMakeDetermineSystem.cmake:93 (include)
  CMakeLists.txt:30 (project)


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jun 27, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jun 27, 2021
@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Jun 28, 2021
@jakubgs
Copy link

jakubgs commented Sep 13, 2021

I've been dealing with these issues in our Android/iOS library we build using gomobile: status-im/status-go#2352

@Lallassu
Copy link

I have the same issue. Pointing out ndk tool chain makes it work. But then I only get 32bit library that is incompatible with my arm64 so file. So I then need to modify the cmake file to build 64bit. Then it works but this feels like something is not up to date as it requires changes to gomobile cmd source.

Anyone else solved this in a better and more generic way?

@myklosbotond
Copy link

I tried changing the install line in init.go#L81 to add the @latest suffix and rebuilding the binary from source. It seems to be working in my Dockerfile, but gomobile version refuses to cooperate after that.

diff --git a/init.go b/init.go
index 172d015..234b1c1 100644
--- a/init.go
+++ b/init.go
@@ -78,7 +78,7 @@ func runInit(cmd *command) error {
 	}()

 	// Make sure gobind is up to date.
-	if err := goInstall([]string{"golang.org/x/mobile/cmd/gobind"}, nil); err != nil {
+	if err := goInstall([]string{"golang.org/x/mobile/cmd/gobind@latest"}, nil); err != nil {
 		return err
 	}

I ran gobind for android and it finished after that.

gomobile version gives me this, though:

gomobile version unknown: cannot test gomobile binary: exit status 1, no required module provides package golang.org/x/mobile/cmd/gomobile: go.mod file not found in current directory or any parent directory; see 'go help modules'

@Lallassu
Copy link

I managed to build OpenAL etc. It required some changes to gomobile itself and the toolchain cmake files for the NDK. I've documented my findings on my project that is fully working using gomobile and OpenAL. Not sure if it's the best way forward but it solved the issues for me.

https://github.com/Lallassu/bintris

@myklosbotond
Copy link

As I see it, this issue may be a duplicate of #50994 which was closed, and the @latest suffix was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile modules 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

6 participants