fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.21k stars 247 forks source link

GoSDK - TinyGo V0.24.0 / Go 1.18.3 - compile error #624

Closed elewis787 closed 2 years ago

elewis787 commented 2 years ago

Using the latest golang and tiny go versions (go - 1.18.3 and tinygo v0.24.0 ) and running the make file in the Go SDK folder results in:

# github.com/fermyon/spin/sdk/go/http
http/internals.go:67:15: cannot use newSpinHeader(k, v[0]) (value of type spinHeader) as C._Ctype_struct___3 value in assignment
http/internals.go:105:9: cannot use (C.spin_http_string_t literal) (value of type C._Ctype_struct___1) as spinString value in return statement
http/internals.go:119:7: cannot use newSpinString(k) (value of type spinString) as C._Ctype_struct___1 value in struct literal
http/internals.go:120:7: cannot use newSpinString(v) (value of type spinString) as C._Ctype_struct___1 value in struct literal
http/internals.go:118:9: cannot use (C.spin_http_tuple2_string_string_t literal) (value of type C._Ctype_struct___3) as spinHeader value in return statement
http/outbound_internals.go:121:9: cannot use (C.wasi_outbound_http_string_t literal) (value of type C._Ctype_struct___10) as spinString value in return statement
http/outbound_internals.go:141:18: cannot use newOutboundString(k) (value of type spinString) as C._Ctype_struct___10 value in assignment
http/outbound_internals.go:142:18: cannot use newOutboundString(v[0]) (value of type spinString) as C._Ctype_struct___10 value in assignment
make: *** [http/testdata/http-tinygo/main.wasm] Error 1

This was first reported in the gopher wasm slack channel but I was able to reproduce this error after upgrading locally. I believe this error in TinyGo with their support for go 1.18 but I have not seen any related issues. I am opening this here to see if there are any additional thoughts before opening an issue in the TinyGo repo.

A quick work around is to use v0.22.0 and golang v1.17.+

radu-matei commented 2 years ago

I can confirm that I see the same issue when trying to build a Spin component with TinyGo 0.24 and Go 1.18 on main.

adamreese commented 2 years ago

I wrote a patch for this last week. I'll open a PR tomorrow.

radu-matei commented 2 years ago

Yay, thanks, @adamreese!

aykevl commented 2 years ago

For those interested, this issue was probably caused by a CGo refactor that made it a bit more strict: https://github.com/tinygo-org/tinygo/pull/2774