New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/api: Assembly causes API compatibility check to fail #8425
Labels
Milestone
Comments
This is really cool. Simpler reproduction case: cd $GOROOT/src/cmd/api go run run.go # everything is fine touch $GOROOT/src/crypto/cipher/asm_amd64.s go run run.go # magical error from go/types 2014/09/15 11:20:08 error typechecking package crypto/x509: /Users/rsc/g/go/src/crypto/x509/pem_decrypt.go:49:14: cannot use des.NewCipher (value of type func(key []byte) (cipher.Block, error)) as func(key []byte) (cipher.Block, error) value in struct literal (windows-amd64) It seems like this has to be a bug in go/types. Somehow it is seeing two different 'cipher' packages, but I can't see how. Owner changed to @griesemer. Status changed to Accepted. |
Observations so far: 1) The bug is reproducible when considering only {GOOS: "darwin", GOARCH: "386"}, {GOOS: "windows", GOARCH: "amd64"}, as (goapi.go) contexts entries. 2) The pkgCache contents are different depending on whether the asm_amd64.s file is present or not: If the file is present, the pkgCache contains the keys (among others): $GOROOT/src/crypto/cipher $GOROOT/src/crypto/cipher,amd64 (otherwise it's just: $GOROOT/src/crypto/cipher ) 3) The presence of the assembly file affects the go/build.Package.AllTags list; if the file is present, the list contains the additional tag "amd64" for the cipher package. 4) This tag list is used to create the respective pkgCache keys (see 2). For reasons I don't fully understand yet, the type-checker must be using entries from the $GOROOT/src/crypto/cipher and $GOROOT/src/crypto/cipher,amd64 package at the same time - while the two packages are identical, the package pointers are not, resulting in an error. Possible explanations: - the goapi.go code assumes that the type-checker can handle packages that are isomorphic but have different package objects (that's not the case) - there's a bug in how goapi.go sets up the pkgCache. |
The pkgCache code is clearly not quite right. If we ever hit this in real code in the repo, we can pull out the pkgCache. But right now it's cutting 40% of the runtime for the api check, so I'd like to keep it. I have not checked, but I think maybe this would go away if there were build tags present for all possible architectures instead of amd64. The all possible thing is much more common: you have one file for amd64, one for 386, one for arm. Maybe there's overlap but you basically never have one for amd64 and nothing for 386/arm, or else you'd have an incomplete package on those. That can happen in external code maybe but not in the standard library. Because of that theory, it is possible that we will never see this in a real standard library package. Status changed to Unfortunate. |
See #21181 for the cause of this issue. |
gopherbot
pushed a commit
that referenced
this issue
Oct 5, 2018
The origin tagKey is just dirname if no tags input which will cause pkgCache missmatch if other imported pkg explicit on GOARCH or GOOS This CL will add GOOS and GOARCH to tagKey Fixes #8425 Fixes #21181 Change-Id: Ifc189cf6746d753ad7c7e5bb60621297fc0a4e35 Reviewed-on: https://go-review.googlesource.com/c/138315 Reviewed-by: Robert Griesemer <gri@golang.org>
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by qpingu:
The text was updated successfully, but these errors were encountered: