-
-
Notifications
You must be signed in to change notification settings - Fork 368
Allow building with Tinygo #1078
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
base: master
Are you sure you want to change the base?
Conversation
4db1663
to
aae8db1
Compare
Thanks, I'm fine with supporting tinygo builds and adding it to CI. I'm not super pumped about adding tinygo build tags, though. Ideally, tags like https://tinygo.org/docs/reference/lang-support/stdlib/#osuser does show a failure, but that seems like a bug that should be tracked/fixed upstream. |
aae8db1
to
ee4e0b8
Compare
I made tinygo-org/tinygo#4278 to address this. |
With tinygo-org/tinygo#4278 merged a while back, I assume we can now get rid of the build tags here? |
This commit adds package internal/tinygostub that contains stubs for some of the standard library functions that are not available in Tinygo. This allows most of the module to be built with Tinygo.
f39aaec
to
af574e1
Compare
This workflow guarantees that at least these packages build under Tinygo x86_64 and WASM: - mvdan.cc/sh/v3/expand - mvdan.cc/sh/v3/syntax - mvdan.cc/sh/v3/interp
2b3d6e3
to
8693c45
Compare
I got rid of a few stubs, but I still have to stub |
That's very odd. Upstream Go doesn't have SameFile behind any build tags, even though they support js/wasm. It seems to me like TinyGo should at the very least publish the stub themselves; the APIs should compile on all platforms, even if all they do is always fail on the unsupported platforms. |
Apparently tinygo got support for SameFile on wasip2 with tinygo-org/tinygo#4027 (see types_unix.go). @diamondburned Is the SameFile exception still needed? |
- name: Build with Tinygo natively | ||
run: tinygo build -o /dev/null ./_tinygo | ||
- name: Build with Tinygo on WASM | ||
run: tinygo build -o /dev/null -target wasm ./_tinygo |
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.
It doesn't check whether the output behaviors correctly.
And I'm already using tinygo
with this package at https://github.com/un-ts/sh-syntax for a long time, although the json encoding
/decoding
parts are levered by easyjson
at https://github.com/un-ts/sh-syntax/blob/main/processor/structs_easyjson.go
I got this building in tinygo |
If someone wants to send a PR adding CI testing for tinygo, just to ensure that we don't do anything too funky in the future to break compatibility, I'm happy to review and merge. Ideally we run the tests, but in practice, just checking that the packages build and link, like this test does, is a good start. I still think and hope we don't need any stubs or compatibility code for tinygo. |
This PR contains commits that allow
mvdan.cc/sh/v3
to be built using Tinygo. The commit messages will contain more information.