Skip to content

all: add Go 1.24 support #4732

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

Merged
merged 10 commits into from
Feb 25, 2025
Merged

all: add Go 1.24 support #4732

merged 10 commits into from
Feb 25, 2025

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Feb 12, 2025

Not entirely finished, but let's see how far we get with just a few adjustments.

@deadprogram
Copy link
Member

Looks like the official image for Go 1.24 is not yet available on https://hub.docker.com/_/golang/tags

@aykevl
Copy link
Member Author

aykevl commented Feb 12, 2025

Yeah you're right, I hope they add it in a day or so.

@aykevl
Copy link
Member Author

aykevl commented Feb 12, 2025

Perhaps we can use the 1.24rc3 one for now?

Copy link

github-actions bot commented Feb 12, 2025

Size difference with the dev branch:

Binary size difference
 flash                          ram
 before   after   diff          before   after   diff
  16656   16656      0   0.00%    4180    4180      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650
  61472   61472      0   0.00%    6188    6188      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go
   9604    9604      0   0.00%    4748    4748      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go
  13584   13584      0   0.00%    6788    6788      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx
   8824    8824      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go
  11848   11848      0   0.00%    6580    6580      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go
   9920    9920      0   0.00%    4760    4760      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go
   8376    8376      0   0.00%    2320    2320      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go
   8164    8164      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go
   7468    7468      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go
  70692   70692      0   0.00%    3656    3656      0   0.00% tinygo build -size short -o ./build/test.hex -target=pinetime     ./examples/bma42x/main.go
  63988   63988      0   0.00%    6196    6196      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go
  27804   27804      0   0.00%    4780    4780      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go
  64048   64048      0   0.00%    6228    6228      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go
  12248   12248      0   0.00%    4812    4812      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go
   8364    8364      0   0.00%    3352    3352      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go
  22300   22300      0   0.00%    3556    3556      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go
  69720   69720      0   0.00%    6376    6376      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/main.go
   4628    4628      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go
  69980   69980      0   0.00%    6980    6980      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi
  66724   66724      0   0.00%    9020    9020      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi
   7232    7232      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go
  67668   67668      0   0.00%    6360    6360      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go
  68220   68220      0   0.00%    6504    6504      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go
   8012    8012      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go
   5840    5840      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go
   5792    5792      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go
  10568   10568      0   0.00%    4748    4748      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go
  14748   14748      0   0.00%    6580    6580      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go
  16160   16160      0   0.00%    2360    2360      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go
  10276   10276      0   0.00%    6924    6924      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic
  10784   10784      0   0.00%    4876    4876      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic
  29644   29644      0   0.00%   38084   38084      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing
  10300   10300      0   0.00%    6916    6916      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll
  10872   10872      0   0.00%    4868    4868      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll
 263492  263492      0   0.00%   46752   46752      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow
  11772   11772      0   0.00%    4780    4780      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go
  14112   14112      0   0.00%    6580    6580      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go
  26500   26500      0   0.00%    2328    2328      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go
  12484   12484      0   0.00%    4788    4788      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go
  10760   10760      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go
   9940    9940      0   0.00%    4780    4780      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go
  10380   10380      0   0.00%    4788    4788      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go
   9924    9924      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go
  68600   68600      0   0.00%    6196    6196      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go
   8276    8276      0   0.00%    4748    4748      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go
   8184    8184      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go
  75472   75472      0   0.00%    7448    7448      0   0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go
  12236   12236      0   0.00%    3360    3360      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go
   6236    6236      0   0.00%    3288    3288      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go
   5264    5264      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go
  10528   10528      0   0.00%    3336    3336      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw
   2841    2841      0   0.00%     558     558      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo
  13752   13752      0   0.00%    3408    3408      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico     ./examples/sgp30
   8212    8212      0   0.00%    6788    6788      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go
  57480   57480      0   0.00%    3688    3688      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go
  57448   57448      0   0.00%    3696    3696      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go
  57444   57444      0   0.00%    3688    3688      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go
   6704    6704      0   0.00%    2288    2288      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/i2c_128x32/main.go
   6152    6152      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/spi_128x64/main.go
   5844    5844      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go
   6764    6764      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go
   6692    6692      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go
  17544   17544      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go
  10712   10712      0   0.00%    4540    4540      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone
  10208   10208      0   0.00%    4740    4740      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go
  10820   10820      0   0.00%    3348    3348      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive
   9648    9648      0   0.00%    6788    6788      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go
  12548   12548      0   0.00%    6984    6984      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go
  15372   15372      0   0.00%    4748    4748      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go
  13852   13852      0   0.00%    4748    4748      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go
  24708   24708      0   0.00%   13720   13720      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go
   6488    6488      0   0.00%    2320    2320      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go
   6152    6152      0   0.00%    2312    2312      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go
   6400    6400      0   0.00%    2320    2320      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go
  26044   26044      0   0.00%   16420   16420      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go
   6988    6988      0   0.00%    4780    4780      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812
   5768    5768      0   0.00%    9522    9522      0   0.00% '-xesppie' is not a recognized feature for this target (ignoring feature)
  62744   62744      0   0.00%    5948    5948      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go
   1581    1581      0   0.00%     598     598      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino   ./examples/ws2812
   1056    1056      0   0.00%     180     180      0   0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812
  32256   32256      0   0.00%    4780    4780      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go
  27128   27152     24   0.09%    3640    3640      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go
  26992   27016     24   0.09%    5620    5620      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go
