tinylib / msgp

A Go code generator for MessagePack / msgpack.org[Go]
MIT License
1.81k stars 192 forks source link

Add unsafe flag #355

Closed jenn-k-f closed 3 months ago

jenn-k-f commented 3 months ago

Hello! I am currently using tinygo with msgp. However, tinygo version 0.31.0 started passing the flag purego which is causing the performance to take a hit, despite being okay with using the unsafe library.

I'd like to propose adding another flag into the msgp/unsafe.go and msgp/purego.go so that even if the purego flag is true, we can bypass and still use the unsafe library by setting another flag. Keeping the purego flag so that current uses aren't impacted.

ie) Change msgp/purego.go from:

//go:build purego || appengine
// +build purego appengine

to:

//go:build (purego && !unsafe) || appengine
// +build purego,!unsafe appengine

With a similar change in msgp/unsafe.go

Thanks!

dgryski commented 3 months ago

This issue (purego disabling unsafe instead of just assembly and cgo) was raised by one of the TinyGo developers at the time https://github.com/golang/go/issues/23172#issuecomment-2000390548 .

klauspost commented 3 months ago

It is of course clumsy, but pragmatically it seems reasonable, given that it is backwards compatible. Feel free to open a PR.

klauspost commented 3 months ago

Merged.