Skip to content

Update x/tools for go v1.25 compatibility.#383

Draft
kousu wants to merge 3 commits intogo-python:masterfrom
kousu:bump-tools-version
Draft

Update x/tools for go v1.25 compatibility.#383
kousu wants to merge 3 commits intogo-python:masterfrom
kousu:bump-tools-version

Conversation

@kousu
Copy link

@kousu kousu commented Mar 22, 2026

I can't build gopy, unfortunately. There is some bug in the old version of x/tools that gopy is pinned to that go got stricter about between 1.24 and 1.26. Apparently in v1.25

It means I can't use it:

$ go version
go version go1.26.1-X:nodwarf5 linux/amd64
$ git rev-parse HEAD
04cb87bab1e03ba3d50e827654e6e07c94ed7606
$ go build
# golang.org/x/tools/internal/tokeninternal
../../../go/pkg/mod/golang.org/x/tools@v0.16.0/internal/tokeninternal/tokeninternal.go:78:9: invalid array length -delta * delta (constant -256 of type int64)

This patch conservatively updates x/tools is the oldest version of x/tools that fixes the build, found by bisection:

Bisection Log
$ # pinned to 0.16. Max is 0.43. 0.32 is about halfway and a convenient number for doing bisection with
$ go get golang.org/x/tools@v0.32.0 && go mod tidy && go build .
go: upgraded go 1.19 => 1.23.0
go: upgraded golang.org/x/mod v0.14.0 => v0.24.0
go: upgraded golang.org/x/tools v0.16.0 => v0.32.0
$ go get golang.org/x/tools@v0.24.0 && go mod tidy && go build .
go: downgraded golang.org/x/tools v0.32.0 => v0.24.0
# golang.org/x/tools/internal/tokeninternal
../../../go/pkg/mod/golang.org/x/tools@v0.24.0/internal/tokeninternal/tokeninternal.go:64:9: invalid array length -delta * delta (constant -256 of type int64)
$ go get golang.org/x/tools@v0.28.0 && go mod tidy && go build .
go: upgraded golang.org/x/tools v0.24.0 => v0.28.0
$ go get golang.org/x/tools@v0.26.0 && go mod tidy && go build .
go: downgraded golang.org/x/tools v0.28.0 => v0.26.0
$ go get golang.org/x/tools@v0.25.0 && go mod tidy && go build .
go: downgraded golang.org/x/tools v0.26.0 => v0.25.0
# golang.org/x/tools/internal/tokeninternal
../../../go/pkg/mod/golang.org/x/tools@v0.25.0/internal/tokeninternal/tokeninternal.go:64:9: invalid array length -delta * delta (constant -256 of type int64)
$ go get golang.org/x/tools@v0.26.0 && go mod tidy && go build .
go: upgraded golang.org/x/tools v0.25.0 => v0.26.0

Then I redid it to make sure not to overshoot in the go version bump.

$ git reset --hard HEAD
HEAD is now at 04cb87b Merge pull request #373 from b-long/chore/link-to-discussions
$ go get golang.org/x/tools@v0.25.0 && go mod tidy && go build .
go: upgraded go 1.19 => 1.22.0
go: upgraded golang.org/x/mod v0.14.0 => v0.21.0
go: upgraded golang.org/x/tools v0.16.0 => v0.25.0
# golang.org/x/tools/internal/tokeninternal
../../../go/pkg/mod/golang.org/x/tools@v0.25.0/internal/tokeninternal/tokeninternal.go:64:9: invalid array length -delta * delta (constant -256 of type int64)
$ go get golang.org/x/tools@v0.26.0 && go mod tidy && go build .
go: upgraded golang.org/x/tools v0.25.0 => v0.26.0

I hope it finds you well and that you will consider it so that I can use your project (actually I'm trying to use https://slidge.im/ and you're a key strut holding that project up).

@kousu kousu changed the title Update x/tools for go v1.26 compatibility. Update x/tools for go v1.25 compatibility. Mar 22, 2026
@kousu kousu force-pushed the bump-tools-version branch 7 times, most recently from 1fae9ed to 4db5ec2 Compare March 23, 2026 19:03
Also, *remove* `@latest` so `go install` respects the pins in go.mod.

Also remove `stack: go 1.22` because that's apparently
only for Linux [^1]  and it's causing build problems.

[^1]: appveyor/ci#3743 (comment)
@kousu kousu force-pushed the bump-tools-version branch from 4db5ec2 to 14b432d Compare March 23, 2026 19:11
@kousu
Copy link
Author

kousu commented Mar 23, 2026

To the maintainers: this fixes the build for me. But the 6-patch series starting at #382 has almost the same fix (go -> 1.22, x/tools -> 0.29) in patch 5, so if you want to pick one, pick theirs. I only leave this open in the hopes that if you are too busy to review 6 patches you can at least review this one and get gopy working again on modern systems.

In fact to get the build to pass I had to cherry-pick in b-long#6 aka #379 so it really seems better to defer to those.

PATH: '%GOPATH%\bin;%GOROOT%\bin;%CPYTHON3DIR%;%CPYTHON3DIR%\\Scripts;C:\msys64\mingw64\bin;C:\msys64\usr\bin\;%PATH%'

stack: go 1.21
PATH: 'C:\go122\bin;%USERPROFILE%\go\bin;%CPYTHON3DIR%;%CPYTHON3DIR%\\Scripts;C:\msys64\mingw64\bin;C:\msys64\usr\bin\;%PATH%'
Copy link
Author

@kousu kousu Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appveyor doesn't seem to respect envs set, see e.g. this run, that's why the path to go is hardcoded.

I wonder therefore if the python paths are also wrong. But the build is passing and I don't want this patch to be a complete overhaul (b-long already did that)

b-long and others added 2 commits March 23, 2026 15:24
Wraps 'typedef uint8_t bool;' with preprocessor guards to avoid
conflicts with C23's native bool type. This fixes compilation
errors with newer C compilers that default to C23 standard.

Based on go-python#379 by @deuill.

Co-Authored-By: Marid de Uill <maridlcueto@gmail.com>
@kousu kousu marked this pull request as draft March 23, 2026 20:53
@kousu
Copy link
Author

kousu commented Mar 23, 2026

Struggling with appveyor. I don't know it and CI is always hard. I might just let this lie because deuill and b-long have already done the maintenance. I hope you accept their work 🙏

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants