-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Make capnpc-go output deterministic #145
Comments
Hm. Are you claiming that the output is not deterministic given the same version of Go and capnpc-go? That shouldn't be the case. I agree that the zlib output will not be deterministic over Go versions, but that shouldn't matter for the purposes of the generator. |
Based on your comment, i did some more digging, and eventually discovered something Odd. Using the .capnp files in https://gist.github.com/kormat/89d9a07b9d83f4ebebe14666b43bc326:
I.e. the output for a given .capnp file changes if other .capnp files are processed at the same time. Environment: |
Here's a diff of the generated files:
|
Looking at the decoded CodeGeneratorRequest, it doesn't look obviously wrong (implying the issue is in
I've updated the gist above (https://gist.github.com/kormat/89d9a07b9d83f4ebebe14666b43bc326) with the full generated capnp.go files, as well as the decoded code gen requests. |
As there can only be len(fnodes) of nodes in a schema var, use that for NewNodes() instead of the the number of files. This makes the output deterministic for compiling a .capnp file on its own, or with others on the same cmdline. Fixes capnproto#145
As there can only be len(fnodes) of nodes in a schema var, use that for NewNodes() instead of the the number of files. This makes the output deterministic for compiling a .capnp file on its own, or with others on the same cmdline. Fixes capnproto#145
As there can only be `len(fnodes)` of nodes in a schema var, use that for `NewNodes()` instead of the the number of files. This makes the output deterministic for compiling a .capnp file on its own, or with others on the same cmdline. Fixes capnproto#145
I found the issue, and sent a PR to fix it (#146) |
As there can only be `len(fnodes)` of nodes in a schema var, use that for `NewNodes()` instead of the the number of files. This makes the output deterministic for compiling a .capnp file on its own, or with others on the same command line. Fixes #145
Currently the output of capnpc-go is not deterministic: the
var schema_XXX
line can change even if the input (or tool version) does not.. This is a problem when you want to store the generated files in git (and want to be sure that you catch drift between the source .capnp files and the output .go files).This is caused by how the schema is encoded
(from https://github.com/capnproto/go-capnproto2/blob/master/capnpc-go/capnpc-go.go#L159):
Neither zlib nor capnp are guaranteed to produce deterministic/canonical output (AIUI).
Would it be possible to change to outputting a canonical representation of the schema instead?
The text was updated successfully, but these errors were encountered: