Skip to content
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

Allow building with Tinygo #1078

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

diamondburned
Copy link
Contributor

This PR contains commits that allow mvdan.cc/sh/v3 to be built using Tinygo. The commit messages will contain more information.

@mvdan
Copy link
Owner

mvdan commented May 28, 2024

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 cgo or purego would be enough for the code on master to already be portable. For example, with either CGO_ENABLED=0 or -tags=purego, os/user.Lookup on Linux should be a stub that returns nothing, why is that not enough for Tinygo?

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.

@diamondburned
Copy link
Contributor Author

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.

I made tinygo-org/tinygo#4278 to address this.

@mvdan
Copy link
Owner

mvdan commented Jul 31, 2024

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.
@diamondburned diamondburned force-pushed the tinygo-build branch 2 times, most recently from f39aaec to af574e1 Compare August 3, 2024 05:44
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
@diamondburned diamondburned force-pushed the tinygo-build branch 2 times, most recently from 2b3d6e3 to 8693c45 Compare August 3, 2024 17:15
@diamondburned
Copy link
Contributor Author

I got rid of a few stubs, but I still have to stub os.SameFile for Tinygo + WASM to work :(

@mvdan
Copy link
Owner

mvdan commented Aug 8, 2024

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.

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