2041030 2041078     48   0.00%  472522  472522      0   0.00%

@deadprogram
Copy link
Member

Perhaps we can use the 1.24rc3 one for now?

A very good idea.

@joonas
Copy link
Contributor

joonas commented Feb 12, 2025

FWIW, it looks like the official 1.24.0 tag (and it's variants) landed about 2 hours ago 🙂

@aykevl
Copy link
Member Author

aykevl commented Feb 13, 2025

I'm investigating a weird CGo problem now.

@aykevl
Copy link
Member Author

aykevl commented Feb 16, 2025

The CGo regression is a result of this commit: golang/go@5bd442a
Need to think about the right way to proceed. Is it our bug, or a bug in Go?

@aykevl
Copy link
Member Author

aykevl commented Feb 16, 2025

Filed an upstream bug: golang/go#71777

@aykevl aykevl marked this pull request as ready for review February 16, 2025 13:32
@aykevl
Copy link
Member Author

aykevl commented Feb 16, 2025

Added a workaround for the CGo issue. This will regress our nice CGo error messages, but I don't see a good alternative.

Previous error message:

# command-line-arguments
tmp/test.go:7:6: undefined: C.FOO

Error message with the workaround:

# command-line-arguments
tmp/test.go:7:6: undefined: _Cgo_FOO

@aykevl aykevl force-pushed the go1.24 branch 4 times, most recently from f3fa0be to 58e94f9 Compare February 16, 2025 14:34
Comment on lines -358 to -364
# Assume this will go away before Go2, so only check minor version.
ifeq ($(filter $(shell $(GO) env GOVERSION | cut -f 2 -d.), 16 17 18), )
TEST_PACKAGES_FAST += crypto/internal/nistec/fiat
else
TEST_PACKAGES_FAST += crypto/elliptic/internal/fiat
endif

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed these, since they're an internal package and the name keeps changing. In Go 1.24, the name seems to have changed to crypto/internal/fips140/nistec/fiat.

@ydnar
Copy link
Contributor

ydnar commented Feb 17, 2025

# text/template
/usr/local/go/src/text/template/exec.go:405:22: val.Seq undefined (type reflect.Value has no field or method Seq)
/usr/local/go/src/text/template/exec.go:454:17: val.Type().CanSeq undefined (type reflect.Type has no field or method CanSeq)
/usr/local/go/src/text/template/exec.go:460:23: val.Seq undefined (type reflect.Value has no field or method Seq)
/usr/local/go/src/text/template/exec.go:471:17: val.Type().CanSeq2 undefined (type reflect.Type has no field or method CanSeq2)
/usr/local/go/src/text/template/exec.go:473:26: val.Seq2 undefined (type reflect.Value has no field or method Seq2)

I can peek at this.

@aykevl
Copy link
Member Author

aykevl commented Feb 18, 2025

Fixed two issues (I hope), now one that looks scary:

~/src/tinygo/tinygo$ tinygo test -target=wasip1 compress/lzw
Error: failed to run main module `/tmp/tinygo4120297224/main.wasmopt`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x13dd0 - runtime.abort
                           at /home/ayke/src/tinygo/tinygo/src/runtime/runtime_tinygowasm.go:78:6              - runtime.runtimePanicAt
                           at /home/ayke/src/tinygo/tinygo/src/runtime/panic.go:103:7
           1: 0x56c7 - runtime.nilPanic
                           at /home/ayke/src/tinygo/tinygo/src/runtime/panic.go:180:16
           2: 0x1cbd9 - (*flag.FlagSet).Var
                           at /usr/local/go1.24.0/src/flag/flag.go:1020:23
           3: 0x17461 - runtime.run$1
                           at /home/ayke/src/tinygo/tinygo/src/runtime/scheduler_cooperative.go:251:10
           4: 0x1503c - <goroutine wrapper>
                           at /home/ayke/src/tinygo/tinygo/src/runtime/scheduler_cooperative.go:250:2
           5:  0x7c9 - tinygo_launch
                           at /home/ayke/src/tinygo/tinygo/src/internal/task/task_asyncify_wasm.S:59
           6: 0x14eba - (*internal/task.Task).Resume
                           at /home/ayke/src/tinygo/tinygo/src/internal/task/task_asyncify.go:114:17              - runtime.scheduler
                           at /home/ayke/src/tinygo/tinygo/src/runtime/scheduler_cooperative.go:230:11              - runtime.run
                           at /home/ayke/src/tinygo/tinygo/src/runtime/scheduler_cooperative.go:255:11              - _start
                           at /home/ayke/src/tinygo/tinygo/src/runtime/runtime_wasmentry.go:20:5
    2: wasm trap: wasm `unreachable` instruction executed
panic: runtime error: nil pointer dereference
FAIL    compress/lzw    0.219s

@deadprogram
Copy link
Member

Perhaps the "important" part of the error is this?

# crypto/internal/sysrand
Error: /opt/hostedtoolcache/go/1.24.0/x64/src/crypto/internal/sysrand/rand_wasip1.go:14:17: undefined: syscall.RandomGet

That function is defined here:
https://go.googlesource.com/go/+/refs/tags/go1.24.0/src/syscall/fs_wasip1.go#946

How does fs_wasip1.go get included in the TinyGo build process again?

@aykevl
Copy link
Member Author

aykevl commented Feb 18, 2025

@deadprogram it's not, that's a separate issue. I just tracked it down to an interp bug (that I think I have a fix for).

@aykevl
Copy link
Member Author

aykevl commented Feb 18, 2025

See: #4742

@aykevl
Copy link
Member Author

aykevl commented Feb 24, 2025

I think #4736 is broken, perhaps it would be best to revert this PR for now?
See: #4736 (comment)

@deadprogram
Copy link
Member

I think #4736 is broken, perhaps it would be best to revert this PR for now?

Broken on Go 1.24 I assume you mean? It passed all of the CI tests at the time, which was part of why I merged it.

@deadprogram
Copy link
Member

@aykevl I tested this branch with PR #4736 reverted in PR #4755 and exactly same result.

@deadprogram
Copy link
Member

I can confirm that https://cs.opensource.google/go/go/+/5e82cba9bdf45d81da549477d172f6b5e23106d4 is what is triggering the Windows test failures. Looking deeper now into the root cause.

@aykevl
Copy link
Member Author

aykevl commented Feb 25, 2025

Broken on Go 1.24 I assume you mean?

Broken in general (not just 1.24). I tried a trivial example, and it crashed. See my comments on that PR.

@aykevl
Copy link
Member Author

aykevl commented Feb 25, 2025

I removed the os/user test since it's not currently working (looks like they added the t.Skip() code in Go 1.24, and we currently don't seem to have a working implementation of that). I can look into adding t.Skip() support in the future, but for now it may be best to just skip this test entirely.

