tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

compiler: conform to latest iteration of wasm types proposal

Open ydnar opened this issue 1 year ago • 14 comments

Updates to current version of the wasm types proposal at https://github.com/golang/go/issues/66984.

Changes include:

  • Removal of int and uint as allowed types.
  • Restriction of int8, uint8, int16, and uint16 to struct fields, arrays, or pointer values.
  • Requires struct types in wasm params with 1 or more fields to include structs.HostLayout. It enforces this for Go 1.23 or later.
    • TODO: revise this to minimum Go 1.24?

ydnar avatar Oct 05 '24 22:10 ydnar

@dgryski @aykevl would you prefer I split this into two parts, one that upgrades the wasm-tools-go dependency and regenerates the bindings, and a separate one with the wasm types changes to package compiler?

ydnar avatar Oct 07 '24 22:10 ydnar

would you prefer I split this into two parts, one that upgrades the wasm-tools-go dependency and regenerates the bindings, and a separate one with the wasm types changes to package compiler?

I personally would prefer that. :smile_cat:

deadprogram avatar Oct 17 '24 07:10 deadprogram

would you prefer I split this into two parts, one that upgrades the wasm-tools-go dependency and regenerates the bindings, and a separate one with the wasm types changes to package compiler?

I personally would prefer that. 😸

Here you go: https://github.com/tinygo-org/tinygo/pull/4529

ydnar avatar Oct 17 '24 15:10 ydnar

# github.com/tinygo-org/tinygo/compiler
compiler/symbol.go:469:33: c.pkg.GoVersion undefined (type *types.Package has no field or method GoVersion)

https://app.circleci.com/pipelines/github/tinygo-org/tinygo/11640/workflows/e46166fe-40b9-410a-95a9-d49be472b0d1/jobs/44676?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-checks-link&utm_content=summary&invite=true#step-112-0_39

deadprogram avatar Oct 17 '24 16:10 deadprogram

@ydnar note the CI failure...

deadprogram avatar Oct 17 '24 19:10 deadprogram

What's the minimum version of Go supported by TinyGo?

Looks like this field was added in 1.21: https://pkg.go.dev/go/types#Package.GoVersion

ydnar avatar Oct 17 '24 19:10 ydnar

"Officially" should be same as Go itself. But we have been able to keep backwards compat quite a few versions of both Go and LLVM, as shown by the CircleCI tests.

deadprogram avatar Oct 17 '24 19:10 deadprogram

"Officially" should be same as Go itself. But we have been able to keep backwards compat quite a few versions of both Go and LLVM, as shown by the CircleCI tests.

How does this project define compatibility?

  1. TinyGo can be built with version N of Go?
  2. or TinyGo can be used with version N of Go?

Asking because what % of users build TinyGo from source, and what % of those users are using older versions of Go? Versus what % of end-users of TinyGo who use a binary distribution use older versions of Go?

ydnar avatar Oct 17 '24 21:10 ydnar

Usually we keep compatibility as long as it isn't too much of an issue to support. We tend to drop older versions when it's getting annoying to support these older versions. It's always surprising how many people rely on older Go versions but still expect to use a newer TinyGo version.

Also, to be clear: because it makes CI easier "can be built" and "can be used with" is usually the same version. The lower bound is currently LLVM 15 and Go 1.19:

https://github.com/tinygo-org/tinygo/blob/ef4f46f1d1550beb62324d750c496b2b4a7f76d0/.circleci/config.yml#L121-L123

aykevl avatar Oct 18 '24 08:10 aykevl

I guess we could drop support for Go 1.19 and Go 1.20. That would leave Go 1.21-1.23 supported. I find it difficult to guess how many people would have an issue with this (note that Go 1.19 is the Go version in Debian 12).

aykevl avatar Oct 18 '24 08:10 aykevl

@aykevl I updated this quite a bit. Can you take a look?

ydnar avatar Oct 18 '24 18:10 ydnar

I can split this into two PRs, one for the package goenv changes (Parse and Compare), and a second for the wasm types.

ydnar avatar Oct 18 '24 21:10 ydnar

I can split this into two PRs, one for the package goenv changes (Parse and Compare), and a second for the wasm types.

Sorry to be a pain, but I am fairly certain that will make it a lot easier to review. Thank you!

deadprogram avatar Oct 19 '24 09:10 deadprogram

I can split this into two PRs, one for the package goenv changes (Parse and Compare), and a second for the wasm types.

Sorry to be a pain, but I am fairly certain that will make it a lot easier to review. Thank you!

Done! See #4536.

ydnar avatar Oct 19 '24 20:10 ydnar

@ydnar I think this PR can be rebased now, if you please.

deadprogram avatar Oct 21 '24 14:10 deadprogram

@deadprogram done!

ydnar avatar Oct 21 '24 14:10 ydnar

Was this PR also meant to be squashed?

aykevl avatar Oct 22 '24 13:10 aykevl

Now merging, thank you @ydnar for working on this and to @aykevl for helping review.

deadprogram avatar Oct 22 '24 16:10 deadprogram