diff options
| author | Michael Pratt <mpratt@google.com> | 2021-09-30 13:26:19 -0400 |
|---|---|---|
| committer | Michael Pratt <mpratt@google.com> | 2021-10-04 20:20:20 +0000 |
| commit | 2dc91a25f619c49b5d64af1b92497705a3325951 (patch) | |
| tree | d4999df9e600eb73271ab4e84eff398c446e3bfc /src/cmd/api | |
| parent | 579ff8b1313479b795e3b536f7b9444094060b32 (diff) | |
| download | go-2dc91a25f619c49b5d64af1b92497705a3325951.tar.xz | |
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 <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Diffstat (limited to 'src/cmd/api')
| -rw-r--r-- | src/cmd/api/goapi.go | 5 |
1 files changed, 5 insertions, 0 deletions
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 { |
