-
Notifications
You must be signed in to change notification settings - Fork 999
compiler: conform to latest iteration of wasm types proposal #4501
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
Conversation
I personally would prefer that. 😸 |
Here you go: #4529 |
9972fcc to
94e3bf9
Compare
|
|
@ydnar note the CI failure... |
|
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 |
|
"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. |
94e3bf9 to
6917156
Compare
How does this project define compatibility?
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? |
|
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: Lines 121 to 123 in ef4f46f
|
aykevl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though please see #4520 because it will conflict.
compiler/symbol.go
Outdated
| if !goenv.WantGoVersion(c.pkg.GoVersion(), 1, 23) { | ||
| hasHostLayout = true // package structs does not exist before go1.23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess one way to work around this is to put this in a separate file with build tags. Together with #4501, the compiler won't try to compile projects with a Go version that's newer than the one TinyGo was compiled with (which means that when TinyGo was compiled with Go before 1.23, it will refuse to even compile code that requires Go 1.23+).
It's a bit ugly, but will keep compatibility for a bit longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aykevl thanks! I rebased and my branch now uses Parse. I included the tests for Parse in my PR as well.
|
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). |
6917156 to
e945a4f
Compare
Address PR feedback in tinygo-org#4501.
|
@aykevl I updated this quite a bit. Can you take a look? |
|
I can split this into two PRs, one for the package |
Sorry to be a pain, but I am fairly certain that will make it a lot easier to review. Thank you! |
Address PR feedback in tinygo-org#4501.
7f96e9f to
ae5801f
Compare
Address PR feedback in tinygo-org#4501.
ae5801f to
bb5805a
Compare
Done! See #4536. |
|
@ydnar I think this PR can be rebased now, if you please. |
golang/go#66984 - Remove int and uint as allowed types in params, results, pointers, or struct fields - Only allow small integers in pointers, arrays, or struct fields
golang/go#66984 TODO: regenerate WASI syscall packages for GC shape types including structs.HostLayout compiler: require go1.23 for structs.HostLayout compiler: use an interface to check if GoVersion() exists This permits TinyGo to compile with Go 1.21. compiler: use goenv.Compare instead of WantGoVersion
compiler/testdata: improve tests for structs.HostLayout
bb5805a to
9d2bf5f
Compare
|
@deadprogram done! |
deadprogram
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some testing and my current code still compiles and runs without issue.
LGTM!
| if gv, ok := any(c.pkg).(interface{ GoVersion() string }); ok { | ||
| if goenv.Compare(gv.GoVersion(), "go1.23") >= 0 { | ||
| hasHostLayout = false // package structs added in go1.23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting solution, I hadn't thought of that! Much cleaner than using build tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! It's great when the only difference is a new method.
|
Was this PR also meant to be squashed? |
Updates to current version of the wasm types proposal at golang/go#66984.
Changes include:
intanduintas allowed types.int8,uint8,int16, anduint16to struct fields, arrays, or pointer values.structtypes in wasm params with 1 or more fields to includestructs.HostLayout. It enforces this for Go 1.23 or later.