Copy link
Member

@deadprogram deadprogram left a comment

Choose a reason for hiding this comment

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

Wow, that was not easy! Great work all around on this one.

@deadprogram
Copy link
Member

@aykevl can you resolve merge conflict since I merged the revert into dev? I probably should have done it in the opposite order, oh well.

This mangles CGo identifier names to something like "_Cgo_foo" instead
of using literal identifiers like "C.foo". This works around
golang/go#71777.

I don't like this solution, but I hope we'll find a better solution in
the future. In that case we can revert this commit.
This also moves flash padding code to a single place, since it was
copied 5 times.

This change is necessary in Go 1.24 to avoid an import cycle.
We can't use the bytes package in Go 1.24 since it would result in an
import cycle. Therefore, use bytealg.Index instead.

(I'm not sure this code is correct - just searching for a range of bytes
seems brittle. But at least this commit shouldn't change the code).
Not entirely sure what they're for, but the Go runtime also stores this
information per goroutine so let's go with that.
This function is needed starting with Go 1.24.
We should really be using syscall.Fchdir here, but this is a fix to get
Go 1.24 working.
This method was added in Go 1.24.
This fixes lots of broken tests in stdlib packages in Go 1.24.
@deadprogram
Copy link
Member

@aykevl never mind I resolved merge conflict. Now just waiting for CI to run...

@deadprogram
Copy link
Member

Now merging! Thanks everyone.

@deadprogram deadprogram merged commit 38e3d55 into dev Feb 25, 2025
24 checks passed
@deadprogram deadprogram deleted the go1.24 branch February 25, 2025 13:41
@deadprogram
Copy link
Member

We will need to address #4759 before release.

@aykevl
Copy link
Member Author

aykevl commented Feb 27, 2025

@deadprogram see #4761

@gandarez
Copy link

gandarez commented Feb 27, 2025

Since it's merged and blocked on #4759. Is it possible to build tinygo from source?

nvm I found it at BUILDING.md that's not referenced in the README.md.

@aykevl
Copy link
Member Author

aykevl commented Feb 28, 2025

@gandarez please take a look here: https://tinygo.org/docs/guides/build/

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.

6 participants