hash/maphash fails to compile with Go 1.27: undefined: abi.MapType
TinyGo 0.42.0 fails to compile any program that imports hash/maphash when built with Go 1.27. The same program builds with Go 1.26.
Reproducer
package main
import "hash/maphash"
func main() { var h maphash.Hash; h.WriteString("x"); println(h.Sum64()) }With Go 1.27.1:
$ tinygo build -o m.wasm -target wasm .
# internal/runtime/maps
.../go/1.27.1/src/internal/runtime/maps/group.go:298:39: undefined: abi.MapType
.../go/1.27.1/src/internal/runtime/maps/group.go:305:40: undefined: abi.MapType
.../go/1.27.1/src/internal/runtime/maps/group.go:327:25: undefined: abi.MapType
...
.../go/1.27.1/src/internal/runtime/maps/table.go:888:27: undefined: abi.MapGroupSlots
.../go/1.27.1/src/internal/runtime/maps/table.go:1032:32: undefined: abi.MapGroupSlotsBitsGo 1.26.8,
tinygo build -target wasm: buildsGo 1.27.1,
tinygo build -target wasm: fails as aboveGo 1.27.1,
tinygo build(native): fails the same wayGo 1.27.1,
go run: workstinygo version 0.42.0 darwin/arm64 (using go version go1.27.1 and LLVM version 22.1.4)
internal/abiondevstill has onlyabi.go,escape.go,funcpc.goandtype.go(checked 2026-09-15)
Cause
In Go 1.26, hash/maphash was split by build tag:
maphash_runtime.go(//go:build !purego) importsinternal/runtime/mapsmaphash_purego.go(//go:build purego) does not
TinyGo builds with the purego tag, so it used the pure Go version.
Go 1.27 removed that split. maphash.go now imports internal/runtime/maps for every build, and the purego file is gone. That package needs abi.MapType, abi.MapGroupSlots and abi.MapGroupSlotsBits, which TinyGo's internal/abi doesn't define.
TinyGo overrides runtime, reflect and unique, but not hash/maphash, so the Go 1.27 version is used as-is.
Impact
Anything that imports hash/maphash, directly or through a dependency, stops compiling on Go 1.27. We hit it through github.com/modelcontextprotocol/go-sdk → github.com/google/jsonschema-go (used for uniqueItems validation), while building a Cloudflare Worker with syumai/workers-go. The Worker build doesn't compile with TinyGo unless MCP is compiled out.
Possible fixes
- Provide a TinyGo version of
hash/maphashinsrc/hash/maphash, as is already done foruniqueandreflect. It would be based on the 1.26maphash_purego.goand not useinternal/runtime/maps. - Or add the Go 1.27 map types to TinyGo's
internal/abisointernal/runtime/mapscompiles. This is probably the larger change.
Source: tinygo-org/tinygo