-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Go] Unable to build with tinygo #32832
Comments
Matthew Topol / @zeroshade: |
Tim Schaub: I started to put together a change that converts the casting functions to use For example, I was assuming func bytesToUint64(b []byte) []uint64 {
return unsafe.Slice((*uint64)(unsafe.Pointer(&b[0])), len(b)/uint64SizeBytes)
} But I'm uncertain if that is the correct length/capacity. If you have thoughts on the correct implementation, I would be happy to put together a pull request that changes this and the other casting functions. |
Matthew Topol / @zeroshade: func bytesToUint64(b []byte) []uint64 {
return unsafe.Slice((*uint64)(unsafe.Pointer(&b[0])), len(b)/uint64SizeBytes)
} Would be the correct implementation (no need to bother with pulling the SliceHeader in this case. If you're up for putting together a pull request that would be fantastic. Go for it and just tag me on the PR when you file it and I'll give it a review. Thanks much! |
Tim Schaub: I think there are still issues with the changes (tests are failing for me), but I put up a draft PR: #14026 |
Matthew Topol / @zeroshade: |
Apache Arrow JIRA Bot: |
@zeroshade -- Hi from FDS! I just ran across this issue and a previous attempt in #14026 to support tinygo. We are successfully building using the native I'm not sure what the cost of supporting tinygo would be but if there is any interest in doing so we would be game to help and test. We are wanting to compile to WASM so that we can use a lot of tooling around Arrow tables that we've implemented in Go, in the browser as well. |
Howdy @chriscasola! Hope all is well over there! 😄 If I remember correctly, the thing that was holding back tinygo at that point was an issue with thrift (because Parquet still uses thrift under the hood) and a It's likely possible to muck about with build constraints to exclude the parquet libs from a tinygo/wasm build and avoid that issue if it still exists. Feel free to give it a shot and poke about with it in a PR. I don't have the time at the moment to try this myself but I can definitely review a PR if you submit one. |
### Rationale for this change To support compiling with tinygo which enables use of arrow in environments where binary size is important, like web assembly. ### What changes are included in this PR? Using an internal JSON package that uses `goccy/go-json` for regular builds as it does currently, but uses the native `encoding/json` for tinygo builds. This is necessary because go-json has a lot of code that is incompatible with tinygo. Remove dependency on `parquet` package from non-parquet code since it is also incompatible with tinygo. Other minor tweaks for compatibility with tinygo. ### Are these changes tested? Should we add a build step that compiles the example with tinygo? ### Are there any user-facing changes? None. * Closes: #32832 Lead-authored-by: Chris Casola <ccasola@factset.com> Co-authored-by: Adam Gaynor <adam.gaynor@factset.com> Signed-off-by: Matt Topol <zotthewizard@gmail.com>
I was hoping to use TinyGo to build WASM binaries with Arrow. TinyGo can generate builds that are 1% the size of those generated with Go (significant for applications hosted on the web).
Arrow's use of
reflect.SliceHeader
fields limits the portability of the code. For example, theLen
andCap
fields are assumed to beint
here: https://github.com/apache/arrow/blob/go/v9.0.0/go/arrow/bitutil/bitutil.go#L158-L159Go's reflect package warns that the SliceHeader "cannot be used safely or portably and its representation may change in a later release."
Attempts to build a WASM binary using the github.com/apache/arrow/go/v10 module result in failures like this:
This happens because TinyGo uses
uintptr
for the corresponding types: https://github.com/tinygo-org/tinygo/blob/v0.25.0/src/reflect/value.go#L773-L777This feels like an issue with TinyGo, and it has been ticketed there multiple times (see tinygo-org/tinygo#1284). They lean on the warnings in the Go sources that use of the SliceHeader fields makes code unportable and suggest changes to the libraries that do not heed this warning.
I don't have a suggested fix or alternative for Arrow's use of SliceHeader fields, but I'm wondering if there would be willingness on the part of this package to make WASM builds work with TinyGo. Perhaps the TinyGo authors could also offer suggested changes.
Reporter: Tim Schaub
PRs and other links:
Note: This issue was originally created as ARROW-17584. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: