-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
go/build: importing with UseAllFiles
on Go 1.20 and 1.21 fails for build-constrained files that use Go 1.22 #cgo directives
#63293
Comments
The presence of Go 1.22 #cgo directives in any file prevents the module from being vendored by Go 1.21 or below, even if the file has build constraints. Revert the Go 1.22 directives for now so the module can be vendored into projects using Go 1.21 or Go 1.20.
Huh, yep. This was probably introduced in https://go.dev/cl/283641, and is related to this TODO: It looks like we're also missing a The right solution might be to always ignore errors from |
Even if this issue is not new, given that it now will occur more due to the addition of the new #cgo directives in go1.22, would it make sense to mark this as release blocker? |
I think we should consider reworking the new |
@golang/compiler: what are your opinions on adjusting the directive syntax? |
@bcmills do you have a suggestion for a different syntax? Is that any |
Yes, it looks that way. The Go 1.21 parser implementation is here: Notably, it has a To me, that suggests that maybe we could use a |
In compiler/runtime triage, we're wondering if it's an option to update older supported releases to accept the new cgo directive? |
That may be an option, yes. It would involve at least backporting portions of https://go.dev/cl/497837 in the |
Another option would be have the go command to not error for directives in files with a build tag of newer version of Go. This would also help if in the future we add other cgo directives. Would syntax like |
Yep, we should probably do that but it's a somewhat more involved change, and of course it only helps once a fix is backported and released and users upgrade to it. 🙃
Unfortunately no: any program that uses (Perhaps for the purpose of future-proofing we should make |
UseAllFiles
on Go 1.20 and 1.21 fails for build-constrained files that use Go 1.22 #cgo directives
@corhere, for the moment I suggest that you file an issue against https://github.com/golang-fips/openssl to roll back the use of these new directives. |
Change https://go.dev/cl/539235 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
No output;
go mod vendor
succeeds.What did you see instead?
internal error: failed to find embedded files of github.com/golang-fips/openssl/v2: /Volumes/Workspace/pkg/mod/github.com/golang-fips/openssl/[email protected]/cgo_go122.go: invalid #cgo line: #cgo noescape go_openssl_EVP_PKEY_derive
The cgo_go122.go file has a
//go:build go1.22
build constraint so the module is otherwise compatible with Go 1.21; it builds without error. The module just cannot be vendored.The text was updated successfully, but these errors were encountered: