From 2dc91a25f619c49b5d64af1b92497705a3325951 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 30 Sep 2021 13:26:19 -0400 Subject: cmd/api: set architecture sizes when type checking Otherwise the type checker defaults to amd64, which can break type-checking for definitions using unsafe.Sizeof. This has the side effect of changing the API output: constants with different values across architectures (e.g., MaxInt) are now individually listed per-arch. This actually makes the API file more accurate, but does introduce a one-time discontinuity. These changes have been integrated into the API files where the constants were added. Change-Id: I4bbb0b7a7f405d3adda2d83869475c8bacdeb6a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/353331 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Dmitri Shuralyov Reviewed-by: Robert Findley Reviewed-by: Alexander Rakoczy --- src/cmd/api/goapi.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/cmd/api') diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go index b07a238d67..43c761a657 100644 --- a/src/cmd/api/goapi.go +++ b/src/cmd/api/goapi.go @@ -653,10 +653,15 @@ func (w *Walker) ImportFrom(fromPath, fromDir string, mode types.ImportMode) (*t } // Type-check package files. + var sizes types.Sizes + if w.context != nil { + sizes = types.SizesFor(w.context.Compiler, w.context.GOARCH) + } conf := types.Config{ IgnoreFuncBodies: true, FakeImportC: true, Importer: w, + Sizes: sizes, } pkg, err = conf.Check(name, fset, files, nil) if err != nil { -- cgit v1.3-6-g1900