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

cmd/ebitenmobile: doesn't work with go1.23 in go.mod #3086

Open
2 of 11 tasks
2me2 opened this issue Sep 8, 2024 · 20 comments
Open
2 of 11 tasks

cmd/ebitenmobile: doesn't work with go1.23 in go.mod #3086

2me2 opened this issue Sep 8, 2024 · 20 comments

Comments

@2me2
Copy link

2me2 commented Sep 8, 2024

Ebitengine Version

github.com/hajimehoshi/ebiten/v2 v2.7.8

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

1.23

What steps will reproduce the problem?

git clone https://github.com/hajimehoshi/go-inovation
cd go-inovation
go run github.com/hajimehoshi/ebiten/v2/cmd/ebitenmobile bind -target ios -o ./mobile/ios/Mobile.xcframework ./mobile

confirm that works
vi go.mod # and then make the changes to go 1.23 and toolchain go1.23.0

go 1.23

toolchain go1.23.0

go run github.com/hajimehoshi/ebiten/v2/cmd/ebitenmobile bind -target ios -o ./mobile/ios/Mobile.xcframework ./mobile

and then try with 1.22 as well to see if that works (it did for me, only 1.23 didn't work)

What is the expected result?

Should not fail- it worked for 1.22 and below.

What happens instead?

gomobile: go mod tidy failed: exit status 1
go: downloading go1.23 (darwin/amd64)
go: download go1.23 for darwin/amd64: toolchain not available

Anything else you feel useful to add?

Not sure if it's just my computer.

@2me2 2me2 added the bug label Sep 8, 2024
@hajimehoshi hajimehoshi added this to the v2.8.0 milestone Sep 8, 2024
@hajimehoshi hajimehoshi changed the title Potential ebitenmobile with go1.23 cmd/ebitenmobile: doesn't work with go1.23 in go.mod Sep 8, 2024
@hajimehoshi
Copy link
Owner

I found a similar issue:

diff --git a/go.mod b/go.mod
index 485e3b5..071069c 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/hajimehoshi/go-inovation
 
-go 1.19
+go 1.23
 
 require (
        github.com/hajimehoshi/bitmapfont/v3 v3.1.0
2024/09/11 10:47:56 go [build -o bin/gomobile github.com/ebitengine/gomobile/cmd/gomobile] failed: # internal/unsafeheader
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/goarch
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/goos
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/goexperiment
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/race
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/profilerecord
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/coverage/rtcov
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/byteorder
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# unicode
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/godebugs
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/itoa
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# unicode/utf8
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# cmp
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/asan
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# math/bits
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/nettrace
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/cpu
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# encoding
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# crypto/internal/alias
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# unicode/utf16
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/msan
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# sync/atomic
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# vendor/golang.org/x/crypto/cryptobyte/asn1
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/goversion
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# log/internal
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# internal/platform
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# crypto/internal/boring/sig
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# crypto/subtle
compile: version "go1.23.0" does not match go tool version "go1.22.6"
# golang.org/x/tools/internal/packagesinternal
compile: version "go1.23.0" does not match go tool version "go1.22.6"

exit status 1
exit status 1

@hajimehoshi
Copy link
Owner

Another error with the lastest Ebitengine...

gomobile: /var/folders/cj/73zbb35j0qx5t4b6rnqq0__h0000gn/T/ebitenmobile-352129176/bin/gobind -lang=go,objc -outdir=/var/folders/cj/73zbb35j0qx5t4b6rnqq0__h0000gn/T/gomobile-work-3228724954/ios -tags=ios github.com/hajimehoshi/go-inovation/mobile github.com/hajimehoshi/ebiten/v2/mobile/ebitenmobileview failed: exit status 1
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"

@hajimehoshi
Copy link
Owner

hajimehoshi commented Sep 11, 2024

I failed to reproduce your error Go 1.23 worked of course

diff --git a/go.mod b/go.mod
index 485e3b5..a8e53c3 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,8 @@
 module github.com/hajimehoshi/go-inovation
 
-go 1.19
+go 1.23
+
+toolchain go1.23.0
 
 require (
        github.com/hajimehoshi/bitmapfont/v3 v3.1.0
go install golang.org/dl/go1.23.1@latest
go1.23.1 download
go1.23.1 mod tidy 
go1.23.1 run github.com/hajimehoshi/ebiten/v2/cmd/ebitenmobile bind -target ios -o ./mobile/ios/Mobile.xcframework ./mobile

@hajimehoshi
Copy link
Owner

Ebitenmobile tries to compile gomobile under a temporary directory, and in this case the Go version differs unfortunately.

package main

import (
	"os"
	"os/exec"
	"strings"
)

func printGoVersion() {
	cmd := exec.Command("go", "version")
	out, err := cmd.Output()
	if err != nil {
		panic(err)
	}
	println(strings.TrimSpace(string(out)))
}

func main() {
	println("Under go.mod")
	printGoVersion()

	origDir, err := os.Getwd()
	if err != nil {
		panic(err)
	}

	println("Under a temporary directory")
	if err := os.Chdir(os.TempDir()); err != nil {
		panic(err)
	}
	printGoVersion()

	println("Under go.mod again")
	if err := os.Chdir(origDir); err != nil {
		panic(err)
	}
	printGoVersion()
}
Under go.mod
go version go1.23.0 darwin/arm64
Under a temporary directory
go version go1.22.6 darwin/arm64
Under go.mod again
go version go1.23.0 darwin/arm64

I'll add a toolchain line to the temporary go.mod under the temporary directory.

@hajimehoshi
Copy link
Owner

@2me2 Please try f63a757, thanks

@hajimehoshi
Copy link
Owner

hajimehoshi commented Sep 19, 2024

Let me close this. I'll reopen this if the latest commit doesn't work yet.

EDIT: I'll reopen this as @2me2 reported this was not fixed yet.

@hajimehoshi
Copy link
Owner

@2me2 Have you update the Ebitengine version in go-inovation's go.mod?

@hajimehoshi
Copy link
Owner

ping

@hajimehoshi
Copy link
Owner

I couldn't reproduce the original issue even with Ebitengine 2.7 (and with Go 1.23).

The mysterious thing is,

gomobile: go mod tidy failed: exit status 1
go: downloading go1.23 (darwin/amd64)
go: download go1.23 for darwin/amd64: toolchain not available

says go1.23, but shouldn't this be go1.23.0?

@2me2
Copy link
Author

2me2 commented Sep 24, 2024

Sorry I missed the ping earlier. Yes it should be 1.23.0, i do get that same error if I change to just 1.23 and run go mod tidy right away.

Ok so I just tried pulling the latest go-innovation code again, here are the order of the operations:

  1. go install github.com/hajimehoshi/ebiten/v2/cmd/ebitenmobile@main
  2. git pull (the latest go-innovation code)
  3. vi go.mod # edit the version
-go 1.19
+go 1.23.0
  1. go mod tidy
  2. go get github.com/hajimehoshi/ebiten/v2@main
  3. go mod tidy
  4. ebitenmobile bind -target ios -o ./mobile/ios/Mobile.xcframework ./mobile

Output:

~/src/go-inovation on branch main > ebitenmobile bind -target ios -o ./mobile/ios/Mobile.xcframework ./mobile

gomobile: /var/folders/q_/16fwpggs3_z0skpfkj4_cnfm0000gn/T/ebitenmobile-2179495083/bin/gobind -lang=go,objc -outdir=/var/folders/q_/16fwpggs3_z0skpfkj4_cnfm0000gn/T/gomobile-work-1583894332/iossimulator -tags=ios github.com/hajimehoshi/go-inovation/mobile github.com/hajimehoshi/ebiten/v2/mobile/ebitenmobileview failed: exit status 1
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"
no exported names in the package "github.com/hajimehoshi/go-inovation/mobile"
2024/09/23 21:19:00 exit status 1

If i change the version to 1.22, it seems to work fine.

In any case it seems like I'm having the issue with gomobile. I tried a minimal example and same issue with that using just gomobile bind -target ios ./mobile with literally just a dummy fn and having the same issues, but works fine in 1.22. I wasn't able to locate any information online about 1.23 with gomobile, maybe it is just not supported yet or maybe my environment is just messed up.

@hajimehoshi
Copy link
Owner

What the result of your go version and go env? Thanks,

@hajimehoshi
Copy link
Owner

hajimehoshi commented Sep 24, 2024

I think I could find a similar issue. go.mod's Go version is 1.19 in my case. And my Go version is 1.23.1 and ebitenmobile was built with it.

% ebitenmobile bind -target ios -o ./mobile/ios/Mobile.xcframework ./mobile 
gomobile: iossimulator/amd64: go build -buildmode=c-archive -o /var/folders/cj/73zbb35j0qx5t4b6rnqq0__h0000gn/T/gomobile-work-2020258109/Mobile-iossimulator-amd64.a ./gobind failed: exit status 1
# gobind/gobind
mobileebitenviewcontroller_ios.m:23:58: error: no type or protocol named 'EbitenmobileviewRenderer'
mobileebitenviewcontroller_ios.m:44:40: error: passing 'MobileEbitenViewController *__strong' to parameter of incompatible type 'id<EbitenmobileviewSetGameNotifier> _Nullable' [-Werror]
gobind/Ebitenmobileview.objc.h:41:105: note: passing argument to parameter 'setGameNotifier' here
mobileebitenviewcontroller_ios.m:54:40: error: passing 'MobileEbitenViewController *__strong' to parameter of incompatible type 'id<EbitenmobileviewSetGameNotifier> _Nullable' [-Werror]
gobind/Ebitenmobileview.objc.h:41:105: note: passing argument to parameter 'setGameNotifier' here
mobileebitenviewcontroller_ios.m:152:3: error: call to undeclared function 'EbitenmobileviewSetRenderer'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

This happens that go.mod's Go version and the Go version used for ebitenmobile don't match. This happens whatever the Go version in go.mod is. When you use ebitenmobile, using go run github.com/hajimehoshi/ebiten/v2/cmd/ebitenmobile is always safer. Anyway there is an issue when we use ebitenmobile command.

EDIT: This happens when go-inovation's Ebitengine version and ebitenmobile's Ebitengine version don't match. It is possible to fix this case, but similar things can happen in the future, so I'll leave this case as it is.

@hajimehoshi hajimehoshi reopened this Sep 24, 2024
@hajimehoshi
Copy link
Owner

@2me2 I'm afraid I cannot reproduce your case yet. Could you try '-x' to show a log?

ebitenmobile bind -target ios -o ./mobile/ios/Mobile.xcframework -x ./mobile

@hajimehoshi
Copy link
Owner

Also, instead of @main, could you try @v2.8.0-rc.1?

@2me2
Copy link
Author

2me2 commented Sep 24, 2024

~/src/go-inovation on branch main > go version
go version go1.23.0 darwin/amd64
~/src/go-inovation on branch main > go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/2me2/Library/Caches/go-build'
GOENV='/Users/2me2/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/2me2/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/2me2/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/2me2/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/2me2/go/pkg/mod/golang.org/[email protected]/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/2me2/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/2me2/src/go-inovation/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/q_/16fwpggs3_z0skpfkj4_cnfm0000gn/T/go-build1580475631=/tmp/go-build -gno-record-gcc-switches -fno-common'

2.8.0-rc.1 still has the same issue, but I'm seeing this outside of ebiten anyway. I suspect its something I'm having with gomobile- are you able to even use gomobile with 1.23? Could it be restricted by the version in gomobile (https://cs.opensource.google/go/x/mobile/+/master:go.mod;l=3) ?

@hajimehoshi
Copy link
Owner

Thanks.

are you able to even use gomobile with 1.23? Could it be restricted by the version in gomobile (https://cs.opensource.google/go/x/mobile/+/master:go.mod;l=3) ?

ebitenmobile uses a fork of gomobile so in my case Go 1.23 should work with gomobile. I'll check this with the original gomobile.

@hajimehoshi
Copy link
Owner

hajimehoshi commented Sep 24, 2024

% git log
commit 642950227fb3dd9e9ec517d7630b10397f1d5e01 (HEAD -> master, origin/master, origin/HEAD)
Author: Gopher Robot <[email protected]>
Date:   Mon Sep 9 15:51:57 2024 +0000

    go.mod: update golang.org/x dependencies
    
    Update golang.org/x dependencies to their latest tagged versions.
    
    Change-Id: I47a97af459b0151af8af9df1bed5ee25312579a9
    Reviewed-on: https://go-review.googlesource.com/c/mobile/+/611936
    Reviewed-by: Dmitri Shuralyov <[email protected]>
    Reviewed-by: David Chase <[email protected]>
    TryBot-Bypass: Dmitri Shuralyov <[email protected]>
    Auto-Submit: Gopher Robot <[email protected]>
...

% go version
go version go1.23.1 darwin/arm64

% go install ./cmd/gomobile

% go install ./cmd/gobind

% gomobile bind -target=ios ./example/bind/hello  

Go 1.23.1 worked perfectly with gomobile.

@hajimehoshi
Copy link
Owner

hajimehoshi commented Sep 24, 2024

My go env is:

% go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/hajimehoshi/Library/Caches/go-build'
GOENV='/Users/hajimehoshi/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/hajimehoshi/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/hajimehoshi/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/hajimehoshi/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/hajimehoshi/go-inovation/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/cj/73zbb35j0qx5t4b6rnqq0__h0000gn/T/go-build659188259=/tmp/go-build -gno-record-gcc-switches -fno-common'

Interestingly, GOROOT is different. My understanding is that this happens when your Go version and go.mod's Go version don't match, go.mod's Go version is automatically selected. I'll take a look further.

@hajimehoshi
Copy link
Owner

As we discussed at Discord, this issue happens with Intel macOS with Go installed via Homebrew. Also, the same issue occurs even only with Gomobile without Ebitengine. Thus, I'll remove the milestone.

@hajimehoshi hajimehoshi removed this from the v2.8.0 milestone Sep 24, 2024
@hajimehoshi
Copy link
Owner

golang/go#69612

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

No branches or pull requests

2 participants