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

tinygo with flabuffers branch not working #8

Open
gedw99 opened this issue May 7, 2021 · 7 comments
Open

tinygo with flabuffers branch not working #8

gedw99 opened this issue May 7, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@gedw99
Copy link

gedw99 commented May 7, 2021

openpgp-mobile git:(flatbuffers) ✗ make wasm_tinygo 
mkdir -p output/wasm
tinygo build -tags=math_big_pure_go -o output/wasm/openpgp.wasm -target wasm wasm/main.go
# encoding/asn1
/usr/local/opt/go/libexec/src/encoding/asn1/asn1.go:1100:15: cannot convert nil (untyped nil value) to reflect.Type
make: *** [wasm_tinygo] Error 1
@jerson
Copy link
Owner

jerson commented May 7, 2021

hi @gedw99 yes this is the last issue i had with tinygo and flatbuffers, im still in the process, but at least for now .wasm with go is like 3mb less

@jerson
Copy link
Owner

jerson commented May 7, 2021

an update to this, if you pull latest changes from flatbuffers and use this version:

➜  openpgp-mobile git:(flatbuffers) go version
go version go1.15.11 linux/amd64
➜  openpgp-mobile git:(flatbuffers) tinygo version
tinygo version 0.17.0 linux/amd64 (using go version go1.15.11 and LLVM version 11.0.0)
➜  openpgp-mobile git:(flatbuffers) make wasm_tinygo
mkdir -p output/wasm
tinygo build -tags=math_big_pure_go -o output/wasm/openpgp.wasm -target wasm wasm/main.go
cp `tinygo env TINYGOROOT`/targets/wasm_exec.js  output/wasm/wasm_exec.js
cp output/wasm/openpgp.wasm wasm/sample/public/openpgp.wasm
cp output/wasm/wasm_exec.js  wasm/sample/public/wasm_exec.js

wasm tinygo build succesfully but when i try to test in sample returns an error

➜  openpgp-mobile git:(flatbuffers) ✗ cd wasm/sample 
➜  sample git:(flatbuffers) ✗ yarn
yarn install v1.22.10
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.15s.
➜  sample git:(flatbuffers) ✗ yarn start
yarn run v1.22.10
$ node server.js
Wasm app listening on port 3000!

image

seems like i need to add a missing hash to make it work

panic: crypto: requested hash function #357444 is unavailable

and about this error syscall/js.finalizeRef not implemented there is a fix inside tinygo tinygo-org/tinygo#1140 (comment) but the main issue is crypto: requested hash function #
image

@gedw99
Copy link
Author

gedw99 commented May 14, 2021

thanks for the hints. I have not started to dig into them.

Tinygo updated to v0.18.0 yesterday with some wasm changes, so first trying that.

On branch flatbuffers
Your branch is up to date with 'origin/flatbuffers'.

tinygo version
tinygo version 0.18.0 darwin/amd64 (using go version go1.16.3 and LLVM version 11.0.0)

classic go wasm

cd openpgp-mobile && /Applications/Xcode.app/Contents/Developer/usr/bin/make wasm
mkdir -p output/wasm
cd wasm && GOARCH=wasm GOOS=js go build -ldflags="-s -w" -o ../output/wasm/openpgp.wasm main.go
cp `go env GOROOT`/misc/wasm/wasm_exec.js  output/wasm/wasm_exec.js
cp output/wasm/openpgp.wasm wasm/sample/public/openpgp.wasm
cp output/wasm/wasm_exec.js  wasm/sample/public/wasm_exec.js

tinygo wasm

cd openpgp-mobile && /Applications/Xcode.app/Contents/Developer/usr/bin/make wasm_tinygo
mkdir -p output/wasm
tinygo build -tags=math_big_pure_go -o output/wasm/openpgp.wasm -target wasm wasm/main.go
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7c65997]

runtime stack:
runtime.throw(0x80ba113, 0x2a)
        /usr/local/go/src/runtime/panic.go:1117 +0x72
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:718 +0x2ef

goroutine 12 [syscall]:
runtime.cgocall(0x4365610, 0xc00586d890, 0xc0058a35e8)
        /usr/local/go/src/runtime/cgocall.go:154 +0x5b fp=0xc00586d860 sp=0xc00586d828 pc=0x40053bb
tinygo.org/x/go-llvm._Cfunc_LLVMVerifyModule(0xa50b8f0, 0xc000000001, 0xc0058a35e8, 0x0)
        _cgo_gotypes.go:9578 +0x48 fp=0xc00586d890 sp=0xc00586d860 pc=0x4259d08
tinygo.org/x/go-llvm.VerifyModule.func1(0xa50b8f0, 0xc000000001, 0xc0058a35e8, 0x0)
        /Users/distiller/go/pkg/mod/tinygo.org/x/go-llvm@v0.0.0-20210325115028-e7b85195e81c/analysis.go:38 +0x99 fp=0xc00586d8c0 sp=0xc00586d890 pc=0x4265679
tinygo.org/x/go-llvm.VerifyModule(0xa50b8f0, 0x1, 0x3, 0x4)
        /Users/distiller/go/pkg/mod/tinygo.org/x/go-llvm@v0.0.0-20210325115028-e7b85195e81c/analysis.go:38 +0x56 fp=0xc00586d910 sp=0xc00586d8c0 pc=0x425a0d6
github.com/tinygo-org/tinygo/transform.OptimizeReflectImplements(0xa50b8f0)
        /Users/distiller/project/transform/rtcalls.go:185 +0x850 fp=0xc00586da40 sp=0xc00586d910 pc=0x4314af0
github.com/tinygo-org/tinygo/transform.Optimize(0xa50b8f0, 0xc00024def0, 0x2, 0x2, 0x5, 0x0, 0x0, 0x0)
        /Users/distiller/project/transform/optimizer.go:69 +0x2e5 fp=0xc00586dda0 sp=0xc00586da40 pc=0x430f1e5
github.com/tinygo-org/tinygo/builder.optimizeProgram(0xa50b8f0, 0xc00024def0, 0xc002936650, 0x2)
        /Users/distiller/project/builder/build.go:698 +0x14e fp=0xc00586de10 sp=0xc00586dda0 pc=0x43235ee
github.com/tinygo-org/tinygo/builder.Build.func2(0xc005d65aa0, 0x0, 0x0)
        /Users/distiller/project/builder/build.go:390 +0x7c6 fp=0xc00586df70 sp=0xc00586de10 pc=0x4333cc6
github.com/tinygo-org/tinygo/builder.jobWorker(0xc0005aa180, 0xc0005aa120)
        /Users/distiller/project/builder/jobs.go:165 +0xe2 fp=0xc00586dfd0 sp=0xc00586df70 pc=0x432c542
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc00586dfd8 sp=0xc00586dfd0 pc=0x406c3c1
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:84 +0xc5

goroutine 1 [chan receive]:
github.com/tinygo-org/tinygo/builder.runJobs(0xc0028bb6a0, 0x3, 0x4, 0x0, 0x0)
        /Users/distiller/project/builder/jobs.go:116 +0x12e
github.com/tinygo-org/tinygo/builder.Build(0x7ffeefbff29d, 0xc, 0x7ffeefbff277, 0x18, 0xc00024def0, 0xc00701bb18, 0x0, 0x0)
        /Users/distiller/project/builder/build.go:609 +0x2725
main.Build(0x7ffeefbff29d, 0xc, 0x7ffeefbff277, 0x18, 0xc000292000, 0x0, 0x12)
        /Users/distiller/project/main.go:111 +0xc8
main.main()
        /Users/distiller/project/main.go:1047 +0xf5a

goroutine 9 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc0005aa180, 0xc0005aa120)
        /Users/distiller/project/builder/jobs.go:162 +0x85
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:84 +0xc5

goroutine 10 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc0005aa180, 0xc0005aa120)
        /Users/distiller/project/builder/jobs.go:162 +0x85
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:84 +0xc5

goroutine 11 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc0005aa180, 0xc0005aa120)
        /Users/distiller/project/builder/jobs.go:162 +0x85
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:84 +0xc5
make[1]: *** [wasm_tinygo] Error 2
make: *** [go-build-wasm-tiny] Error 2



@gedw99
Copy link
Author

gedw99 commented May 14, 2021

@jerson
Copy link
Owner

jerson commented May 14, 2021

if you want to use upgrade script you need to specify a version, bc flatbuffers is a prerelease

https://github.com/jerson/openpgp-mobile/releases/tag/v1.0.0-rc0

VERSION=v1.0.0-rc0 ./upgrade_bridge_flatbuffers.sh

@gedw99
Copy link
Author

gedw99 commented May 14, 2021

thanks - will try now.

@gedw99
Copy link
Author

gedw99 commented May 14, 2021

flutter project is bailing on me.

Will raise an issue if i cant sort out whats going on.

@jerson jerson added the enhancement New feature or request label May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants