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

compiling wasm package using tinygo failed due to unsupported library #250

Closed
Rizary opened this issue Sep 15, 2021 · 4 comments
Closed
Assignees

Comments

@Rizary
Copy link
Contributor

Rizary commented Sep 15, 2021

I try to compile the wasm package using tinygo and get an error that I describe here.

Moreover, I found this list of package that is supported by tinygo here.

When looking at mapstructure, I only found 2 files that using it, 0chain/gosdk/zboxcore/fileref/list.go and 0chain/gosdk/zboxcore/fileref/refpath.go.

There might be another error that is related it so I may open this issue until wasm package is successfully compiled with tinygo.

any thought, @cnlangzi @moldis @mallochine?

@cnlangzi
Copy link
Contributor

It is fine to remove reflect package from gosdk. It seems is only used on validator. I am going to refactor ReferencePath parts.

@mallochine
Copy link
Contributor

mallochine commented Oct 22, 2021

I wrote this back in June to Saswata. I tried for a couple hours to get tinygo working because it had a nice compilation feature to automatically translate functions so we don't have wrapper code.

I found it was a deadend because tinygo does not support network calls. Did you find something has changed in the past 4 months? Do they support network calls now?

the biggest reason why all these gosdk functions are not immediately accessible is -- there is no "automatic" translation of a golang function to a "JS function" that can be called.
for example, if there was func HelloWorld() , you need to explicitly write the wrapper golang code that JS can use to call "HelloWorld".
the tinygo compiler has feature: //export HelloWorld that automatically creates that wrapper code, so it becomes a lot simpler to export those libraries. However! tinygo is a deadend for our approach because tinygo does not support network calls. I already have this 20 line program proving network calls to get tinygo working (At Ryan Stewart's request). Tinygo is deadend and cannot be used (edited)

@mallochine
Copy link
Contributor

already have this 20 line program proving network calls to get tinygo working (At Ryan Stewart's request). Tinygo is deadend and cannot be used (edited)

@mallochine
Copy link
Contributor

mallochine commented Oct 22, 2021

Here was the 20 line program:

package main

import "net/http"

// Generated by curl-to-Go: https://mholt.github.io/curl-to-go

// curl https://www.google.com

func main() {
	resp, err := http.Get("https://www.google.com")
	if err != nil {
		// handle err
	}
	defer resp.Body.Close()
}

Try compiling with: "tinygo build -o tinygo.wasm -target wasm ./tinygo.go"

/opt/homebrew/Cellar/go/1.16/libexec/src/net/pipe.go:156:16: ErrDeadlineExceeded not declared by package os

while compiling with the normal wasm does work

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

No branches or pull requests

3 participants