Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-17584

[Go] Unable to build with tinygo

    XMLWordPrintableJSON

Details

    • Bug
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Go

    Description

      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, the `Len` and `Cap` fields are assumed to be `int` here: https://github.com/apache/arrow/blob/go/v9.0.0/go/arrow/bitutil/bitutil.go#L158-L159

      Go'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:

      tinygo build -tags noasm -o test.wasm ./main.go
      
                   
      # github.com/apache/arrow/go/v10/arrow/bitutil
      ../../go/pkg/mod/github.com/apache/arrow/go/v10@v10.0.0-20220831082949-cf27001da088/arrow/bitutil/bitutil.go:158:10: invalid operation: h.Len / uint64SizeBytes (mismatched types uintptr and int)
      ../../go/pkg/mod/github.com/apache/arrow/go/v10@v10.0.0-20220831082949-cf27001da088/arrow/bitutil/bitutil.go:159:10: invalid operation: h.Cap / uint64SizeBytes (mismatched types uintptr and int)
      

      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-L777

      This feels like an issue with TinyGo, and it has been ticketed there multiple times (see https://github.com/tinygo-org/tinygo/issues/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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tschaub Tim Schaub
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 4h 10m
                  4h 10m