-
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
x/tools/go/gcexportdata: Read to support only 2 Go releases + tip #68898
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Move the documentation for indexed export data format from $GOROOT/src/cmd/compile/internal/typecheck/iexport.go to x/tools/internal/gcimporter/iexport.go . This is the only current writer of this format. Updates golang/go#68778 Updates golang/go#68898 Change-Id: I365f56315d03affc5860cf407ea6e3d0caa1a88e Reviewed-on: https://go-review.googlesource.com/c/tools/+/607495 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Change https://go.dev/cl/607495 mentions this issue: |
This proposal has been added to the active column of the proposals project |
After discussion with @griesemer, we agree that the support policy proposed here seems appropriate. Furthermore, we agree that purpose (1), a serialization format for types.Packages, should really move into the go/types package where it will be easier to maintain, since it won't need all the cleverness each time the toolchain upgrades (witness: aliases). We'll file a separate proposal for that: |
Is there ever a reason a tool using gcexportdata would need to read old export data? I can't think of any, but want to put the question out there. |
You may want to ship a single tool that is compatible with analyzing the output of a large range of go toolchains. Today this would be something like creating a single binary that supports working with builds of both the 1.18 and 1.24 (tip) toolchains. |
This is more a description of the hypothetical tool than a motivation for it. In any case, you could still build such a tool by forking the old importer. |
If for some reason you are working with multiple versions of go you wouldn't want to have, for example, multiple copies of staticcheck, each compiled with a different version of go. |
Thanks for playing devil's advocate everyone. :) I think we can move this forward. |
Have all remaining concerns about this proposal been addressed? The proposal is for |
I have one remaining somewhat theoretical concern. There are three relevant copies of the indexed format export data reader.
What this proposal means today, is that if it is accepted So this might just be a theoretical concern, but it is what I am worried about. |
I think we could probably delete $GOROOT/src/go/internal/gcimporter/iimport.go today. It is only used as the implementation of |
Change https://go.dev/cl/620135 mentions this issue: |
@timothy-king I've sent a CL for the deletion. In any case I don't think the concern has any bearing on this proposal. |
Change https://go.dev/cl/620036 mentions this issue: |
This CL eliminates the "goroot" flavor of TestIExportDataTypeParameterizedAliases, leaving just the "tools" flavor, and simplifies accordingly. The logic of the goroot version assumed that importer.Default() could read what gcexportdata.Write would write... except that that comments correctly stated the assumption was false. Updates golang/go#68898 Change-Id: Ifded4ed2cc2103de32ac869731176a49877d10e0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/620036 Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
The compiler hasn't emitted indexed export data files since go1.19, so this code, which is only statically reachable from go/importer.For("gc") aka importer.Default(), is not dynamically reachable since those files will not be in indexed format. Updates #68898 Change-Id: I12ea4e1b88da4fffdc9a07f318b9445a61e0d02b Reviewed-on: https://go-review.googlesource.com/c/go/+/620135 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
The
That's true, but this would only be a problem if "multiple versions" means "more than two Go releases plus tip". I don't know of any tools that fit this description, and given that the 2+tip support window would be--after this proposal--essentially uniform across all the Go project's modules, it doesn't seem like grounds for an exception here. |
Based on the discussion above, this proposal seems like a likely accept. The proposal is for |
No change in consensus, so accepted. 🎉 The proposal is for |
Change https://go.dev/cl/623638 mentions this issue: |
The gcexportdata package defines functions to export and import
types.Package
s as binary messages. They serve two purposes:gcexportdata.{Write,Read}
permit applications to serialize and deserialize type information. For example, gopls uses it for its index (database) of types.gcexportdata.Read
permits applications to read export data written by the Go compiler. For example, x/tools/go/packages uses this when NeedExport is set.For (1), all that matters is that the Write and Read functions (at the exact same version) can faithfully round-trip all aspects of a types.Package; the form of the message isn't important. Currently, it uses the "indexed" (
i
) form, which the compiler used prior to its support for inlining and generics. This form is obsolete within GOROOT and is mentioned only in a few stale references, including documentation at cmd/compile/internal/typecheck/iexport.go. We plan to purge GOROOT of all mention to thei
format, and move the docs to x/tools/internal.For (2), what matters is that
Read
can read export data written by supported versions of the compiler. The compiler currently uses the "unified" (u
) form. The gcexportdata package currently promises to "support[s] go1.7 export data format and all later versions". Given that almost all other promises of toolchain compatibility are limited to the last two Go releases (plus tip GOROOT), we propose to reduce Read's support window to match. (As a matter of fact, the code actually supports only as far back as go1.11.)@timothy-king @griesemer @findleyr
The text was updated successfully, but these errors were encountered: