wasilibs / nottinygc

Higher-performance allocator for TinyGo WASI apps
MIT License
64 stars 6 forks source link

error: Linking globals named 'runtime.SetFinalizer': symbol multiply defined! #44

Closed vikaschoudhary16 closed 9 months ago

vikaschoudhary16 commented 9 months ago
vikas@ xcp (master) $ go version
go version go1.19 linux/amd64
vikas@ xcp (master) $ tinygo build -o /work/out/wasi_wasm/xcp-guard.wasm -gc=custom -tags='custommalloc nottinygc_envoy' -scheduler=none -target=wasi main.go
error: Linking globals named 'runtime.SetFinalizer': symbol multiply defined!
make[1]: *** [Makefile.core.mk:147: out/wasi_wasm/xcp-guard.wasm] Error 1
make: *** [Makefile:58: docker.xcp-guard] Error 2

I am hitting above shared error when trying to build a wasm module with nottinygo. I have imported nottinygo in main.go and used tinygo build tags as per the README. nottinygo version is 0.7.1

anuraaga commented 9 months ago

Hi @vikaschoudhary16 - can you confirm you're using the latest version of TinyGo? I believe you may be using something older than 0.28.0 which is the floor from https://github.com/wasilibs/nottinygc/releases/tag/v0.4.0

vikaschoudhary16 commented 9 months ago

Thanks for replying @anuraaga . I first tried 0.30.0 and when I encountered this issue, I downgraded to 0.28.0

vikas@ xcp (master) $ sudo dpkg -i tinygo_0.28.0_amd64.deb
[sudo] password for vikas: 
dpkg: warning: downgrading tinygo from 0.30.0 to 0.28.0-dev

same error with both versions

anuraaga commented 9 months ago

Can you doublecheck, maybe adding tinygo version && before the build command? I know it can be easy to end up with some non-system tinygo in $GOPATH/bin if ever building it. The error looks exactly like what would show with pre-0.28 so if that's not the issue the only other thing that comes to mind is if your own codebase has some code with this line in it

https://github.com/wasilibs/nottinygc/blob/main/finalizer.go#L19

vikaschoudhary16 commented 9 months ago
vikas@ xcp (master) $ tinygo version &&  GOFLAGS=-mod=vendor TAG=vikas HUB=gcr.io/xcp-istio make docker.xcp-guard
tinygo version 0.30.0 linux/amd64 (using go version go1.19 and LLVM version 16.0.1)
mkdir -p out/wasi_wasm/
cd xfcc-guard; TMPDIR="/tmp/" tinygo build -o /work/out/wasi_wasm/xcp-guard.wasm -gc=custom -tags='custommalloc nottinygc_envoy' -scheduler=none -target=wasi main.go
error: Linking globals named 'runtime.SetFinalizer': symbol multiply defined!
make[1]: *** [Makefile.core.mk:147: out/wasi_wasm/xcp-guard.wasm] Error 1
make: *** [Makefile:58: docker.xcp-guard] Error 2
vikas@ xcp (master) $ grep -nr SetFinalizer .
./xfcc-guard/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine.go:29:                // setFinalizer defaults to runtime.SetFinalizer, but overridable for tests.
./xfcc-guard/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine.go:415:// releaseCode is a runtime.SetFinalizer function that munmaps the code.codeSegment.
./xfcc-guard/vendor/github.com/tetratelabs/wazero/internal/engine/compiler/engine.go:697:               setFinalizer:    runtime.SetFinalizer,
./xfcc-guard/vendor/github.com/wasilibs/nottinygc/finalizer.go:19://go:linkname SetFinalizer runtime.SetFinalizer
./xfcc-guard/vendor/github.com/wasilibs/nottinygc/finalizer.go:20:func SetFinalizer(obj interface{}, finalizer interface{}) {
./xfcc-guard/vendor/github.com/wasilibs/nottinygc/finalizer.go:58:              panic("BUG: SetFinalizer should have filtered out non-supported finalizer interface")

tinygo is 0.30.0 and there seems no other SetFinalizer, as seen through grep

vikaschoudhary16 commented 9 months ago

This was my env issue. Could not figure out what exactly, but it worked on another system.